Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

Scripting with items

11 years ago

I'm using a lot of scripting in my next game and I'm trying to make it so that a certain page says something different based on whether or not you have a certain item. Is there any way I can:

A: Use the item in the scripting, something along the lines of "Number of bananas = 1, page says "You have a banana". Number of bananas = 0, page says "You don't have a banana.""

Or B: Make it so that a variable changes when you pick the item up. That way I can use the variable to change what the page says.

Scripting with items

11 years ago

http://chooseyourstory.com/help/articles/article.aspx?ArticleId=65

Is what you want. Basically, each item is given a number (it's beside the item on the item menu). If the player has the item, then $ITEMSTATE01 = 1, otherwise $ITEMSTATE01 = 0.

Replace 01 with the item number, and there you go.

Scripting with items

11 years ago

Thank you! heart

Scripting with items

11 years ago

Damn, didn't work. I tried using %%$ITEMSTATE01%=%0%Blah blah blah%% But the words showed up whether I had the item or not. I also tried alternating the 01 with 1, but that didn't fix it. Is there something wrong with the scripting I used?

Scripting with items

11 years ago

Use can't use System Variables ($) On-Page like you can Normal Variables (%) unfortunately...

---

What you can do however, is make your own Normal Variables to track Item Uses in correlation with the Items themselves and display them - such as:

Healing Potions Left: %%HEALPO%%

Scripting with items

11 years ago

... Yeah, I didn't understand a word of that, I'm too blonde.

If you mean that you can come up with a variable for your items, but what I'd like to know is, is there a way to make it so that the variable changes when you pick the item up? So far I can only figure out how to change a variable when you go to a different page, but somebody might go to a new page without picking the item up, so that doesn't work so well.

Sorry I always annoy people with these questions. I do try to read the articles about scripting, but I just don't understand what they're talking about. cheeky

Scripting with items

11 years ago

There is a way. In the globlal page script have something like:

IF $ITEMSTATE01 = 1 THEN
%HASITEM01 := 1 ELSE
%HASITEM01 := 0

For each item you are checking. Then it will run that script every time they enter a page.

Scripting with items

11 years ago

Hmm... Not sure it's working. Is that exactly how you'd post it into the global script? I imagine you're supposed to change the "HASITEM01" bit to the name of whichever variable you want to use, but other than that is there something else you need to do before putting the code into the global page?

Scripting with items

11 years ago

Yeah, that should be all you need. $ITEMSTATE01 checks if the player has the item or not, %HASITEM01 is just whatever you want to call the variable. Have %HASITEM01 show on every page to see if it updates.

Did you put it in the global page script (on the scripts tab)?

Scripting with items

11 years ago

Oh sorry, my bad! It does work, but it doesn't work as soon as you pick the item up if there's scripting on the page where you pick it up. That doesn't really matter though. Thanks so much Killa! This is going to make things so much easier ^_^