Howdy, Stranger!

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

[Sugercube 2.x] Choices that exist/don't exist depending on variable values?

The idea I have is player choices get tracked. So if someone keeps taking the 'relatively' nice options they stop getting the hardliner options so often or other options that wouldn't be avalible for someone taking the closed fist path, and likewise those that want to be mean get options others don't.

Just as examples mind you.

I'm guessing it's not all that hard, just I don't know what I'm doing.

Comments

  • You could set up a variable at the start of the game to keep track of the player's "niceness", and put all links that could be affected by it in <<if>> macros. For example:
    StoryInit passage
    <<set $niceness to 0>>
    
    Whenever niceness changes
    <<set $niceness to it + $change>> (note that $change can be positive or negative)
    
    Making options visible or not
    <<if $niceness > $someAmount>>[[Link to nice passage]]<</if>>
    <<if $niceness < $someAmount>>[[Link to mean passage]]<</if>>
    
  • numberQ wrote: »
    Whenever niceness changes
    <<set $niceness to it + $change>> (note that $change can be positive or negative)
    
    That code is incorrect. It should be something like the following:
    <<set $niceness += $change>>
    
    Or, if you wanted to be verbose about it:
    <<set $niceness to $niceness + $change>>
    
  • edited October 2015
    So to have more than one value I could just have more than one variable?

    I'm guessing if a single choice changes more than one value it'd be something like

    <<set $paragon +=(number), set $renegade -=(number)>>?

    I want some choices to have more weight than a flat 'you chose so the variable goes up one tic' and others to offer points in different areas, since it might be a 'good' thing to do, but it wasn't necessarily 'nice' so you still get renegade points, or even a not nice choice is still the 'right' thing to do, like you pistol whipping a guy who kept his autistic brother hooked up to a machine or headbutting somebody to show that you aren't going to put up with their lip since that is the culturally accepted thing to do by their standards.
  • edited October 2015
    The correct way to assign two (or more) variables within a single set macro is to place a semi-colon between each of theassignment expressions:
    <<set $paragon to 0; $renegade to 0>>
    
    <<set $paragon += 5; $renegade -= 2>>
    
  • numberQ wrote: »
    Whenever niceness changes
    <<set $niceness to it + $change>> (note that $change can be positive or negative)
    
    That code is incorrect. It should be something like the following:
    <<set $niceness += $change>>
    
    Or, if you wanted to be verbose about it:
    <<set $niceness to $niceness + $change>>
    

    You're right, I was mixing up my Sugarcube and Harlowe. My bad. :P
  • To clarify a bit, you may either use the semi-colon or the comma to separate individual sub-expressions within a <<set>> (the semantics are different, but the results are the same). For example, all of the following are legal:
    <<set $paragon to 0; $renegade to 0>>
    
    <<set $paragon to 0, $renegade to 0>>
    
    <<set
    	$paragon  to 0;
    	$renegade to 0
    >>
    
    <<set
    	$paragon  to 0,
    	$renegade to 0
    >>
    
Sign In or Register to comment.