Firework

Find tutorials, documentation, and resources for creating and using TheoTown plugins.
Previous topicNext topic
User avatar
Josh
Inhabitant of a Galaxy
Reactions:
Posts: 2213
Joined: 11 Mar 2017, 17:20
Location: The Netherlands
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Firework

Post by Josh »

In this tutorial, I'm going to show how to make firework. You don't need any graphics because the particles are defined in code.

Code: Select all

[
  {
    "id":"$firework30","type":"animation","frames":[{"steal":"$anim_firework00","frame":2}],
    "meta":{"tags":{"firework":{
      "alpha":0.5, 
      "speed":15,
      "speed variation":0,
      "n":1,
      "time":2500,
      "time variation":0,
      "next":[
          {"id":"$firework31",  "always":true}, 
          {"id":"$firework32"}
       ]
    }}}
  },
  {
    "id":"$firework31","type":"animation","frames":[{"steal":"$anim_firework00","frame":2}],
    "meta":{"tags":{"firework":{
      "alpha":100, 
      "speed":5,
      "speed variation":1,
      "n":1000,
      "time":750,
      "time variation":1
    }}}
  },
  {
    "id":"$firework32","type":"animation","frames":[{"steal":"$anim_firework00","frame":3}],
    "meta":{"tags":{"firework":{
      "alpha":100, 
      "speed":5,
      "speed variation":1,
      "n":1000,
      "time":750,
      "time variation":1
    }}}
  },
  {
    "id":"$syl_spawner03",
    "type":"decoration",
    "category":"$category_firework00",
    "title":"Willow",
    "text":"A big willow.",
    "width":1,
    "height":1,
    "frames":[{"x":960,"y":524,"w":32,"h":20,"offset x":1024,"offset y":1024}],
    "on click fun":[
      {
        "actions":[{"type":"firework","id":"$firework30","z":1}]
      }
    ],
    "fun":[
      {
        "condition":{"type":"or","inner":[
          {"type":"building","id":"$on","x":1},
          {"type":"building","id":"$on","y":1},
          {"type":"building","id":"$on","x":-1},
          {"type":"building","id":"$on","y":-1}
        ]},
        "actions":[{"type":"firework","id":"$firework30","z":1}]
      }
    ],
    "requirements":[{"type":"FEATURE","id":"$feature_firework00"}]
  }
]
The frames are from this picture called $anim_firework00, from left to right (0-14) :img
$anim_firework00.png
The whole code for the huge willow. Let's go through it!

"alpha" - The direction of the particle(s).
"speed" - The speed of a particle(s).
"speed variation" - If there should be variation in speed of the particle(s).
"n" - The number of particles to spawn.
"time" - The duration of the particle(s).
"time variation" - If there should be variation in the duration of the particle(s).
"next" - The id of the particle(s) that should spawn after the lifetime of the current particle(s) expired.

Feel free to ask questions about it :)
You do not have the required permissions to view the files attached to this post.
Last edited by Josh on 20 Jan 2020, 13:11, edited 1 time in total.
TheoTown player since update 1.1.50

Creator of Aldorria, Covinton Empire, West Country, Sunnydale
User avatar
Lobby
Inhabitant of a Supercluster
Reactions:
Posts: 3759
Joined: 26 Oct 2008, 10:34
Plugins: Showcase Store

Re: Firework

Post by Lobby »

Cool, thank you :)
So firework is basically a description of how to spawn particles and what to do when they're at the end of their life time (e.g. spawning new ones).
User avatar
Josh
Inhabitant of a Galaxy
Reactions:
Posts: 2213
Joined: 11 Mar 2017, 17:20
Location: The Netherlands
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Firework

Post by Josh »

I forgot to mension about the frames, added it :bc
TheoTown player since update 1.1.50

Creator of Aldorria, Covinton Empire, West Country, Sunnydale
User avatar
Lakan Haraya
Metropolitan
Reactions:
Posts: 131
Joined: 28 Mar 2019, 07:34
Location: Philippines
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Firework

Post by Lakan Haraya »

@Josh

Please give us more details about those attributes :/ like these following:
How integers on alpha translate on cardinal directions, if it is?
And those variation thingy?

I wonder how...
My fireworks explode immediately on ground and all particles spreads out to the entire city's cake •_• and... beyond :/
"ᜀᜃᜓ ᜀᜅ᜔ ᜁᜌᜓᜅ᜔ ᜑᜇᜌ"
CEO of Haráya Motors

“TheoTown Philippines Council”
“Kapulungan Ng Mga Nagkakaisang Lungsod”
User avatar
PetrovMaksYt
Inhabitant of a Conurbation
Reactions:
Posts: 360
Joined: 16 Aug 2020, 09:26
Plugins: Showcase Store
Version: Beta

Platform

Re: Firework

Post by PetrovMaksYt »

Making fireworks soooooooooooooooo hard...
v.png
You do not have the required permissions to view the files attached to this post.
Started Playing Since 2015
S
Suull13
Settler
Reactions:
Posts: 1
Joined: 14 Feb 2023, 23:45

Re: Firework

Post by Suull13 »

:bd
N
NotPFA
Townsman
Reactions:
Posts: 66
Joined: 28 Jan 2023, 15:34
Plugins: Showcase Store

Plugin Creator

Platform

Re: Firework

Post by NotPFA »

Please don't reply to old threads next time, unless they are unanswered, also check the date and year when the last post was posted before replying. If the thread helped you, react to the post instead of replying.‎@Suull13[Posts][PM]
Subscribe: https://bit.ly/40vXeWP
Join (and share) this discord server: https://discord.gg/geuMNCVbth
Download this plugin: https://bit.ly/3kZ6XVI
User avatar
Seth 15
Villager
Reactions:
Posts: 12
Joined: 11 Jul 2026, 03:20
Location: But that's not how you pronounce it
Plugins: Showcase Store

Re: Firework

Post by Seth 15 »

is it possible to grab the firework building texture from the world texture or is it ok to keep it invisible? :bq
Previous topicNext topic