Howdy, Stranger!

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

random and fixed variable

Hi,

So I want the player see randomly the sentence first, and when he has seen it, always see it.
The fact is : it's always random.

Here is the code :
<<if $Observant>=random(100) || $Votpan==1>>You see an voting panel][$Votpan to1<</if>>

$Observant is fix between 0 and 100, $Votpan is set as 0 in the storyinit


BTW : little question here : https://twinery.org/forum/discussion/comment/20400/#Comment_20400 (re sorry for the dig up)

Sorry for my english, that's not my native language.

Thx for the answers.

Comments

  • Alianna wrote: »
    So I want the player see randomly the sentence first, and when he has seen it, always see it.
    The fact is : it's always random.

    Here is the code :
    <<if $Observant>=random(100) || $Votpan==1>>You see an voting panel][$Votpan to1<</if>>

    $Observant is fix between 0 and 100, $Votpan is set as 0 in the storyinit
    The are two possible issues I can see in what you've shown and I have a couple of suggestions.

    First the issues:
    1. Another casing issue. It's StoryInit, not storyinit.
    2. In the setter link, you have $Votpan to1, which should be $Votpan to 1—i.e. there must be a space between the operator and the value.
    I don't know if either or both of those are transcription errors, however, if they're in your actual code like that, then they need to be corrected.

    Now the suggestions:
    • Do not use numbers in place of boolean values. If $Votpan is only acting as a flag, then use actual boolean true and false.
    • In the conditional, put the $Votpan test before the random test, so that when $Votpan is true the random test is skipped entirely.

    For example, do the following within your StoryInit special passage:
    <<set $Votpan to false>>
    

    And the rest of the code:
    <<if $Votpan or $Observant >= random(100)>>You see a [[voting panel][$Votpan to true]]<</if>>
    


    A final observation. Even after initially noticing the voting panel, if the player doesn't click the link, then $Votpan will not be set to true. You may instead wish to separate the two actions, so when the player notices the panel it stays noticed whether they immediately click on it or not. For example:
    <<if not $Votpan and $Observant >= random(100)>><<set $Votpan to true>><</if>>
    \<<if $Votpan>>You see a [[voting panel]]<</if>>
    
  • Ok,

    1 : StoryInit is ok. (just me who write it wrong, I'll pay more attention next time)
    2 : I correct the error : same, always random.

    Suggestions :

    Your code is clearly more optimize.
    But always random TT, even with $Votpan puts first. (I assume that $Votpan without true means it's true by default).

    I don't really understand what's going wrong with this code.

    I continue to work on it.
    Thx for your answer.
  • Two questions. How are you setting $Observant? Are you using the <<back>> macro?
  • I set $observant like that :
    <<set $Observant=60>>

    And yes I use the <<back>> macro. Is that reseting the previous action ?

    Thx for your time.
  • Please use the code tag when posting code—it's C on the editor bar.


    The <<back>> macro undoes existing history, yes. Using it is undoing the change to $Votpan made by the setter link.

    If you simply want an immediate return from the voting panel passage to the previous passage, you could use the <<return>> macro—from its documentation: Functionally identical to <<back>>, save that it pushes forward to the destination state/passage, rather than popping back (i.e. it creates new history, rather than undoing existing history).
  • edited January 2017
    Ok noted for C.

    As well for <<return>>.

    I thank you a lot.
    I check answered.
Sign In or Register to comment.