Condition Index

Any information about the fun attribute is given here.

Moderator: Plugin Moderators

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

Platform

Condition Index

#1

Post by Lobby »

A generic condition looks like:
Show
condition name
Description
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


Show
building
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.
Show
buildable
Checks if the building given by ID is buildable by user at given x/y.
Show
building nearby
A description will follow.
Show
wire
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.
Show
road
A description will follow.
Show
road decoration
Checks whether there's a road decoration (if provided: of the given id) at x, y.
Show
road occupation
Reserved for future use.
Show
fence
Checks whether there's a fence on the given tile. If frame is provided it will be interpreted as edge index to check.
Show
pipe
Checks whether there's a pipe (if provided: of the given id) at x, y.
Show
tree
Checks whether there's a tree (if provided, of the given id) at x, y.
Show
and
Is only true if all inner conditions are true (or if there are no inner conditions).
Show
or
Is true if at least one inner condition is true.
Show
true
Is always true. If you don't provide any condition this one will be the default one
Show
false
Is always false.
Show
count
Counts the number of true inner conditions. The number x is hen checked against min + z <= x <= max + z.
Show
nearby
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.
Show
frame
Checks whether the frame of the building at x, y fulfilled min + z <= frame <= max + z. Also works for roads but checks for the alignment (0<=alignment<=15) rather than the frame. Specify "code":"f" to check for the actual frame (to detect one-way directions).
Show
land
Checks whether the tile at x, y is land (if specified, of the given id).
Show
water
Checks whether the tile at x, y is water (if specified, of the given id).
Show
road usage
Evaluates the road usage at the current position and checks whether it's in the provided range. Values range from 0 to 100.
Show
zone
Checks whether the zone - given by id - is set at the current position.
Show
building count
Counts how often the building - given by id - is built in the current city.
Show
value
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

Code: Select all

min + z <= code <= max + z
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

Code: Select all

z = code
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.
Show
burning
Returns true if the building at the current position is burning.
Show
upgrade
Checks whether the upgrade - given by id - is applied to the building at the current position.
Show
date
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.
Show
sandbox
Is true if the current city is in sandbox mode.
Show
ground
Checks whether there's ground of the given id at the current position.
Show
map size
A description will follow.
Show
animation running
True if animation of the building's animation slot specified by attribute level is running, false otherwhise.
Show
performance
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.
Show
rnd
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
}
Last edited by FranchuFranchu on 06 Aug 2018, 22:36, edited 1 time in total.

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

Platform

Re: Fun condition and action index

#2

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

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

Plugin Creator

Platform

Re: Fun condition and action index

#3

Post by CommanderABab »

I really don't think so, as that would be self-modifying code, a very dangerous practice.

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

Plugin Creator

Platform

Re: Fun condition and action index

#4

Post by CommanderABab »

Yes. On built fun, on event fun, on click fun, random fun, fun: all can be there.

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

Plugin Creator

Platform

Re: Fun condition and action index

#5

Post by CommanderABab »


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

Plugin Creator

Platform

Re: Fun condition and action index

#6

Post by CommanderABab »


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

Platform

Re: Fun condition and action index

#7

Post by JustAnyone »

I won't even bother with :json . Probably dusko will make it in few seconds with his amazing keyboard.

User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 2220
Joined: 07 Jul 2016, 22:50
Location: 'Merica
Plugins: Showcase Store
Version: Beta
Contact:

Plugin Creator

Platform

Re: Fun condition and action index

#8

Post by KINGTUT10101 »

How does building nearby work?

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

Platform

Re: Fun condition and action index

#9

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

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

Platform

Re: Fun condition and action index

#10

Post 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 "level", 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.
Last edited by CommanderABab on 24 Apr 2021, 21:35, edited 1 time in total.
Reason: "lvl" is actually "level"

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

Platform

Re: Fun condition and action index

#11

Post by Lobby »

I just tested it and you're right, road detection doesn't work. Reason was this line:
fun_road_bug.png
:fire

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

Platform

Re: Fun condition and action index

#12

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

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

Plugin Creator

Platform

Re: Fun condition and action index

#13

Post by CommanderABab »

You could check the frame of a rotation aware id.

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

Platform

Re: Fun condition and action index

#14

Post by Lobby »

No, but in the next update the virtual variable "cityRotation" will be capable of doing that.

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

Platform

Re: Fun condition and action index

#15

Post by Lobby »

The variable is called "roadAutoJoin" and is ready to use 8-)

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

Platform

Re: Fun condition and action index

#16

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

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

Platform

Re: Fun condition and action index

#17

Post by Lobby »

Fixed.

User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 2220
Joined: 07 Jul 2016, 22:50
Location: 'Merica
Plugins: Showcase Store
Version: Beta
Contact:

Plugin Creator

Platform

Re: Condition Index

#18

Post by KINGTUT10101 »

Is it possible to detect what wheather is going on in a city?

User avatar
ElephantEthan
Inhabitant of a Megacity
Reactions:
Posts: 294
Joined: 26 Aug 2018, 14:07
Plugins: Showcase Store

Platform

Re: Condition Index

#19

Post by ElephantEthan »

KINGTUT10101 wrote:
29 Aug 2018, 02: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
Last edited by CommanderABab on 29 Aug 2018, 11:11, edited 1 time in total.
Reason: Added buttons with some info about link topics

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

Plugin Creator

Platform

Re: Condition Index

#20

Post by CommanderABab »

ElephantEthan wrote:
29 Aug 2018, 09:01
KINGTUT10101 wrote:
29 Aug 2018, 02: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
Thanks for the research! :)

Post Reply Previous topicNext topic

Return to “Fun attribute”