Condition Index
Moderator: Plugin Moderators
- Imran M
- Inhabitant of a Megalopolis
- Reactions:
- Posts: 715
- Joined: Wed Oct 24, 2018 13:41
- Plugins: Show
Re: Condition Index
So rnd picks a number from 0-9, min and max means a range of numbers it can choose. would i put action, then type:frame, and frame:x? Is this correct?
I have no clue what's happening this year
Re: Condition Index
The result of the condition will only be true if min <= x <= max is fulfilled.
x will be a randomly picked integer between 0 and frame exclusively (namely 0, 1, 2, ..., frame - 1).
Yes, you set frames by something like
However that's for building animations, only. For animations appended to a building (that means by using the "animation" attribute and some pre-defined animation(s)) you have to use the animation control attributes.
Namely you can use
to set the frame of the first appended animation (indicated by "level":0) to 0. Use "type":"animation resume" to set a frame of an animation without pausing it.
x will be a randomly picked integer between 0 and frame exclusively (namely 0, 1, 2, ..., frame - 1).
Yes, you set frames by something like
Code: Select all
{"type":"frame","frame":0}
Namely you can use
Code: Select all
{"type":"animation resume","frame":0,"level":0}
=^._.^= ∫
- Imran M
- Inhabitant of a Megalopolis
- Reactions:
- Posts: 715
- Joined: Wed Oct 24, 2018 13:41
- Plugins: Show
Re: Condition Index
So, would the code be along the lines of this?Lobby wrote: ↑Sun Feb 10, 2019 17:12The result of the condition will only be true if min <= x <= max is fulfilled.
x will be a randomly picked integer between 0 and frame exclusively (namely 0, 1, 2, ..., frame - 1).
Yes, you set frames by something likeHowever that's for building animations, only. For animations appended to a building (that means by using the "animation" attribute and some pre-defined animation(s)) you have to use the animation control attributes.Code: Select all
{"type":"frame","frame":0}
Namely you can useto set the frame of the first appended animation (indicated by "level":0) to 0. Use "type":"animation resume" to set a frame of an animation without pausing it.Code: Select all
{"type":"animation resume","frame":0,"level":0}
Code: Select all
"fun":{"condition":{"type":"rnd","min":1,"max":3,"frame":0},"action":{"type":"animation resume","frame":0,"level":0},"condition":{"type":"rnd","min":4,"max":10,"frame":0},"action":{"type":"animation resume","frame":1,"level":0}}
I have no clue what's happening this year
- CommanderABab
- AB
- Reactions:
- Posts: 9113
- Joined: Tue Jun 07, 2016 21:12
- Plugins: Show
- Version: Beta
Re: Condition Index
Imran M wrote: ↑Sun Feb 10, 2019 17:37So, would the code be along the lines of this?Lobby wrote: ↑Sun Feb 10, 2019 17:12The result of the condition will only be true if min <= x <= max is fulfilled.
x will be a randomly picked integer between 0 and frame exclusively (namely 0, 1, 2, ..., frame - 1).
Yes, you set frames by something likeHowever that's for building animations, only. For animations appended to a building (that means by using the "animation" attribute and some pre-defined animation(s)) you have to use the animation control attributes.Code: Select all
{"type":"frame","frame":0}
Namely you can useto set the frame of the first appended animation (indicated by "level":0) to 0. Use "type":"animation resume" to set a frame of an animation without pausing it.Code: Select all
{"type":"animation resume","frame":0,"level":0}
Code: Select all
"fun":{"condition":{"type":"rnd","min":1,"max":3,"frame":0},"action":{"type":"animation resume","frame":0,"level":0},"condition":{"type":"rnd","min":4,"max":10,"frame":0},"action":{"type":"animation resume","frame":1,"level":0}}
Code: Select all
"fun": {
"condition": {
"type": "rnd",
"min": 1,
"max": 3,
"frame": 0
},
"action": {
"type": "animation resume",
"frame": 0,
"level": 0
},
"condition": {
"type": "rnd",
"min": 4,
"max": 10,
"frame": 0
},
"action": {
"type": "animation resume",
"frame": 1,
"level": 0
}
}

- Imran M
- Inhabitant of a Megalopolis
- Reactions:
- Posts: 715
- Joined: Wed Oct 24, 2018 13:41
- Plugins: Show
Re: Condition Index
So how should I do this? I'm clueless to fun.CommanderABab wrote: ↑Sun Feb 10, 2019 18:51Imran M wrote: ↑Sun Feb 10, 2019 17:37So, would the code be along the lines of this?Lobby wrote: ↑Sun Feb 10, 2019 17:12The result of the condition will only be true if min <= x <= max is fulfilled.
x will be a randomly picked integer between 0 and frame exclusively (namely 0, 1, 2, ..., frame - 1).
Yes, you set frames by something likeHowever that's for building animations, only. For animations appended to a building (that means by using the "animation" attribute and some pre-defined animation(s)) you have to use the animation control attributes.Code: Select all
{"type":"frame","frame":0}
Namely you can useto set the frame of the first appended animation (indicated by "level":0) to 0. Use "type":"animation resume" to set a frame of an animation without pausing it.Code: Select all
{"type":"animation resume","frame":0,"level":0}
Code: Select all
"fun":{"condition":{"type":"rnd","min":1,"max":3,"frame":0},"action":{"type":"animation resume","frame":0,"level":0},"condition":{"type":"rnd","min":4,"max":10,"frame":0},"action":{"type":"animation resume","frame":1,"level":0}}
is wrong.Code: Select all
"fun": { "condition": { "type": "rnd", "min": 1, "max": 3, "frame": 0 }, "action": { "type": "animation resume", "frame": 0, "level": 0 }, "condition": { "type": "rnd", "min": 4, "max": 10, "frame": 0 }, "action": { "type": "animation resume", "frame": 1, "level": 0 } }
I have no clue what's happening this year
- Imran M
- Inhabitant of a Megalopolis
- Reactions:
- Posts: 715
- Joined: Wed Oct 24, 2018 13:41
- Plugins: Show
Re: Condition Index
Wait a minute, would this work?
The condition is what number it is from the range, the action resumes with the first animation, if the number doesn't match a number from the range, it uses the second animation and flys safely, am I right? I think I haven't used frames correctly
Code: Select all
"fun":{"condition":{"type":"rnd","min":0,"max":3,"frame":0},"action":{"type":"animation resume","frame":1,"level":0},"else action":{"type":"animation resume","frame":1,"level":1}}
I have no clue what's happening this year
- CommanderABab
- AB
- Reactions:
- Posts: 9113
- Joined: Tue Jun 07, 2016 21:12
- Plugins: Show
- Version: Beta
Re: Condition Index
Code: Select all
[{
"fun": {
"condition": {
"type": "rnd",
"min": 0,
"max": 3,
"frame": 0
},
"action": {
"type": "animation resume",
"frame": 1,
"level": 0
},
"else action": {
"type": "animation resume",
"frame": 1,
"level": 1
}
}
}]

- CommanderABab
- AB
- Reactions:
- Posts: 9113
- Joined: Tue Jun 07, 2016 21:12
- Plugins: Show
- Version: Beta
Re: Condition Index
Code: Select all
[{
"fun": [{
"condition": {
"type": "rnd",
"min": 0,
"max": 3,
"frame": 0
},
"action": {
"type": "animation resume",
"frame": 1,
"level": 0
},
"else action": {
"type": "animation resume",
"frame": 1,
"level": 1
}
}]
}]

- Imran M
- Inhabitant of a Megalopolis
- Reactions:
- Posts: 715
- Joined: Wed Oct 24, 2018 13:41
- Plugins: Show
Re: Condition Index
So would this be the correct code?CommanderABab wrote: ↑Sun Feb 10, 2019 22:27Code: Select all
[{ "fun": [{ "condition": { "type": "rnd", "min": 0, "max": 3, "frame": 0 }, "action": { "type": "animation resume", "frame": 1, "level": 0 }, "else action": { "type": "animation resume", "frame": 1, "level": 1 } }] }]
I have no clue what's happening this year
Re: Condition Index
No, it picks a number from 0 to (frame-1), so you'd have to change at least the value of frame:
Code: Select all
"condition": {
"type": "rnd",
"min": 0,
"max": 3,
"frame": 10
}
=^._.^= ∫
- Kamikazi
- Inhabitant of a Conurbation
- Reactions:
- Posts: 364
- Joined: Sat Jan 27, 2018 0:58
- Location: Zaragoza, ESPAÑA
- Plugins: Show
- Version: Beta
- Contact:
Re: Condition Index
How do you do if you want a building only to be able to build in sandbox ...
...




- CommanderABab
- AB
- Reactions:
- Posts: 9113
- Joined: Tue Jun 07, 2016 21:12
- Plugins: Show
- Version: Beta
Re: Condition Index
Code: Select all
on built fun":[
{
"condition":{"type":"sandbox","invert":true},
"actions":[{"type":"remove"}]
}
]

- KINGTUT10101
- 1,000,000 inhabitants
- Reactions:
- Posts: 2103
- Joined: Thu Jul 07, 2016 22:50
- Location: 'Merica
- Plugins: Show
- Version: Beta
- Contact:
Re: Condition Index
On built fun is a thing? Since when?
All of my plug-ins, maps and more:
https://sites.google.com/view/retrocity ... authuser=0
YouTube channel:
https://youtube.com/c/kingtut-101
https://sites.google.com/view/retrocity ... authuser=0
YouTube channel:
https://youtube.com/c/kingtut-101
- CommanderABab
- AB
- Reactions:
- Posts: 9113
- Joined: Tue Jun 07, 2016 21:12
- Plugins: Show
- Version: Beta
Re: Condition Index
For a while. Probably 538 or so. It's important not to duplicate the same building within the plugin using "on built fun" as you will likely run into stack overflow.

- rjroldan1
- Inhabitant of a Megalopolis
- Reactions:
- Posts: 644
- Joined: Mon Jul 17, 2017 16:16
- Location: Philippines
- Plugins: Show
- Contact:
Re: Condition Index
If road deco can build bus stops at the current position using fun?
.╔═╗─────────────╔╗────────
║╬║─╔╗╔╦╗╔═╗╔╗─╔╝║╔═╗─╔═╦╗
║╗╣─╠╣║╔╝║╬║║╚╗║╬║║╬╚╗║║║║
╚╩╝╔╝║╚╝─╚═╝╚═╝╚═╝╚══╝╚╩═╝
───╚═╝────────────────────
T.P.C.
Plugin creator Doesn't had Cities
- CommanderABab
- AB
- Reactions:
- Posts: 9113
- Joined: Tue Jun 07, 2016 21:12
- Plugins: Show
- Version: Beta
Re: Condition Index
No, I don't think road decos have fun available to them. If yes, then they probably could. Roads could using the , but I wouldn't recommend it.
Code: Select all
"on built fun"

- rjroldan1
- Inhabitant of a Megalopolis
- Reactions:
- Posts: 644
- Joined: Mon Jul 17, 2017 16:16
- Location: Philippines
- Plugins: Show
- Contact:
Re: Condition Index
Can i suggest to implement "type":"rank" as a fun condition together with "lvl": integer for specified CITY RANK or maybe with "min" and "max"
i think these are also helpful condition (•‿•)
i think these are also helpful condition (•‿•)
.╔═╗─────────────╔╗────────
║╬║─╔╗╔╦╗╔═╗╔╗─╔╝║╔═╗─╔═╦╗
║╗╣─╠╣║╔╝║╬║║╚╗║╬║║╬╚╗║║║║
╚╩╝╔╝║╚╝─╚═╝╚═╝╚═╝╚══╝╚╩═╝
───╚═╝────────────────────
T.P.C.
Plugin creator Doesn't had Cities
Re: Condition Index
I'm surprised that this doesn't exist, yet. Will be added in 1.8.84 and work like that:
This would be true once the user has reached rank of index 3 (ranks start with index 0).
An alternative would be to use https://doc.theotown.com/modules/City.html#getRank in Lua:
Code: Select all
{"type":"rank", "min":3, "max": 9999}
An alternative would be to use https://doc.theotown.com/modules/City.html#getRank in Lua:
Code: Select all
local _,rank = City.getRank() -- Rank would then contain the rank level with 0 for the first rank
=^._.^= ∫
- rjroldan1
- Inhabitant of a Megalopolis
- Reactions:
- Posts: 644
- Joined: Mon Jul 17, 2017 16:16
- Location: Philippines
- Plugins: Show
- Contact:
Re: Condition Index
Im very happy that this will implement soon thanks lobbyLobby wrote: ↑Thu Jun 18, 2020 17:47I'm surprised that this doesn't exist, yet. Will be added in 1.8.84 and work like that:This would be true once the user has reached rank of index 3 (ranks start with index 0).Code: Select all
{"type":"rank", "min":3, "max": 9999}
An alternative would be to use https://doc.theotown.com/modules/City.html#getRank in Lua:Code: Select all
local _,rank = City.getRank() -- Rank would then contain the rank level with 0 for the first rank

.╔═╗─────────────╔╗────────
║╬║─╔╗╔╦╗╔═╗╔╗─╔╝║╔═╗─╔═╦╗
║╗╣─╠╣║╔╝║╬║║╚╗║╬║║╬╚╗║║║║
╚╩╝╔╝║╚╝─╚═╝╚═╝╚═╝╚══╝╚╩═╝
───╚═╝────────────────────
T.P.C.
Plugin creator Doesn't had Cities
- rjroldan1
- Inhabitant of a Megalopolis
- Reactions:
- Posts: 644
- Joined: Mon Jul 17, 2017 16:16
- Location: Philippines
- Plugins: Show
- Contact:
Re: Condition Index
Where's the rank condition?
.╔═╗─────────────╔╗────────
║╬║─╔╗╔╦╗╔═╗╔╗─╔╝║╔═╗─╔═╦╗
║╗╣─╠╣║╔╝║╬║║╚╗║╬║║╬╚╗║║║║
╚╩╝╔╝║╚╝─╚═╝╚═╝╚═╝╚══╝╚╩═╝
───╚═╝────────────────────
T.P.C.
Plugin creator Doesn't had Cities