Condition Index

Any information about the fun attribute is given here.

Moderator: FranchuFranchu

Post Reply
User avatar
Lobby
Developer
Reactions:
Posts: 2946
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone: S7 edge

Condition Index

Post by Lobby » Thu Oct 05, 2017 10:52

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
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.
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.
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 buring.
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
performance
Evaluates the performance of the building at position x, y and check 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
}
...Have a nice stay

User avatar
JustAnyone
Feature manager
Reactions:
Posts: 1977
Joined: Sun Jul 23, 2017 12:45
Location: TheoTown command centre
Plugins: Show
Version: Beta
Phone: Xiaomi Redmi 3s

Re: Fun condition and action index

Post by JustAnyone » Sun Dec 03, 2017 9:58

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?
Founder and owner of DSA
TheoTown discord manager
Developer of Plugin Creator Application.

User avatar
CommanderABab
Inhabitant of a Multiverse
Reactions:
Posts: 5728
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Re: Fun condition and action index

Post by CommanderABab » Sun Dec 03, 2017 10:14

I really don't think so, as that would be self-modifying code, a very dangerous practice.
486486Currently using 486. 486 What's new? :)
Urban rails, search!
:)

Telegram - t.me/
๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธCommander๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธ

User avatar
CommanderABab
Inhabitant of a Multiverse
Reactions:
Posts: 5728
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Re: Fun condition and action index

Post by CommanderABab » Sun Jan 07, 2018 17:02

Yes. On built fun, on event fun, on click fun, random fun, fun: all can be there.
486486Currently using 486. 486 What's new? :)
Urban rails, search!
:)

Telegram - t.me/
๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธCommander๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธ

User avatar
CommanderABab
Inhabitant of a Multiverse
Reactions:
Posts: 5728
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Re: Fun condition and action index

Post by CommanderABab » Sun Jan 07, 2018 17:11

486486Currently using 486. 486 What's new? :)
Urban rails, search!
:)

Telegram - t.me/
๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธCommander๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธ

User avatar
CommanderABab
Inhabitant of a Multiverse
Reactions:
Posts: 5728
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Re: Fun condition and action index

Post by CommanderABab » Sun Jan 07, 2018 17:19

486486Currently using 486. 486 What's new? :)
Urban rails, search!
:)

Telegram - t.me/
๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธCommander๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธ

Nexus24680
Inhabitant of a Megalopolis
Reactions:
Posts: 666
Joined: Sat May 06, 2017 19:12
Plugins: Show
Version: Beta

Re: Fun condition and action index

Post by Nexus24680 » Sun Jan 07, 2018 22:01

@CommanderABab, thanks.
BTW, how do I make a specific building catch fire on a specific date?
Maybe the Big City Hall on Nov. 5
ยฏ\_(ใƒ„)_/ยฏ

User avatar
JustAnyone
Feature manager
Reactions:
Posts: 1977
Joined: Sun Jul 23, 2017 12:45
Location: TheoTown command centre
Plugins: Show
Version: Beta
Phone: Xiaomi Redmi 3s

Re: Fun condition and action index

Post by JustAnyone » Sun Jan 07, 2018 22:20

I won't even bother with :json . Probably dusko will make it in few seconds with his amazing keyboard.
Founder and owner of DSA
TheoTown discord manager
Developer of Plugin Creator Application.

User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 1655
Joined: Thu Jul 07, 2016 22:50
Location: 'Merica
Plugins: Show
Version: Beta
Phone: Moto Z Force Droid

Re: Fun condition and action index

Post by KINGTUT10101 » Sat Jan 13, 2018 0:33

How does building nearby work?

User avatar
Lobby
Developer
Reactions:
Posts: 2946
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone: S7 edge

Re: Fun condition and action index

Post by Lobby » Sat Jan 13, 2018 16:02

@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).
...Have a nice stay

User avatar
Lobby
Developer
Reactions:
Posts: 2946
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone: S7 edge

Re: Fun condition and action index

Post by Lobby » Fri Jan 26, 2018 23:20

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.
...Have a nice stay

User avatar
Lobby
Developer
Reactions:
Posts: 2946
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone: S7 edge

Re: Fun condition and action index

Post by Lobby » Fri Jan 26, 2018 23:51

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

Nexus24680
Inhabitant of a Megalopolis
Reactions:
Posts: 666
Joined: Sat May 06, 2017 19:12
Plugins: Show
Version: Beta

Re: Fun condition and action index

Post by Nexus24680 » Sat Jan 27, 2018 4:00

@Lobby
Can you please add a fun action that detects if there's a car on the tile?
For example,
If I put building A and I set it to check if there's a car on the road next to it, if so it changes to B, if not it keeps being A
Could this be possible?
Could you implement it please?

User avatar
Lobby
Developer
Reactions:
Posts: 2946
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone: S7 edge

Re: Fun condition and action index

Post by Lobby » Sat Jan 27, 2018 10:54

@Nexus24680 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.
...Have a nice stay

User avatar
CommanderABab
Inhabitant of a Multiverse
Reactions:
Posts: 5728
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Re: Fun condition and action index

Post by CommanderABab » Sat Jan 27, 2018 19:08

You could check the frame of a rotation aware id.
486486Currently using 486. 486 What's new? :)
Urban rails, search!
:)

Telegram - t.me/
๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธCommander๐Ÿ†Ž๏ธ๐Ÿ†Ž๏ธ

User avatar
Lobby
Developer
Reactions:
Posts: 2946
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone: S7 edge

Re: Fun condition and action index

Post by Lobby » Sat Jan 27, 2018 19:33

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

User avatar
Lobby
Developer
Reactions:
Posts: 2946
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone: S7 edge

Re: Fun condition and action index

Post by Lobby » Sun Jan 28, 2018 22:30

The variable is called "roadAutoJoin" and is ready to use 8-)
...Have a nice stay

User avatar
Lobby
Developer
Reactions:
Posts: 2946
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone: S7 edge

Re: Fun condition and action index

Post by Lobby » Wed Jan 31, 2018 18:53

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.
...Have a nice stay

User avatar
Lobby
Developer
Reactions:
Posts: 2946
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone: S7 edge

Re: Fun condition and action index

Post by Lobby » Wed Jan 31, 2018 18:56

Fixed.
...Have a nice stay

Post Reply

Return to โ€œFun attributeโ€

Who is online

Users browsing this forum: No registered users and 1 guest

๏ปฟ