How to minimize block repetition?[SOLVED]

vugiabach

  • Posts: 4
Is there a way to minimize creating the same chunk of blocks for attributes that are named in a numerical order? For example, my character can charge and release an attack, the longer they charge, the more powerful the strike will be. The damage of each level of charge is stored in Attributes that are named numerically  (e.g. Damage1, Damage2, etc...), an Attribute (e.g. Strikelvl) holds the level of charge (1,2, 3, etc...) and call for the corresponding DamageX. The problem with this is that I will have to create a similar chunk of blocks for each level of attack, is there a way to minimize this by creating something akin to Damage[Strikelvl]? I have tried looking the problem up but don't know how to word it properly. Attached below this the chunk of block that is curtailed specifically to an individual Attribute.

« Last Edit: March 22, 2020, 05:10:11 am by vugiabach »

Luyren

  • *
  • Posts: 2019
Learn to use lists, and use a manual timer (a number that's counting up) instead of the do after block.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

vugiabach

  • Posts: 4
Hi, does manual timer mean using increment/decrement inside the Updating block? Why is this better than using the 'Do after' block?

Luyren

  • *
  • Posts: 2019
Yes for the increment on the update event. And it's better simply because you can interrupt it if you need, and you can execute your logic based on the progression of the timer. With a "do after" there's no way to interrupt it, and you'd have to go out of your way to retrieve the progress of the do after, probably by tweening a number attribute along with it.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter