Howdy, Stranger!

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

Is there a way to make a button hidden until a user clicks something?

I need to make sure that a user can't progress until they've selected an option from the checkbox
To make my purpose more clear, when the user enters the "Shop", they can select an item to buy using checkboxes that subtract it from their money on hand, and the button takes them to a page that determines if they have enough money to confirm the purchase, and this all works fine

Until they go back to the shop. Once they go back in, if they fail to select an option, and hit the purchase button, the function will try to subtract the price of the item from their money again, and, if they have insufficient funds, the item will be set as false and taken out of their inventory

This is a sample item as it appears in the store
<<if $Knife is "false">>\
<<checkbox "$Knife" "false" "true">> Knife $50
<<else>>\
<<endif>>\

then the confirm purchase passage
<<if $Knife is "true">>\
<<set $playMoney -= 50>>\
<<if $playMoney < 0>>\
You don't have enough for the Knife.
<<set $Knife = "false">>\
<<set $playMoney += 50>>\
<<else>>\
You have purchased the Knife
<<endif>>\
<<endif>>\

Any help would be much appreciated, as i have been pulling my hair out about this.
Thanks

Comments

  • With the way you have your shop setup, you're going to need two variables. Also, you should stop treating boolean values as strings. Finally, the logic in your second section was daft. Rather than purchasing an item and then undoing that if the player has insufficient funds, simply check their money first and only go ahead with the purchase if they have sufficient funds.

    Try something like the following.

    Setup:
    <<set $BuyKnife = false>>
    <<set $Knife = false>>
    
    Store:
    <<if not $Knife>>\
    <<checkbox "$BuyKnife" false true>> Knife $50
    <</if>>\
    
    Purchase:
    <<if $BuyKnife>>\
    <<if $playMoney < 50>>\
    You don't have enough for the Knife.
    <<else>>\
    <<set $BuyKnife = false>>\
    <<set $Knife = true>>\
    <<set $playMoney -= 50>>\
    You have purchased the Knife.
    <</if>>\
    <</if>>\
    
  • With the way you have your shop setup, you're going to need two variables. Also, you should stop treating boolean values as strings. Finally, the logic in your second section was daft. Rather than purchasing an item and then undoing that if the player has insufficient funds, simply check their money first and only go ahead with the purchase if they have sufficient funds.

    Try something like the following.

    Setup:
    <<set $BuyKnife = false>>
    <<set $Knife = false>>
    
    Store:
    <<if not $Knife>>\
    <<checkbox "$BuyKnife" false true>> Knife $50
    <</if>>\
    
    Purchase:
    <<if $BuyKnife>>\
    <<if $playMoney < 50>>\
    You don't have enough for the Knife.
    <<else>>\
    <<set $BuyKnife = false>>\
    <<set $Knife = true>>\
    <<set $playMoney -= 50>>\
    You have purchased the Knife.
    <</if>>\
    <</if>>\
    

    Thanks, this is working a lot better, and as for the strings instead of booleans, every time i had tried to use booleans prior to this, they seemed to mess up, so i had just been going with strings.
Sign In or Register to comment.