What does "*temp comma" do?


#1

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:


#2

@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?


#3

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:


#4

“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.


#5

Ah, okay, ty!


#6

@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.


#7

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”


#8

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:


#9

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.


#10

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


#11

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


#12

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…


#13

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


#14

while *create does?


#15

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


#16

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


#17

@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.


#18

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


#19

@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.


#20

thanks eposic, that explained a lot.

And thank you too Daisuke!

Now then, back to scripting!