Re: Condition Index
Posted: 10 Feb 2019, 14:16
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?
A feature rich city builder game for Android, iOS and PC
https://forum.theotown.com/
Code: Select all
{"type":"frame","frame":0}
Code: Select all
{"type":"animation resume","frame":0,"level":0}
So, would the code be along the lines of this?Lobby wrote: ↑10 Feb 2019, 17:12 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 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}}
Imran M wrote: ↑10 Feb 2019, 17:37So, would the code be along the lines of this?Lobby wrote: ↑10 Feb 2019, 17:12 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 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
}
}
So how should I do this? I'm clueless to fun.CommanderABab wrote: ↑10 Feb 2019, 18:51Imran M wrote: ↑10 Feb 2019, 17:37So, would the code be along the lines of this?Lobby wrote: ↑10 Feb 2019, 17:12 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 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 } }
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}}
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
}
}
}]
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
}
}]
}]
So would this be the correct code?CommanderABab wrote: ↑10 Feb 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 } }] }]
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
}
Code: Select all
on built fun":[
{
"condition":{"type":"sandbox","invert":true},
"actions":[{"type":"remove"}]
}
]
Code: Select all
"on built fun"
Code: Select all
{"type":"rank", "min":3, "max": 9999}
Code: Select all
local _,rank = City.getRank() -- Rank would then contain the rank level with 0 for the first rank
Im very happy that this will implement soon thanks lobbyLobby wrote: ↑18 Jun 2020, 17:47 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).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