Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

Adding items on click

18 years ago
Is there any with scripting to add an item, when, say, someone clicks on a link and is taken to another page? The uses for this would be varied and cause making separate pick up pages irrelevant. Just wondering if there's a secret $ADDITEM := "Glowing Blue Sword" or something.

Adding items on click

18 years ago

Yes there is. First find the item id number for the item that you want to be "picked up" through a link. Put this in the link script that would make the user have the item after clicking the link:

$ITEMSTATE## := 1

replace the "##" with the item id number. The ":= 1" means it will add the item to the item's inventory, if you were to put:

$ITEMSTATE## := 0

Again, replacing ## with the id number, it will remove the item from the inventory.

I believe there is also, $ITEMUSE or $ITEMUSES, but that you will have to check up on, and they are pretty self-explanatory, they hold the item's number of uses.

Adding items on click

18 years ago

You should be able to do this, there are script commands that deal with using items. Solostrike's Intermediate Article deals with this a bit:

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

$ITEMSTATE is a script command variable, that holds the state of an item. While in Advanced mode, making sure you Edit Features for you game, and have scripting and variables set to Advanced.

This then puts a system number next to your items on the items page for your story. To use the $ITEMSTATE command, you just add the number of the item onto the end. Ie, $ITEMSTATE5 or $ITEMSTATE22

If an item has a state of '0' it means that the item is not in the player's inventory, but is at its starting page.

If an item has a state of '1' it means that the item is in the player's inventory.

You can simply write a script command, saying: $ITEMSTATE5 := 1 and you will be changing its state, and putting it in the player's inventory. You can also use $ITEMSTATE5 := 0 to remove an item from their inventory. So, yes, you could do this by link instead of having the player go to a page and click on an item picture there.

However, at the time of this post, this command does not work when placed in links. I've tried it numerous times, and it comes up with a major error. I keep meaning to post it as a bug, so I'll go and do that right now. Once it's fixed, you can just do what I said and it should work.

Adding items on click

18 years ago
Interestingly, this DOES work in a page script. I have no errors. So useful! Too bad I'm not going back and changing everything. The way I was doing it before is, if you found an item on multiple pages, I had to make separate items and separate code for every item later in the story. Now, I can just put it in there. Hehe. Wish I'd realized this earlier. Oh well.

Adding items on click

18 years ago
Actually, it works on page links, but that's not why, I suspect. Setting ITEMSTATE to 0 causes an error regardless of where you put it. So, in essence, you can add items, but you cannot take them away.

Adding items on click

18 years ago
Damn, I could've actually helped someone with scripting (never done that before). Solo and Paul beat me to it.

Adding items on click

18 years ago
ahha october you will get your chance :P soon...

Adding items on click

18 years ago
Ah, strong. I just re-read the article and it makes perfect sense. Interesting that I didn't remember that since I proofread that article. I see what you mean about it not working, though. Thanks for the quick responses guys.