Condition Index

Any information about the fun attribute is given here.

Moderator: Plugin Moderators

User avatar
Imran M
Inhabitant of a Country
Reactions:
Posts: 844
Joined: 24 Oct 2018, 13:41
Plugins: Showcase Store

Plugin Creator

Platform

Re: Condition Index

#26

Post by Imran M »

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

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

Plugin Creator

Platform

Re: Condition Index

#27

Post by CommanderABab »

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!)

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

Plugin Creator

Platform

Re: Condition Index

#28

Post by CommanderABab »

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
		}
	}]
}]

User avatar
Imran M
Inhabitant of a Country
Reactions:
Posts: 844
Joined: 24 Oct 2018, 13:41
Plugins: Showcase Store

Plugin Creator

Platform

Re: Condition Index

#29

Post by Imran M »

CommanderABab wrote:
10 Feb 2019, 22: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?

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

Platform

Re: Condition Index

#30

Post by Lobby »

Imran M wrote:
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?
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: 471
Joined: 27 Jan 2018, 00:58
Location: ESPAÑA
Plugins: Showcase Store
Version: Beta
Contact:

Plugin Creator

Platform

Re: Condition Index

#31

Post by Kamikazi »

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

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

Plugin Creator

Platform

Re: Condition Index

#32

Post by CommanderABab »

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.

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

#33

Post by KINGTUT10101 »

On built fun is a thing? Since when?

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

Plugin Creator

Platform

Re: Condition Index

#34

Post by CommanderABab »

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.

User avatar
Hadestia
Inhabitant of a Megalopolis
Reactions:
Posts: 727
Joined: 17 Jul 2017, 16:16
Location: Philippines
Plugins: Showcase Store
Contact:

Plugin Creator

Platform

Re: Condition Index

#35

Post by Hadestia »

If road deco can build bus stops at the current position using fun?

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

Plugin Creator

Platform

Re: Condition Index

#36

Post by CommanderABab »

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.

User avatar
Hadestia
Inhabitant of a Megalopolis
Reactions:
Posts: 727
Joined: 17 Jul 2017, 16:16
Location: Philippines
Plugins: Showcase Store
Contact:

Plugin Creator

Platform

Re: Condition Index

#37

Post by Hadestia »

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 (•‿•)

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

Platform

Re: Condition Index

#38

Post by Lobby »

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: 727
Joined: 17 Jul 2017, 16:16
Location: Philippines
Plugins: Showcase Store
Contact:

Plugin Creator

Platform

Re: Condition Index

#39

Post by Hadestia »

Lobby 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:

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:

User avatar
Hadestia
Inhabitant of a Megalopolis
Reactions:
Posts: 727
Joined: 17 Jul 2017, 16:16
Location: Philippines
Plugins: Showcase Store
Contact:

Plugin Creator

Platform

Re: Condition Index

#40

Post by Hadestia »

Where's the rank condition?

User avatar
THEMAX
Inhabitant of a Universe
Reactions:
Posts: 4314
Joined: 14 Sep 2017, 17:30
Location: Astrellia, UHAE
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Condition Index

#41

Post by THEMAX »

Is on weather fun possible ? Well, on specific weather to be more specific.
Like on storm fun, on rain fun, on sunny fun or on fog fun, perhaps even on blizzard fun.

Basically i want to have a building façade that change color at night based on the on-going weather.

User avatar
Kulche
Pluche
Reactions:
Posts: 1141
Joined: 07 Jun 2017, 20:28
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Condition Index

#42

Post by Kulche »

You can use variables for that: viewtopic.php?f=81&t=5903

User avatar
PBbunnypower
Villager
Reactions:
Posts: 13
Joined: 26 Aug 2022, 11:49
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Condition Index

#43

Post by PBbunnypower »

Using in touch fun, Im trying to make an animation sort of thing. I have two animations defined. So what I ma trying to do is, have the snowflake fly up with one animation and make it fly down once the first animation. But I want to play the first animation on tap and stop when the second animation is over by itself (without an additional tap) So kinda like a video with autoplay off . I dont know how to execute the second part of it though.

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

Platform

Re: Condition Index

#44

Post by JustAnyone »

You would probably use fun variables for that. On clicked fun you would set the variable to 1, then a fun listener would check if variable is equal to 1 and start an animation. You would then check if animation is running and when it stops, change the variable back to zero and start the second animation. Something like that.

Post Reply Previous topicNext topic

Return to “Fun attribute”