Trouble Using *Set

create and set are beginner right, well create doesn’t do anything, and set doesn’t help either i tried to follow your guide but all i keep getting is errors and the stats don’t change at all depending on a + or - but doesn’t matter, no change no matter what i try

*create doesn’t do anything obviously visible during runtime, but it tells ChoiceScript to make a variable which you can then manipulate later using *set. If you don’t create the variable, you can’t set it and CS will throw an error if you try. *create makes the variable available to every scene file in the game.

*temp creates a temporary variable which does not carry to other scenes, but can be used in the same scene for something like a quick dice throw.

*create health 30

*set health + 10

Your health is ${health}.

That should output:

Your health is 40.

Remember you can ONLY *create variables at the top of the startup.txt scene. You can create *temp variable in any scene, but it won’t carry over to any other scene.

So every global variable in the game needs to go at the beginning of startup.txt, no matter where it’s used in the game

Example Startup:

[code]*title The Game of Awesome
*author My Own Self

*scenes
firstscene
secondscene
thirdscene
finale

*create health 20
*create stamina 20
*create likes_broccoli false
*create pc_name “Thor”[/code]

Have you looked at other game’s code? It really helps.

I am using create and set, this is what i wrote

*create foo 20

Scene1: your name is Jack Maxson, you are 25 and have been living with your SO for about a year, you have been dating for two, you awake with morning wood, how embarrassing, you noticed that your
girlfriend Zoe is taking a shower, Zoe is slim and  beautiful with long blonde hair and sparkling blue eyes, those eyes drew you in when you first met
*fake_choice
 #Join Zoe
*set foo + 5

Is that all in the startup?

no, scene 1 is a new scene, i know create can only be used in startup

What is the error you’re getting? Like, a specific error or it just isn’t working?

  1. What is the actual error you’re seeing when you test?
  2. I put <pre> in the code you presented where I guess your code begins/ends.
  3. Your indentation is wrong in the above is incorrect, it should be:
*choice
    #Join Zoe
        *set foo + 5
1 Like

I not getting an errors, just nothing happens, moves on to the next scene no problem

changed it, still nothing

Wait, so you have nothing that actually displays the stats? Try this instead:

*create foo 20
Foo is: ${foo}
*choice
    #Make Choice
        *set foo + 5
        Foo is: ${foo}
        *finish

Considering you commented originally on my guide, I’ll mention this is covered as part of the walk through in it.

the stats are fine but nothing happens for example

foo: 50%

set foo + 5

still 50%

This is grasping at straws, but try it without the spaces.
*set foo+5

tried that too m8 still no change

I always use *set foo +5

(No space between + and number)

Works for me. I just copy-pasted @/Reaperoa’s code

Could you take a screenshot of the code and post it here?

Okay, post the entirety of your code that isn’t working (/take a screenshot) without editing, because the above code I put up works fine in the IDE, so I have no idea what’s going on in your case.

stats:
*label screen
*choice
    #Relationships.
        *stat_chart
            percent 20 foo
         *goto screen


startup:
*create foo 20
Foo is: ${foo}
*page_break


Scene1:
*choice
    #Join Zoe
*set foo+5
*label screen
*choice
    #Relationships.
        *stat_chart
            percent foo
         *goto screen

Change it to that.

1 Like