Page 1 of 2
Condition Index
Posted: Thu Oct 05, 2017 10:52
by Lobby
A generic condition looks like:
To check for such a condition you would use the code
Code: Select all
"condition":{"type":"condition name",...},
Possible additional attribute for conditions are:
id, x, y, z, min, max, frame, level, inner, invert, code
Checks for a building. If id and/or frame is provided they will checked on that building. The result is true iff there's a building that meets the given id/frame.
Checks if the building given by ID is buildable by user at given x/y.
A description will follow.
Is true if a wire with given ID is built at given x/y. If the ID is not defined, game will check for any building with wire type.
A description will follow.
Checks whether there's a pipe (if provided: of the given id) at x, y.
Checks whether there's a road decoration (if provided: of the given id) at x, y. V.490+
Checks whether there's a tree (if provided, of the given id) at x, y.
Is only true if all inner conditions are true (or if there are no inner conditions).
Is true if at least one inner condition is true.
Is always true. If you don't provide any condition this one will be the default one
Counts the number of true inner conditions. The number x is hen checked against min + z <= x <= max + z.
Applies the inner condition (only one) on all 8 neighboring tiles. The number of fulfilled ones x is then checked against min + z <= x <= max + z.
Checks whether the frame of the building at x, y fulfilled min + z <= frame <= max + z.
Checks whether the tile at x, y is land (if specified, of the given id).
Checks whether the tile at x, y is water (if specified, of the given id).
Evaluates the road usage at the current position and checks whether it's in the provided range. Values range from 0 to 100.
Checks whether the zone - given by id - is set at the current position.
Counts how often the building - given by id - is built in the current city.
Checks whether the value of an evaluated code is in a certain range. The string provided in "code" is evaluated to a value. The condition is true iff
is fullfilled. Default values for min, max and z are 0. So you usually only provide min and max or z. If you only provide z the condition basically is
Example:
Code: Select all
"condition":{"type":"value","code":"day/360"}
This condition is only fullfilled if date is within first year.
See
https://theotown.com/forum/viewtopic.php?f=81&t=5736 and
https://theotown.com/forum/viewtopic.php?f=81&t=5959 for more information.
Returns true if the building at the current position is burning.
Checks whether the upgrade - given by id - is applied to the building at the current position.
Is true if the current game day is the given number. Possible values are "z":0-359. min and max can be used to specify a range. See
here for more information.
Is true if the current city is in sandbox mode.
Checks whether there's ground of the given id at the current position.
A description will follow.
True if animation of the building's animation slot specified by attribute level is running, false otherwhise.
Evaluates the performance of the building at position x, y and checks it against =z or >=min and <=max. Values range from 0 to 100.
Can be used to make random numbers
Code: Select all
"condition":{
// A number in [0,9] is generated and checked to be >= min and <= max
"type":"rnd","min":0,"max":3,"frame":10
}
Re: Fun condition and action index
Posted: Sun Dec 03, 2017 9:58
by JustAnyone
Like always my ideas are too complicated for TheoTown to implement it, but if condition "buiilding" is true, could it unhide categories/buildings set by default hidden?
Re: Fun condition and action index
Posted: Sun Dec 03, 2017 10:14
by CommanderABab
I really don't think so, as that would be self-modifying code, a very dangerous practice.
Re: Fun condition and action index
Posted: Sun Jan 07, 2018 17:02
by CommanderABab
Yes. On built fun, on event fun, on click fun, random fun, fun: all can be there.
Re: Fun condition and action index
Posted: Sun Jan 07, 2018 17:11
by CommanderABab
Re: Fun condition and action index
Posted: Sun Jan 07, 2018 17:19
by CommanderABab
Re: Fun condition and action index
Posted: Sun Jan 07, 2018 22:20
by JustAnyone
I won't even bother with

. Probably dusko will make it in few seconds with his amazing keyboard.
Re: Fun condition and action index
Posted: Sat Jan 13, 2018 0:33
by KINGTUT10101
How does building nearby work?
Re: Fun condition and action index
Posted: Sat Jan 13, 2018 16:02
by Lobby
@KoalaGuy they should be supported, have you tried it?
@KINGTUT10101 it counts how many buildings of the specified id are on one of the 8 neighboring tiles. It then checks whether this number is >=min and <=max. I added this functionality for the Game of Life example, but you can do the same with the nearby condition (which is more general).
Re: Fun condition and action index
Posted: Fri Jan 26, 2018 23:20
by Lobby
It should work as expected: If there's road, it returns true. If you provide an id, it checks whether the road there also have this specific id. If you provide "lvl", it will check whether there's road at that specific level (0=ground, 1=air).
"x" and "y" move the context and aren't specifically connected to the check itself. So, if you set "x":1 and there's road at (1,0), it should return true.
Re: Fun condition and action index
Posted: Fri Jan 26, 2018 23:51
by Lobby
I just tested it and you're right, road detection doesn't work. Reason was this line:

Re: Fun condition and action index
Posted: Sat Jan 27, 2018 10:54
by Lobby
@former member You might use "road usage" for that purpose. It returns average usage of a road in percent. It will go >0 if there's a car.
Re: Fun condition and action index
Posted: Sat Jan 27, 2018 19:08
by CommanderABab
You could check the frame of a rotation aware id.
Re: Fun condition and action index
Posted: Sat Jan 27, 2018 19:33
by Lobby
No, but in the next update the virtual variable "cityRotation" will be capable of doing that.
Re: Fun condition and action index
Posted: Sun Jan 28, 2018 22:30
by Lobby
The variable is called "roadAutoJoin" and is ready to use

Re: Fun condition and action index
Posted: Wed Jan 31, 2018 18:53
by Lobby
Code: Select all
{"type":"value","code":"cityRotation","z":0} // Will only be true in default rotation
Values of cityRotation are 0, 1, 2, 3. 0 is default rotation, 1 is rotated by 90 degrees clockwise etc.
Re: Fun condition and action index
Posted: Wed Jan 31, 2018 18:56
by Lobby
Fixed.
Re: Condition Index
Posted: Wed Aug 29, 2018 2:50
by KINGTUT10101
Is it possible to detect what wheather is going on in a city?
Re: Condition Index
Posted: Wed Aug 29, 2018 9:01
by ElephantEthan
KINGTUT10101 wrote: ↑Wed Aug 29, 2018 2:50
Is it possible to detect what wheather is going on in a city?
You can use the "value" condition to check virtual variables for weather.
Variables
Virtual Variables
Weather manipulation
Re: Condition Index
Posted: Wed Aug 29, 2018 11:11
by CommanderABab
Thanks for the research!
