Help with a script!

if (playertouchsme) { lay2 itemx OR itemy,x,y; }
how to write this? ^^

Like random drop? Make a random number and use modular division on it by 2. Raise that number for different odds.

I don’t understand why you cannot figure these out on your own.

if ( playertouchsme ){
  this.item = ( random(0,1) > 0.5 ) ? itemID1 : itemID2;
  lay2 this.item,x,y;

The ternary operation is nice in this case and basically acts as an if-else. Have fun!

I was trying the same ^^ but look.

Whoops, I was under the impression lay2 used an index instead of an actual string. I’ll leave you to fix up the code, you’ll not be able to use the ternary operation with strings though…
Btw, do you even bother reading commands.rtf?

Yep but my english isnt so good :smiley:
anyways i have the script but i thought there is one which isnt so long

If (timeout) {
This.item = int(random(1,5)) 
} timeout =0.05;

If (this.item==1) { lay goldrupee }
If (this.item==2) { lay redrupee }

Etc… :slight_smile:

Stefan’s English wasn’t all that great when he typed it up.

Didn’t beholder or somebody come out with a revised edition that was easier to understand?

I’d advise again the use of conditionals outside of events as they’ll lead to unpredictable outcomes.
Your script should instead look like this

if (playerenters || timeout ){
  this.item = int(random(1,5));

  If (this.item==1) { lay goldrupee }
  If (this.item==2) { lay redrupee }

  timeout = 0.05;

Sorted better, and has some stuff added from the newfeature documents. Btw, if you’re new to GraalScript you should read those.

also I guess you’re talking about the NSB but I like the commands.rtf in the other thread better.