Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

Manipulating number of item uses

10 years ago

Hi there everyone, I have a question. In my story I have a potion which you can use to restore your health, however it has a limited number of uses. I want the character to still have the item in their inventory but be unable to use it once they you have ran out of the number of uses. I also want them to be able to refill the potion, thus resetting the number of uses for the item. Does anyone know if this is possible, and if so, how to do it?

Manipulating number of item uses

10 years ago

Hi, to do this you need to keep track of uses yourself with a Variable that you create. Then have a page for when the variable uses is zero.

When they refill the potion, reset your variable.

Manipulating number of item uses

10 years ago

But how could I prevent users from using the item after the amount of uses has expired?

Manipulating number of item uses

10 years ago

That is what your "This potion is empty" page is for  =)

Manipulating number of item uses

10 years ago

There's already a system variable for number of uses of an item.

$ITEMUSED1

Each item has a number beside it (which is what the number beside 'used' correlates with). Each time you use the item, the variable gets 1 added to it (so if you used it twice in the game, it would be at 2).

You'd have to use the item script of that item, to do a check when you use it, and if the $ITEMUSED1 value is equal to the limit, change the destination they go to, to some default "there is no more uses".

Unfortunately, there's no "disabling" an item or something.

Of course, when you reach the limit you could always replace the item with an item that looks the same, but has no links to anywhere (and it's description says it can't be used anymore). Then, when they "replenish" the item, switch it back to the old item (and reset $ITEMUSED1 to 0).

Manipulating number of item uses

10 years ago

That should work!

Displaying a variable in Global Scripts

10 years ago

Ignore

Displaying Variable in Global Scripts

10 years ago

I have a new problem, In my game I want the player to be able to see the amount of gold they have on every page. But instead of displaying the variable on every page I am using a global script instead. It accepts the script but when I view any of the pages in the story it shows Gold: %%GOLD%% at the bottom of the page.

How can I get it to display Gold: (amount of gold) instead of Gold: %%GOLD%%?

PS: The script I used was this:

$PAGETEXT := $PAGETEXT + "<br><br>"
$PAGETEXT := $PAGETEXT + "<b>Gold:</b> %%GOLD%%"

Displaying Variable in Global Scripts

10 years ago

$PAGETEXT := $PAGETEXT + "<b>Gold: </b>" + %GOLD

Try that.

Displaying Variable in Global Scripts

10 years ago

That works, thanks.

Displaying Variable in Global Scripts

10 years ago

No problem.

Displaying Variable in Global Scripts

10 years ago

%GOLD for Scripts and %%GOLD%% for directly on a page in the text.