Action Index

Any information about the fun attribute is given here.

Moderator: Plugin Moderators

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

Platform

Action Index

#1

Post by Lobby »

A generic action looks like:
Show
action name
Description
To do some actions (iff the corresponding condition is true) you can use the code:

Code: Select all

"actions":[{"type":"action name",...},...],
Possible additional attribute for actions are:
id, x, y, z, x2, y2, frame, invert, ignore, level,inner


Show
build
Builds whatever is given as id. If provided, the given frame will be used. For roads z can be used to provide the level to build at (0 or 1). For fences if frame is provided (0..3) it will be interpreted as edge index where to place the fence; if no frame was provided the fence will be built around the context area.
Show
remove
Removes anything from the given position. Convenient to ensure that a building can be built.
Show
remove fence
Removes the fence at the current location. If frame is provided it will be interpreted as edge index to remove.
Show
remove pipe
Removes the pipe at the given position. If id is provided the pipe will only be removed if it matches that id.
Show
remove road decoration
Removes the road decoration at the given position and level. If id is provided only road decorations with matching id will be removed.
Show
remove road occupation
Removes the road occupation at the given position and level. Reserved for future use.
Show
frame
Sets the frame of the building at x, y to the specified frame. The frame can also be specified using code.
Show
burn
Initiates a fire on the building at x, y. Be aware that not all buildings can burn.
Show
extinguish
Extinguishes the fire of the building at x, y.
Show
play
Plays the sound from the given id.
Show
notify
See here for more information.
Show
disaster
Issues a disaster at the given position. The disaster is specified using the "id" tag. Possible values are:
  • "fire"
  • "meteor"
  • "earthquake"
  • "nuke"
  • "tornado"
  • "nuclear plant"
  • "illness"
  • "flooding"
  • "riot"
  • "crime"
  • "ufo"
  • "generic building"
Set "frame":0 to let the disaster spawn at a random position. If the disaster wasn't issued successfully, further actions won't be executed. Set "ignore":true to change this behavior.
Show
toast
Shows an Android toast overlay with id as content.
Show
firework
Emits the firework specified by id at x, y.
Show
set
Sets the value of the variable id to the value given in code. See here for more information about variables.
Show
performance
Applies the performance provided in code to of the building at x, y (values 0 - 100).
Show
animation pause
Pauses the animation slot "level" (0 by default). Additionally sets the frame to "frame" if specified.
Show
animation resume
Resumes the animation slot "level" (0 by default). Additionally sets the frame to "frame" if specified.
Show
rect
Can be used to execute actions in a rectangular area.
See here: https://theotown.com/forum/viewtopic.ph ... 25#p118725
Show
call
Can be used to call a Lua function.
See here: viewtopic.php?f=81&t=10561
Last edited by Bearbear76 on 24 May 2020, 16:14, edited 2 times in total.
=^._.^= ∫

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

Platform

Re: Fun condition and action index

#2

Post by Lobby »

New with the next version: disaster action :teach
=^._.^= ∫

User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 2192
Joined: 07 Jul 2016, 22:50
Location: 'Merica
Plugins: Showcase Store
Version: Beta
Contact:

Platform

Plugin Creator

Re: Fun condition and action index

#3

Post by KINGTUT10101 »

Is illness going to be functional?

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

Platform

Re: Fun condition and action index

#4

Post by Lobby »

No, it shouldn't do anything, yet.
=^._.^= ∫

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

Platform

Re: Fun condition and action index

#5

Post by JustAnyone »

Lobby wrote:
17 Nov 2017, 17:34
...yet.
:bb
:pickle:

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

Platform

Re: Fun condition and action index

#6

Post by JustAnyone »

KoalaGuy wrote:
07 Jan 2018, 11:51
@Lobby
It looks like the nuke disaster doesn't work with fun. Could you please have a look at it :bq
It does. At least for my disasterous presents.
:pickle:

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

Platform

Re: Fun condition and action index

#7

Post by Lobby »

This code works for me :json

Code: Select all

"on click fun":[
  {
    "actions":[{"type":"disaster","id":"nuke"}]
  }
]
So how does your code look like?
Attachments
Screenshot_20180107-113737.png
=^._.^= ∫

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

Platform

Plugin Creator

Re: Fun condition and action index

#8

Post by CommanderABab »

It works for me. Set speed to max. Build a 6x6 road enclosure(max!), totally enclosed. Build the wandering blue animals inside! (They're nuclear enabled). Don't let any out! Set some on fire. Wait til the animation freezes. Wait a bit longer!

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

Platform

Plugin Creator

Re: Fun condition and action index

#9

Post by CommanderABab »

Code: Select all

"on event fun":[
        {"actions":[{"type":"burn","x":0,"y":1}],"always":true,"ignore success":true},
        {"actions":[{"type":"burn","x":0,"y":-1}],"always":true,"ignore success":true},
        {"actions":[{"type":"burn","x":1,"y":0}],"always":true,"ignore success":true},
        {"actions":[{"type":"burn","x":-1,"y":0}],"always":true,"ignore success":true}                
      ],   
If you are spawning rioters on the roads from a 1x1 building..

Copy the actions and change the 1s to 2s etc for greater radius. You have to remember it might hit a big building. If the spawning building is bigger than 1x1, you have to add its width to the positive x and y values to avoid setting itself on fire.

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

Platform

Re: Fun condition and action index

#10

Post by Lobby »

Yes, that's the issue:
issue.png
issue.png (12.85 KiB) Viewed 15011 times
Will be fixed :bf
=^._.^= ∫

User avatar
Mg3094066
Inhabitant of a Supercluster
Reactions:
Posts: 3223
Joined: 28 May 2017, 01:50
Location: Venezuelan Republic of Mexico
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Fun condition and action index

#11

Post by Mg3094066 »

Lobby wrote:
17 Nov 2017, 17:34
No, it shouldn't do anything, yet.
I have a question
How the meteor explosion works?
I threw my dignity to trash and downloaded Free Fire... But someway i liked it ":'D

But i think it was too early to celebrate... my internet runs at 8kb...

Just wait another month... :bb

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

Platform

Re: Fun condition and action index

#12

Post by JustAnyone »

Creates white screen, shakes it, builds scrap and crater.
:pickle:

User avatar
Mg3094066
Inhabitant of a Supercluster
Reactions:
Posts: 3223
Joined: 28 May 2017, 01:50
Location: Venezuelan Republic of Mexico
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Fun condition and action index

#13

Post by Mg3094066 »

JustAnyone wrote:
27 Jan 2018, 08:15
Creates white screen, shakes it, builds scrap and crater.
In a json code, may be used for napalms because we can produce big fires
I threw my dignity to trash and downloaded Free Fire... But someway i liked it ":'D

But i think it was too early to celebrate... my internet runs at 8kb...

Just wait another month... :bb

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

Platform

Re: Fun condition and action index

#14

Post by Lobby »

@former member I think you would have to do it the other way: The buildings that should change should do it in their own fun code.

@former member I'm not sure why or how to add it. After all, the system isn't meant to be used that way.
=^._.^= ∫

cesareborgia94
Reactions:

Re: Fun condition and action index

#15

Post by cesareborgia94 »

Lobby wrote:
17 Nov 2017, 17:29
New with the next version: disaster action :teach
Lobby, it may be too late for this question but what does the disaster action do?
Also in the action index, can you specify, explain in-depth what does toasts do?
Thank you for your time.

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

Plugin Creator

Platform

Re: Action Index

#16

Post by Kulche »

For disaster action, it summons chosen disaster (earthquake, meteor, nukes, etc.) at random or specified location.

Code: Select all

"fun":[
{
"actions":[
{
"type":"disaster",  //Makes fun disastrous
"id":"nuke",  //Shoots nuke at x and y   \/ look down there\/
"x":10,
"y":-10  //Specifies location
}
]
}
]
I'm not lazy, I'm motivated to do nothing!
...blame lobby for that

cesareborgia94
Reactions:

Re: Action Index

#17

Post by cesareborgia94 »

Kulche wrote:
04 Jul 2018, 19:16
For disaster action, it summons chosen disaster (earthquake, meteor, nukes, etc.) at random or specified location.

Code: Select all

"fun":[
{
"actions":[
{
"type":"disaster",  //Makes fun disastrous
"id":"nuke",  //Shoots nuke at x and y   \/ look down there\/
"x":10,
"y":-10  //Specifies location
}
]
}
]
Does it apply to crime as well?
Sorry for asking the repeated questions, jusy need some confirmation.
Also, if you did not specify location, it would happen at a random place, yes?

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

Plugin Creator

Platform

Re: Action Index

#18

Post by Kulche »

Propably yes, cuz Lobby wrote it upper.

Idk, try it.
I'm not lazy, I'm motivated to do nothing!
...blame lobby for that

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

Platform

Re: Action Index

#19

Post by Lobby »

Yes, it works also for crime :bc

Toasts are especially useful for debugging. It's basically a text that is shown for a short amount of time and can be used to provide some information. See here for more details: https://developer.android.com/guide/top ... ers/toasts

Usage is quite simple:

Code: Select all

"actions":[{"type":"toast","id":"Hi, I am some text!"}]
If you want to print the value of a variable $myvar on the screen you can use string interpolation:

Code: Select all

"actions":[{"type":"toast","id":"The value of the variable is ${$myvar}"}]
The content of ${*} will be evaluated at runtime and can therefore be used to show the value of variables.
=^._.^= ∫

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

Platform

Plugin Creator

Re: Action Index

#20

Post by CommanderABab »

Show
quote
Lobby wrote:
04 Jul 2018, 19:35
Yes, it works also for crime :bc

Toasts are especially useful for debugging. It's basically a text that is shown for a short amount of time and can be used to provide some information. See here for more details: https://developer.android.com/guide/top ... ers/toasts

Usage is quite simple:

Code: Select all

"actions":[{"type":"toast","id":"Hi, I am some text!"}]
If you want to print the value of a variable $myvar on the screen you can use string interpolation:

Code: Select all

"actions":[{"type":"toast","id":"The value of the variable is ${$myvar}"}]
The content of ${*} will be evaluated at runtime and can therefore be used to show the value of variables.
#stringinterpolation,
#runtimeevaluation

Post Reply Previous topicNext topic

Return to “Fun attribute”