Updating attribute

grove

  • Posts: 8
I have a situation where I want the following:

when attribute A passes a number divisible by 100 attribute B increases by 1

I could make a series of code like "if A = 100" and if "A = 200" etc. But that seems cumbersome.
I have made a code that goes "if remainder of A /100 = 0" but this will only increase B if A is exactly divisible by 100. If attribute A jumps from 96 to 102 this won't activate.

Suggestions?

Luyren

  • *
  • Posts: 2747
Code: [Select]
Set B to [floor of (A/100)]That's all you need. Floor is an option in the "round" block.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

grove

  • Posts: 8

grove

  • Posts: 8
Follow up.

This sets attribute B to a fraction of attribute A, using an updating code.
But I can't then add B to attribute C as this results in C rapidly increasing in number. How do I pass B as a static number to C?

Luyren

  • *
  • Posts: 2747
https://youtu.be/j10SMwy2prM
This video should help you understand how the Updating event works, as that seems to be the issue you are having.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

grove

  • Posts: 8
Nope, sorry, that was no help at all.

Luyren

  • *
  • Posts: 2747
Unless you post a screenshot of the code you attempted, there's not much help to be given. There is a camera icon on the bottom right corner of your behavior you can use for that.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter