Gs2 --> gs1 Shovel

Been trying to convert this shovel written in Gs2 back to Gs1. So far it hasnt been working :whatever:. I guess the easiest way to do this is to post the script, and have you more knowledgable scripters out there take a look and see if you can spot whats making it not work?

To be honest I can’t quite remember where I found this script. I know it’s off Agret’s DVD…I’m thinking Classic 06’. Anyways…

Shovel NPC:

//#CLIENTSIDE

if (weaponfired) {
  {
    this.tiles ={
      2176,
      2177,
      2192,
        2193
          };
    
    setani shovel,;
    
    freezeplayer 1;
    sleep 0.5;
    
    ar = {playerx + (vecx(playerdir) * 2) + 1.1,
      playery + (vecy(playerdir) * 2) + 1.1};
    
    showimg 2001,"@Courier [email protected]@+", ar[0], ar[1];
    
    if (tiles[ar[0],ar[1]] == 2240){
      this.num = int(random(1,9));
      if (this.num == 4){
        setplayerprop#c,;
        if (params[0] == "dirt"){
          
          ar = {playerx + (vecx(playerdir) * 2) + 1.1,
            playery + (vecy(playerdir) * 2) + 1.1};
          
          putnpc ar[0],ar[1],"join digitems;";
          
          temp.num = int(random(1,4));
          temp.owner = #a;
          
          with(npcs[npcs.size()-1]) {
            this.num = temp.num;
            this.owner = temp.owner;
          }
        }
      }
      if (tiles[ar[0],ar[1]] in this.tiles){
        this.num = int(random(1,9));
        if (this.num == 4){
          setplayerprop#c,;
          
          if (params[0] == "grass"){
            
            ar = {playerx + (vecx(playerdir) * 2) + 1.1,
              playery + (vecy(playerdir) * 2) + 1.1};
            
            putnpc2(ar[0], ar[1], "join digitems;");
            
            temp.num = 4;
            temp.owner = #a;
            
            with(npcs[npcs.size()-1]) {
              this.num = temp.num;
              this.owner = temp.owner;
            }
            
          }
        }
        
      }
    }
    
    sleep 0.5;
    
    setani idle,;
    hideimg 2001;
  }
}

digitems class:

[CODE]if (created) {
this.numb = int(random(1,6));
this.time = 30;
setshape 1,32,32;
if (this.num == 1){
message SeaShell1;
setimg block.png;
}
if (this.num == 2){
message SeaShell2;
setimg block.png;
}
if (this.num == 3){
message SeaShell3;
setimg block.png;
}
if (this.num == 4){
message Money - @this.numb;
setimg block.png;
}
timeout = 1;
}
if (playertouchsme) {
if (#a == this.owner || this.time == 0){
if (this.num == 1){
client.seashell1 +=1;
destroy;
}
if (this.num == 2){
client.seashell2 +=1;
destroy;
}
if (this.num == 3){
client.seashell3 +=1;
destroy;
}
if (this.num == 4){
playerrupees +=this.numb;
destroy;
}
}
}
if (timeout) {
if (this.time != 0){
this.time -=1;
}
timeout = 1;
}

[/CODE]

I don’t think you can use join. xD

You can use join however, not in the proper manner.
Properly, join appends code once the code is run.
However the GServer cannot run code; Crude hack? Find “join something;” delete “join something;” append something.txt to he end of the script thats is being sent.

I changed it around a little but…

Debugging it offline highlights this below… any ideas as to if this is really incorrect or how to fix it?

putnpc ar[0],ar[1],digitems.txt;

putnpc imgname,scriptname,x,y; creates a npc, scriptname is the name of a textfile containing the npc script

I removed some of the double = signs… good, bad? I’m still not getting anything either way though. I added in the corect putnpc format as you said Shiny…this is what I have:

//#CLIENTSIDE

if (weaponfired) {
  {
    this.tiles ={
      2176,
      2177,
      2192,
        2193
          };
    
    setani shovel,;
    
    freezeplayer 1;
    sleep 0.5;
    
    ar = {playerx + (vecx(playerdir) * 2) + 1.1,
      playery + (vecy(playerdir) * 2) + 1.1};
    
    showimg 2001,"@Courier [email protected]@+", ar[0], ar[1];
    
    if (tiles[ar[0],ar[1]]=2240){
      this.num=int(random(1,2));
      if (this.num=1){
        setplayerprop#c,!;
        if (params[0]=dirt){
          
          ar = {playerx + (vecx(playerdir) * 2) + 1.1,
            playery + (vecy(playerdir) * 2) + 1.1};
          
          putnpc block.png,digitems.txt,ar[0],ar[1];
          
          temp.num=int(random(1,2));
          temp.owner=#a;
          
          with(npcs[npcs.size()-1]) {
            this.num=temp.num;
            this.owner=temp.owner;
          }
        }
      }
      if (tiles[ar[0],ar[1]] in this.tiles){
        this.num=int(random(1,2));
        if (this.num=1){
          setplayerprop#c,!!;
          
          if (params[0]=grass){
            
            ar = {playerx + (vecx(playerdir) * 2) + 1.1,
              playery + (vecy(playerdir) * 2) + 1.1};
            
            putnpc block.png,digitems.txt,ar[0],ar[1];
            
            temp.num=1;
            temp.owner=#a;
            
            with(npcs[npcs.size()-1]) {
              this.num=temp.num;
              this.owner=temp.owner;
            }
            
          }
        }
        
      }
    }
    
    sleep 0.5;
    
    setani idle,;
    hideimg 2001;
  }
}

== is for comparisons.
= is for assigning.

Also I’m sure theres a shovel script somewhere on the forums somewhere, one that will confuse you less.

To elaborate:
[php]
if (test == 5) {
foo = 2;
}[/php]

I gotcha

But can you find random items digging with it :stuck_out_tongue:

Aye but that won’t matter if you can’t figure out how the shove itself works.

I have another shovel NPC thats the standard i guess. Using updateboard and putobject to lay the dirt hole, but looking at it next to the one im trying to work with here, they’re very different :frowning:

Well its GS2. Also, there’s plenty of ways to make something, there’s no one way to make something.

Also its good to even have objects that you dig up planned first. A simple gralat would help you for now as a test. O_o

The objects are in the class in the first post. Images are placeholders of course.

Looks like Classic’s shovel. Just make your own. This one sucks. (Trust me I work on Classic)

//Shovel Script
//#CLIENTSIDE
if(created){
  setimg wspade0.gif;
  toweapons Shovel;
  setstring this.on,0;
}
if(weaponfired){
  if(this.on==0){
    this.on=1;
    setani shovel,;
    if(playerdir=0){
        
        putnpc pics1.png,hole.txt,playerx+.5,playery-1;
    } 
    if(playerdir=1){
        
        putnpc pics1.png,hole.txt,playerx-2,playery+2;
    }
    if(playerdir=2){
        
        putnpc pics1.png,hole.txt,playerx+.5,playery+3;
    }  
    if(playerdir=3){
        
        putnpc pics1.png,hole.txt,playerx+3,playery+2;
    }
    freezeplayer .3;
    sleep .3;
  } else {
    this.on=0;
    setani idle,;
  }
}

[code]
//hole script
//#CLIENTSIDE
if(created){
setimgpart pics1.png,(1658),(1618),(162),(162);
dontblock;
drawunderplayer;
this.rand=random(0,13);

if(this.rand>=0 && this.rand<3) setplayerprop #c, … ;
if(this.rand>=3 && this.rand<6) lay2 greenrupee,x+.25,y-.3;
if(this.rand>=6 && this.rand<9) lay2 bombs,x+.25,y-.3;
if(this.rand>=9 && this.rand<12) lay2 bluerupee,x+.25,y-.3;
if(this.rand>=12 && this.rand<15) lay2 darts,x+.25,y-.3;
if(this.rand>=15 && this.rand<18) lay2 redrupee,x+.25,y-.3;
if(this.rand>=18 && this.rand<19) lay2 hearts,x+.25,y-.3;
if(this.rand>=19 && this.rand<20) lay2 goldrupee,x+.25,y-.3;
timeout=3;
}
if(timeout){
destroy;
}[/code]

this is the script i had made for a shovel . however urza had edited it to make it function right .