Virtual Variables

Any information about the fun attribute is given here.

Moderator: Plugin Moderators

User avatar
Lobby
Developer
Posts: 3713
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Virtual Variables

#1

Post 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
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.
Show
gameSpeed
Sets the speed in your city.
0 - pause
1 - slow
2 - normal
3 - fast
4 - ultra fast
Show
gameMode
Returns a numerical representation of the current game mode
0 - sandbox
1 - easy
2 - medium
3 - hard
4 - free
Last edited by Bearbear76 on 06 Oct 2019, 10:37, edited 2 times in total.

User avatar
CommanderABab
AB
Posts: 11185
Joined: 07 Jun 2016, 21:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Virtual Variables

#2

Post by CommanderABab »

Which ones of those are writeable?

User avatar
Lobby
Developer
Posts: 3713
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Re: Virtual Variables

#3

Post by Lobby »

Any except those which are written in capital letters :)

User avatar
Lobby
Developer
Posts: 3713
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Re: Virtual Variables

#4

Post by Lobby »

Added variables to count buildings, roads, wires and pipes :mine

User avatar
JustAnyone
Developer
Posts: 3534
Joined: 23 Jul 2017, 12:45
Location: Easter Island
Plugins: Showcase Store

Platform

Re: Virtual Variables

#5

Post 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

User avatar
cesareborgia94

Re: Virtual Variables

#6

Post by cesareborgia94 »

What is the name of virtual variable for setting music in the recent update 1.478?
Can anyone help elaborate?
:bt

User avatar
cesareborgia94

Re: Virtual Variables

#7

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

User avatar
Lobby
Developer
Posts: 3713
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Re: Virtual Variables

#8

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

User avatar
cesareborgia94

Re: Virtual Variables

#9

Post 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 :)

User avatar
dc5
Townsman
Posts: 96
Joined: 08 Feb 2021, 01:43

Re: Virtual Variables

#10

Post by dc5 »

How do I enter when changing demand?

Post Reply Previous topicNext topic

Return to “Fun attribute”