Page 1 of 1

Virtual Variables

Posted: Wed Jan 31, 2018 23:23
by Lobby
Virtual variables are variables that are used by the game internally and are exposed for use in fun. See here to learn more about variables in general. Unlike user defined variables virtual variables don't have to be read- and writeable at the same time. It's not defined what happens if you try to read a non readable virtual variable. If you try to set a non-writeable virtual variable nothing will happen.

Virtual variables (constants are written in CAPITAL LETTERS):
Show
roadAutoJoin
0 or 1
Determines whether placed road connects automatically to neighboring roads (game wide). You should set it back to it's original value after using it.
Show
winter
0, 1 or 2
Can be used to control winter (game wide).
0 = auto
1 = on
2 = off
Show
weatherTime
integer
Can be used to control weather. See here for more information.
Show
weatherFog
0 or 1
Can be used to enable (1) or disable fog (0).
Show
weatherLocked
0 or 1
Can be use to lock (1) or unlock (0) weather timer.
Show
WEATHER_NORMAL
integer constant 0
New cities will start with this weather time.
Show
WEATHER_SUNNY
integer constant 290373
This weather time will lead to sunny weather.
Show
WEATHER_RAIN
integer constant 849711
This weather time will lead to rainy weather.
Show
WEATHER_LIGHTNING
integer constant 622697
This weather time will lead to lightning.
Show
day
integer
Absolute day of the current date.
Show
cityRotation
0, 1, 2, 3
Rotation of the city. Default rotation is 0. Higher numbers mean 90 degree clock-wise rotation of the map.
Show
buildingCount
integer, only readable
Number of buildings in the city.
Show
roadCount
integer, only readable
Number of roads in the city.
Show
wireCount
integer, only readable
Number of wires in the city.
Show
pipeCount
integer, only readable
Number of pipes in the city.
Show
disaster
0 or 1
Is 1 if a disaster is currently active.
Show
music
0 or 1
Current setting for background music (on=1 or off=0).
Show
isDeveloper
0 or 1, only readable
Is 1 iff running in a developer build.
Show
demand_XY
integer, only readable
Demand for res/com/ind for specific level.
Possible values for X: res, com, ind
Possible values for Y: 0, 1, 2
For example to read demand for level II commerical you would use variable demand_com1. demand_XY contains the offset that is given by demand_XY_offset.
Show
demand_XY_offset
integer
Modifyable offset for demand. For XY see explanation of demand_XY.

Re: Virtual Variables

Posted: Wed Jan 31, 2018 23:30
by CommanderABab
Which ones of those are writeable?

Re: Virtual Variables

Posted: Wed Jan 31, 2018 23:32
by Lobby
Any except those which are written in capital letters :)

Re: Virtual Variables

Posted: Sat Mar 10, 2018 15:27
by Lobby
Added variables to count buildings, roads, wires and pipes :mine

Re: Virtual Variables

Posted: Mon Apr 30, 2018 18:23
by JustAnyone
Since version 471 a new variable was added called "gameSpeed"
It sets the speed in your city.
0 - pause
1 - slow
2 - normal
3 - fast
4 - ultra fast

Re: Virtual Variables

Posted: Wed May 23, 2018 14:05
by cesareborgia94
What is the name of virtual variable for setting music in the recent update 1.478?
Can anyone help elaborate?
:bt

Re: Virtual Variables

Posted: Wed Jul 04, 2018 19:13
by cesareborgia94
@Lobby
It may be too late to ask this,
but what does virtual variable involving "music" do in the game?

Also I don't mean to ask too much but how does a json code is used involving a virtual variable using music?

Thank you.

Re: Virtual Variables

Posted: Wed Jul 04, 2018 19:51
by Lobby
You can use the virtual variable "music" to get/set the current setting for music. E.g. if you want to turn background music off you could execute:

Code: Select all

"actions":[{"type":"set","id":"music","code":"0"}]
By the way in recent versions you could write instead:

Code: Select all

"actions":["music=0"]
It means exactly the same thing.

Re: Virtual Variables

Posted: Wed Jul 04, 2018 20:18
by cesareborgia94
Thank you Lobby for explaining.

I thought the music action is supposed to allow a plugin to pick a music from a library, but I guess I was wrong about that :/
Now I understand :)