Trouble Using *Set


#1

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


The Beginners Guide to ChoiceScript
#2

*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]


#3

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


#4

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

#5

Is that all in the startup?


#6

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


#7

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


#8
  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

#9

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


#10

changed it, still nothing


#11

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.


#12

the stats are fine but nothing happens for example

foo: 50%

set foo + 5

still 50%


#13

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


#14

tried that too m8 still no change


#15

I always use *set foo +5

(No space between + and number)


#16

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


#17

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


#18

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.


#19
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

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

Change it to that.