Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Altering state of inventory after item use?

edited November 2015 in Help! with 2.0
I'm sorry for all the questions. I'm trying, I really am. I've just spent the last hour or so trying to figure this out for myself, but I just get get it to work

I want an item in my inventory to change state after use.

The player finds a bottle of clear liquid on a dead body, so it goes into the inventory as 'Bottle of clear liquid'. A few passage later they get the chance to try the liquid. It turns out to be just water, so I want the inventory for this item to then change to 'Bottle of water', since the player now knows what it is.

I've tried adding <<set $ClearLiquid to false>> after the player drinks it, and adding <<if $hasDrink>>A bottle of water>> to the inventory passage, but it doesn't do anything.

Here's the original passage where the player drinks the water, without my attempts to make it work:
<<if not $Drink>>\
<<set $Drink to true>>\
Backpack secured - no real weight to it yet.

Steady pace along the long empty road now. Making good time, but the darkness is fading rapidly as the sun makes for the horizon.

Thirst developin. Dry lips.

[[Stay on the road]]
[[Head for the forest and make camp for the night->Camp]]
[[Drink clear liquid|Push on]]
<<else>>Tasting tentatively. A drop to the lips. <em>It's water!</em>

Drinking furiously now, a quarter of the contents gone in a few gulps.

[[Stay on the road]]
[[Head for the forest and make camp for the night->Camp]]<</if>>

Comments

  • Done it!!

    After the 'else' in the code above, I set $hasClearLiquid to false, and $hasDrink to true.

    The only thing now is the gap in the inventory it leaves, after ClearLiquid is removed. Is there a way to get 'A Bottle of water' to replace the slot where 'A bottle of clear liquid' was, instead of it coming underneath and leaving a gap above?
  • Jud_Casper wrote: »
    The only thing now is the gap in the inventory it leaves, after ClearLiquid is removed. Is there a way to get 'A Bottle of water' to replace the slot where 'A bottle of clear liquid' was, instead of it coming underneath and leaving a gap above?
    Probably. It's hard to be sure, since you haven't shown that code.

    Assuming that you're doing something like the following:
    <<if $hasClearLiquid>>Bottle of clear liquid.<</if>>
    <<if $hasDrink>>Bottle of water.<</if>>
    
    And also assuming that having both at the same time isn't allowed, then you could do this:
    <<if $hasClearLiquid>>Bottle of clear liquid.<<elseif $hasDrink>>Bottle of water.<</if>>
    

    Also. I note that you're using both the pipe ("|") and right arrow ("->") separators in your wiki links. Kind of odd that. I'd suggest sticking to whichever you prefer (or just picking one, if you have no preference). There's no technical harm in mixing them, it's just kind of odd to see someone do that.
  • edited November 2015
    Thanks very much, TME. I'm not sure why I started mixing the link targets, to be perfectly honest. I'll stick with -> as that's what I started out with.

    I'm also going to go and do the else option to see if it removes the blank line. I shall report back.

    [edit] Done. Works perfectly! Thank you.
Sign In or Register to comment.