Possible Attribute Issue in 3.0 Public Release

ggiersdorf

  • Posts: 52
On one of my games I decided to make an attribute called Spawn Speed. I created it as a number default value of 3.0 I than made an event using the every X seconds.

I dragged the spawn speed attribute into the seconds box, and just made a quick on mouse click to reduce the spawn speed by 1.0

I than made a draw spawnspeed on the screen so I could see that it changes properly which it does, however the action in the every x second event only fires to the default 3.0 second even though I reduced the spawnspeed attribute..

If I put a physical value in the box it works as it should but when using an attribute it fails.

Does anyone know a fix for this? Or if this has been fixed in a nightly build??


mikhog

  • Posts: 151
I think you need to use the update event instead and check for time passed since you last fired your event. Every update is 10ms apart so it's quite easy to do. The "fire every N sec" event is probably defined at creation so you can't change the value dynamically. That's what I think anyway.
"It came from the forest!" a zombie defense shooter
http://www.kongregate.com/games/mikhog/it-came-from-the-forest
Also, check out my RPG inventory system on stencyl forge or test it: http://www.stencyl.com/game/play/25268
Current project (hack n slash RPG): http://www.stencyl.com/game/play/25366
I also do Unity development both 2D and 3D

Hectate

  • *
  • Posts: 4645
Whenever you use a "Do Every X Seconds" block, what happens is a repeating event is created that runs independently of the code that created it. As a result, the interval is not changed by reducing the value of the variable that was used to set that interval initially. If X was "3", your new timed task will always use a 3 second interval; even if the variable later changes.
You can check if the variable has changed, however, and create a new timed task with the new value (and cancel the old one).
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

ggiersdorf

  • Posts: 52
Thats odd because I can use that attribute in anything but that Every X second block. So how would I do the checks and change variable Hectate??

Example?

It sounds like your saying create multiple instances of the game under different timer fields? IF Spawn = 1.0 than do these steps
sounds like a lot of redundant work no?

twotimingpete

  • *
  • Posts: 1667
I know this isn't what you asked, but have you considered using delay attributes instead of "do every"? "do every" seems to be a convenience block but can make things sticky if you are trying to use it in the middle of complex and fluid mechanics.

for example.

updating: set numberattribute to decrement by 1
if number attribute <= zero, do thing

then you can just set that attribute to whatever you need and it'll count down to zero and you can easily modify the time until it "fires" again any time you want by changing that numberattribute.

ggiersdorf

  • Posts: 52
Yes I thought of that however this specific game I cant just say every 10 seconds decrease... I need it to once score = x decrease that can be at any time value..


Hectate

  • *
  • Posts: 4645
I dragged the spawn speed attribute into the seconds box, and just made a quick on mouse click to reduce the spawn speed by 1.0
You're using whole seconds; surely if you incremented your timer every second you could know if it meets or exceeds the desired value?

When Created:
Set Timer to 0
Do Every 1 Second
- Increment Timer by 1

Always
If Timer >= Spawn Speed
- Do Spawn
- Set Timer to 0
If Mouse Was Clicked
- Decrement Spawn Speed by 1
- If Spawn Speed < 1
-- You dun goofed.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Photon

  • Posts: 2693
Thats odd because I can use that attribute in anything but that Every X second block. So how would I do the checks and change variable Hectate??
I think your line of thinking might be that the timer is always pointing at the variable, which isn't the reality. Rather its getting a copy of the variable's current value and using that to set up an "indefinite" timer. As such, it doesn't pay attention to when the variable changes. Other statements that use the attribute pull copies as well (this depends on attribute type though) but are often called multiple times. Contrast this with "Do Every X Seconds" which is called once per timer instance. Hopefully that makes sense.

This might explain things in a bit more detail:
http://photongamedev.wordpress.com/2013/08/02/stencyl-for-noobs-timed-events/

Also, this might be helpful to you as well:
http://photongamedev.wordpress.com/2013/06/03/the-do-after-dilemma-building-your-own-time-tracking-mechanic/
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!