Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Variable-specific item usage

6 years ago

So let's use an example so I can explain myself well.

You have an object called Cast A Spell, and there's a variable called Magic. You can only use Cast A Spell on a certain page if you have 50 or more Magic. When you have 50 or more Magic, it removes 50 Magic from the variable and takes you to a new page.

How would I implement this through scripting, exactly?

Variable-specific item usage

6 years ago

Anyone willing to help with this?

Variable-specific item usage

6 years ago

Suppose you wanted the item to take the player to page 22 if they're on page 11 and their magic is fifty or greater. This is what you'd put in the item script:

IF $PAGEID = 11 THEN IF %MAGIC >= 50 THEN BEGIN
  %MAGIC := %MAGIC - 50
  $DEST := @P22
END

Just replace the IDs as appropriate.

Variable-specific item usage

6 years ago

I see! Thank you! What about lowering the variable by the same amount required to take you to that page? So as an example, what if I wanted the variable of Magic to decrease by 50 if you use it to take you to that page?

Variable-specific item usage

6 years ago

That's what the %MAGIC := %MAGIC - 50 is for.

Variable-specific item usage

6 years ago

Ahh, thank you!

Variable-specific item usage

6 years ago

One more question, if you don't mind, since I am fairly new to scripting.

The item script settings says that the script will only be run when the item is used on a page that you've set to take you to a certain destination.

What does that... mean? Does that mean each page that the item, Magic, is usable on, has to have a dedicated page to it if you don't have enough Magic?

For example, instead of "You can't use that item here!" if you don't have enough magic, every page has to have a unique failure page, like "the fireball sputters out due to your lack of magic" or the script won't work?

Variable-specific item usage

6 years ago

I don't recall ever experiencing anything like this. The item script runs every time the item is used. If, afterwards, the $DEST variable hasn't been changed, you get the "the item cannot be used here" message.

Variable-specific item usage

6 years ago

Ahh, I see. Thank you.