Condition Index

Any information about the fun attribute is given here.
User avatar
Imran M
Inhabitant of a Country
Reactions:
Posts: 832
Joined: 24 Oct 2018, 11:41
Plugins: Showcase Store

Plugin Creator

Platform

Re: Condition Index

Post by Imran M » 10 Feb 2019, 12: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?
I just love the DOPE-amine you get after completing a plugin!
User avatar
Lobby
Inhabitant of a Supercluster
Reactions:
Posts: 3756
Joined: 26 Oct 2008, 10:34
Plugins: Showcase Store

Re: Condition Index

Post by Lobby » 10 Feb 2019, 15: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 like

Code: Select all

{"type":"frame","frame":0}
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

Code: Select all

{"type":"animation resume","frame":0,"level":0} 
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.
User avatar
Imran M
Inhabitant of a Country
Reactions:
Posts: 832
Joined: 24 Oct 2018, 11:41
Plugins: Showcase Store

Plugin Creator

Platform

Re: Condition Index

Post by Imran M » 10 Feb 2019, 15:37

Lobby wrote: 10 Feb 2019, 15: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 like

Code: Select all

{"type":"frame","frame":0}
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

Code: Select all

 {"type":"animation resume","frame":0,"level":0} 
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.
So, would the code be along the lines of this?

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 just love the DOPE-amine you get after completing a plugin!
User avatar
CommanderABab
AB
Reactions:
Posts: 11263
Joined: 07 Jun 2016, 19:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Condition Index

Post by CommanderABab » 10 Feb 2019, 16:51

Imran M wrote: 10 Feb 2019, 15:37
Lobby wrote: 10 Feb 2019, 15: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 like

Code: Select all

{"type":"frame","frame":0}
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

Code: Select all

 {"type":"animation resume","frame":0,"level":0} 
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.
So, would the code be along the lines of this?

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
 	}
 }
is wrong.
my avatar:
User avatar
Imran M
Inhabitant of a Country
Reactions:
Posts: 832
Joined: 24 Oct 2018, 11:41
Plugins: Showcase Store

Plugin Creator

Platform

Re: Condition Index

Post by Imran M » 10 Feb 2019, 17:26

CommanderABab wrote: 10 Feb 2019, 16:51
Imran M wrote: 10 Feb 2019, 15:37
Lobby wrote: 10 Feb 2019, 15: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 like

Code: Select all

{"type":"frame","frame":0}
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

Code: Select all

 {"type":"animation resume","frame":0,"level":0} 
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.
So, would the code be along the lines of this?

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
 	}
 }
is wrong.
So how should I do this? I'm clueless to fun.
I just love the DOPE-amine you get after completing a plugin!
User avatar
Imran M
Inhabitant of a Country
Reactions:
Posts: 832
Joined: 24 Oct 2018, 11:41
Plugins: Showcase Store

Plugin Creator

Platform

Re: Condition Index

Post by Imran M » 10 Feb 2019, 17:52

Wait a minute, would this work?

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}} 
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
I just love the DOPE-amine you get after completing a plugin!
User avatar
CommanderABab
AB
Reactions:
Posts: 11263
Joined: 07 Jun 2016, 19:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Condition Index

Post by CommanderABab » 10 Feb 2019, 20:21

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
		}
	}
}]
which one is the pause? (Nevermind!)
my avatar:
User avatar
CommanderABab
AB
Reactions:
Posts: 11263
Joined: 07 Jun 2016, 19:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Condition Index

Post by CommanderABab » 10 Feb 2019, 20:27

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
		}
	}]
}]
my avatar:
User avatar
Imran M
Inhabitant of a Country
Reactions:
Posts: 832
Joined: 24 Oct 2018, 11:41
Plugins: Showcase Store

Plugin Creator

Platform

Re: Condition Index

Post by Imran M » 15 Feb 2019, 10:58

CommanderABab wrote: 10 Feb 2019, 20:27

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?
I just love the DOPE-amine you get after completing a plugin!
User avatar
Lobby
Inhabitant of a Supercluster
Reactions:
Posts: 3756
Joined: 26 Oct 2008, 10:34
Plugins: Showcase Store

Re: Condition Index

Post by Lobby » 15 Feb 2019, 12:16

Imran M wrote: 10 Feb 2019, 12: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?
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
}
Please test the code and if it doesn't work as intended then let us know what exactly you expected and what happened instead.
User avatar
Kamikazi
Inhabitant of a Conurbation
Reactions:
Posts: 465
Joined: 26 Jan 2018, 22:58
Location: ESPAÑA
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Condition Index

Post by Kamikazi » 30 Jan 2020, 17:57

How do you do if you want a building only to be able to build in sandbox ...If you are wondering, yes, it is for the fill sandbox requirements plugin
Some random Spaniard sporadically playing TheoTown

Known in the Discord server for streaming the weirdest games

Also, I have a Discord server
https://discord.gg/AwcyJnyeYZ
User avatar
CommanderABab
AB
Reactions:
Posts: 11263
Joined: 07 Jun 2016, 19:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Condition Index

Post by CommanderABab » 30 Jan 2020, 23:24

Screenshot_20200130-173205.jpg

Code: Select all

on built fun":[
  {
    "condition":{"type":"sandbox","invert":true},
    "actions":[{"type":"remove"}]
  }
]
Would remove the current building when building finishes if the map is not sandbox.
You do not have the required permissions to view the files attached to this post.
my avatar:
User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 2208
Joined: 07 Jul 2016, 20:50
Location: 'Merica
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Condition Index

Post by KINGTUT10101 » 31 Jan 2020, 15:28

On built fun is a thing? Since when?
User avatar
CommanderABab
AB
Reactions:
Posts: 11263
Joined: 07 Jun 2016, 19:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Condition Index

Post by CommanderABab » 31 Jan 2020, 17:00

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.
my avatar:
User avatar
Hadestia
Inhabitant of a Megalopolis
Reactions:
Posts: 721
Joined: 17 Jul 2017, 14:16
Location: Philippines
Plugins: Showcase Store

Plugin Creator

Platform

Re: Condition Index

Post by Hadestia » 06 May 2020, 07:18

If road deco can build bus stops at the current position using fun?
 ! Message from: Hadestia
Visit my YouTube channel:
https://youtube.com/channel/UC5qG-r8y21036JZbGRClbdQ
User avatar
CommanderABab
AB
Reactions:
Posts: 11263
Joined: 07 Jun 2016, 19:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Condition Index

Post by CommanderABab » 06 May 2020, 18:34

No, I don't think road decos have fun available to them. If yes, then they probably could. Roads could using the

Code: Select all

"on built fun"
, but I wouldn't recommend it.
my avatar:
User avatar
Hadestia
Inhabitant of a Megalopolis
Reactions:
Posts: 721
Joined: 17 Jul 2017, 14:16
Location: Philippines
Plugins: Showcase Store

Plugin Creator

Platform

Re: Condition Index

Post by Hadestia » 18 Jun 2020, 07:42

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 (•‿•)
 ! Message from: Hadestia
Visit my YouTube channel:
https://youtube.com/channel/UC5qG-r8y21036JZbGRClbdQ
User avatar
Lobby
Inhabitant of a Supercluster
Reactions:
Posts: 3756
Joined: 26 Oct 2008, 10:34
Plugins: Showcase Store

Re: Condition Index

Post by Lobby » 18 Jun 2020, 15:47

I'm surprised that this doesn't exist, yet. Will be added in 1.8.84 and work like that:

Code: Select all

{"type":"rank", "min":3, "max": 9999}
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

local _,rank = City.getRank()  -- Rank would then contain the rank level with 0 for the first rank
User avatar
Hadestia
Inhabitant of a Megalopolis
Reactions:
Posts: 721
Joined: 17 Jul 2017, 14:16
Location: Philippines
Plugins: Showcase Store

Plugin Creator

Platform

Re: Condition Index

Post by Hadestia » 18 Jun 2020, 16:03

Lobby wrote: 18 Jun 2020, 15:47 I'm surprised that this doesn't exist, yet. Will be added in 1.8.84 and work like that:

Code: Select all

{"type":"rank", "min":3, "max": 9999}
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

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 lobby :lol:
 ! Message from: Hadestia
Visit my YouTube channel:
https://youtube.com/channel/UC5qG-r8y21036JZbGRClbdQ
User avatar
Hadestia
Inhabitant of a Megalopolis
Reactions:
Posts: 721
Joined: 17 Jul 2017, 14:16
Location: Philippines
Plugins: Showcase Store

Plugin Creator

Platform

Re: Condition Index

Post by Hadestia » 31 Oct 2020, 17:48

Where's the rank condition?
 ! Message from: Hadestia
Visit my YouTube channel:
https://youtube.com/channel/UC5qG-r8y21036JZbGRClbdQ