#author("2022-12-27T01:15:53+00:00","default:admin","admin")
*What are Variables? [#f711fcd9]
Variables are like boxes into which data can be put.
Numbers/values, text, switches, etc. can be stored and used at various points in the game.
''Putting data into variables is called "assignment".''

 Example:
 If you assign the value "1000" to the variable "money", the variable "money" always has the meaning of the value "1000" in the game.
 The variables themselves are boxes, so the values inside can be added or subtracted.
 If we add another value "500" to this variable "money", "money" has the meaning of the value "1500".
 On the other hand, when the variable "money" is assigned the value "500," the content of the variable is overwritten and "money" becomes the meaning of the value "500".

By utilizing variables, a variety of expressions are possible in the game.

''The initial value of all variables is 0.''

#Contents

**Variable Types [#d274bd21]
Bakin provides the following types of variables.
The following describes the values/strings/local values/arrays/cross-save shared and event switches.

--[About the Values You Can Put into Variables]
Although named "values" and "strings," all variables can be assigned either values or strings.
However, it is recommended that you use them appropriately so that you can proceed with the game creation process in an easy-to-understand manner.

***Values [#odaebc83]
It is basically the most common variable used to store numeric values.
These variables can be referenced from anywhere within a single game.

''<Example of Use>''

- An event in which the player asks the villagers about a certain rumor, and after a certain number of times, is summoned by the village chief to tell him/her about it.
 This is accomplished by recording the number of times the villagers are asked in a value variable.
- Count the number of remaining actions in the escape game, which decreases each time an object is examined, and when it reaches 0, the game is over.
 This is accomplished by recording the number of times things are examined in a value variable.
- Score attack with time limit / Time attack until a certain score is obtained
 The current time and play time at the start are stored in value variables, and the difference is calculated at the end of the session.

 * Although a similar event can be created with a local variable, using this value variable makes it possible to refer to the value managed by the variable from other events.

***Strings [#eb9721d8]
It is basically variables that are used to store text.
These variables can be referenced from anywhere within a single game.

''<Example of Use>''
- Doors and treasure chests that can only be opened with a password
 This is accomplished by putting the correct answer and the password to be entered into string variables, respectively, and comparing them.
- Conversational text calling out the name of the pet waiting at home
 The name of the pet given by entering text is recorded in a string variable and displayed as conversational text.
- Seeds and seedlings that can only be used if the terrain was a field
 This is accomplished by recording the terrain resource name in a string variable with the command script "Obtain Terrain Information" and comparing the string variable to which "field" is assigned.
 Use the ability to call common events from seed and seedling items.

***Local Values [#n0d22cd5]
These variables work the same way as values, but they can be referenced from "only in the event in which this variable is specified".
By keeping variables that need to be used only within a single event as local variables, the list of variables can be prevented from growing.

''<Example of Use>''
- Leave the lid of the opened treasure chest open.
- People whose friendship level changes through conversation and gifts, and who give useful items and important information when it rises to a certain level.
- Rocks that can be broken if the level or attack power is above a certain level.
- Merchants with different products depending on the day of the week.
- Fortune-telling slips and betting with random numbers

 These can be realized with value variables, but can be handled with local value variables.


***Array Variables [#ka311613]
These variables can manage multiple variables at once.
Array variables allow multiple variables to be managed together in a single variable.
These variables can be referenced from anywhere within a single game.

 Think of an array as a row of smaller boxes inside a larger box.
 The name of the large box is the name of the array variable.
 When referring to the contents of a small box in an array variable, the value "pointer" is used to specify which box to refer to.
 Example: In the array variable "price of weapon", "pointer = 1" contains "price of sword" and "pointer = 2" contains "price of bow".

''<Example of Use>''
- Shopping list for a mission to run an errand
 Record the items that need to be bought in a pointer to an array variable.
- List of management game products and their remaining numbers
 The name of product A is recorded at pointer 0, the remaining number of product A at pointer 1, the name of product B at pointer 2, and so on.	
- Naming List
The name is chosen and named by placing name candidates in an array variable and randomly (or arbitrarily) selecting a pointer to one of them.
With two array variables, two or more phrases can be combined, as in two names.
 To put a string into an array variable, use the command script "Assign to String Variable".
 However, if you want to display the contents of an array variable with a message, you must first assign it to a string variable and then display that string variable.
 

***Cross-Save Shared Variables [#h8ca6c8a]
These variables have the widest influence across saves and can be referenced from anywhere in the game.
---If the contents of these variables are overwritten in a test play, the information is retained even after the test play is terminated.
---Use Test Play > Options > Debug Window to rewrite the contents of variables as needed.

''<Example of Use>''
- Change the contents of events that occur in pre-game and post-game clear play.
- In a multi-ending game, record only the endings that the player has already seen and display them (game gallery-like usage).


***Event Switches [#lc038bfb]
Event switches that can be manipulated by command scripts are also a type of variable.

---Any type of variable can be treated as an event switch.
The range in which switches can be referenced is based on the type of variable used as the switch.
---If the value in the variable is 0, it is treated as off, and if it is 1 ( other than 0, strings are invalid), it is treated as on.
---When the event switch is turned off, the contents of the variable are rewritten to 0.

''<Example of Use>''
- Changing the reactions of other NPCs based on whether or not they have had conversations with the key cast members of the story
 After speaking with the key cast members, turn on event switches. Prepare the NPCs' reactions when the event switches are turned on as events.


Front page   Edit Diff History Attach Copy Rename Reload   New Page list Search Recent changes   Help   RSS of recent changes