What does "*temp comma" do?

I have seen it in several ChoiceScript stat screens but I can’t figure out what it does and why I would need it. Any explanation? :slight_smile:

1 Like

@SwedishDude, *temp comma is the declaration of a temporary variable with the name “comma”. Why the variable is called “comma” is another question. Without looking at the code you’re looking at, it’s impossible to say why the programmer chose to call the variable “comma”, but I could see it being used in a loop with a *setref command to construct a string of comma-separated, similarly-named items, where the “comma” variable would be initially empty (so you don’t have a leading comma), and then set to an actual comma at the end of the first pass through the loop, so that all the other items in the string are preceded by a comma. Does that make any sense to you?

I’m trying to build an inventory based on this: http://www.choiceofgames.com/forum/discussion/comment/6553/#Comment_6553

And I can’t figure out why temp needs to be there.

And no, that didn’t make much sense to me sorry :frowning:

“comma” is a boolean for a weapon (true/false), if your making an inventory system, do *create weapon, then *set weapon “None”, then add it to stats_choicescript.txt as text Weapon, this is somewhat easier than *temp.

Ah, okay, ty!

@SwedishDude, okay, I see what they are doing in the code you referenced. They are using the “comma” variable to know when to insert a comma into their inventory list. You don’t want a comma before the first item in your list, so they have the variable set to false initially. When one of the items is actually placed in the list, the variable is set to true, so they know that each remaining item added to the list will need to have a comma inserted before it.

It’s all about presentation. In the example you referenced, suppose the character had a Pistol and a Rifle, but no Revolver. By using the “comma” variable, you can make the inventory string look like this:

Pistol, Rifle

If you didn’t use the “comma” variable, the inventory string would look like this:

, Pistol, Rifle

The method @Daisuke proposes is easier and more flexible if you don’t have lots of items to be displayed in your inventory. If your character is only allowed to carry one weapon, then you can have a variable called “weapon”, assign the name of the carried weapon to that variable, and then include that variable in your stats_choicescript.txt file. This avoids the use of the temporary “comma” variable.

If your character is allowed to carry more than one weapon, you can still avoid the “comma” variable by doing something similar to what @Daisuke proposed. Let’s say the character will be able to find and carry one each of Revolver, Pistol, and Rifle. You can have a “revolver_status” variable, a “pistol_status” variable, and a “rifle_status” variable. Then you can assign to each one of these the value None or Carried. For an example, suppose your character is carrying a pistol and a rifle but not a revolver, as in the previous example. Then your stats display instead of looking like Pistol, Rifle could look like this:

Revolver: None
Pistol: Carried
Rifle: Carried

If you have the concept in your game of a weapon being “equipped”, then you could add Equipped as another possible weapon status value. In the example above, if the character had the Rifle equipped, your stats display could look like this:

Revolver: None
Pistol: Carried
Rifle: Equipped

Having separate weapon status variables for each weapon gives you a lot of flexibility. You can add other weapon status values, such as Damaged or Jammed. But perhaps I’ve already gone too far afield with this discussion. Good luck with what you decide to do.

You could also do:

*set rifle “equiped” = false
and when you pick it up…
*set rifle “taken” = true
make false = “not equiped”
and in the *stat_chart:

*choice
-selectable_if rifle = taken #Equip Rifle
–*set gun “Rifle”

Eposic: Aha, so it was only for the visual, I see. Ty for explaining it!

Daisuke: so, I can make a choice inside the choicescrip_stats file? Didn’t know that :stuck_out_tongue:

Being able to do *choice in the stats file is said to be removed in a future update, of course, you could just not update your choicescript.

Or if enough of us make stats files with choices in them, they might change their minds on that… :slight_smile:

Rally the people, we want *choice in the stats. :wink:

Daisuke: Well, another thing that comes to my mind is: what is the difference between the *create command and *temp command? Choiceofgames.com doesn’t really explain this very well…

*temp coresponds to a temporary boolean, for instance, the game starts with *temp beta = false, but upon doing something, it can change to true, allowing you to go down paths that are “selectable_if (beta = true)”.

You can also do this in the mygame.js file.

while *create does?

*create creates a varible, same effect as adding a stat name in the mygame.js.

ah okay, thanks (Still wonder why Choiceofgames only barely mention *create but explains a lot about *temp…).

@SwedishDude, it’s important to note that *temp variables go away when you go to another scene, whereas *create variables, or those installed in the mygame.js file, stick around and can be accessed from any scene.

I think CoG wants you to use mygame.js instead of *create.

@eposic
Which is weird when you note all their games use *create and their mygame.js files are blank.
Also, forgot to note that fact, thanks Eposic.

thanks eposic, that explained a lot.

And thank you too Daisuke!

Now then, back to scripting!