So I’m trying to create a function or series of functions that will add status effects to the player character that drain stamina and health over time, but only stay active for a certain amount of time. E.g. drain health by 1/s for 6 seconds.
The issue i’m having is wanting to have these stackable so at one point they can have an affect added that drains 1 health/s for 6 seconds then after 3 seconds have another one added so the player will drain 1 health drained for 3 seconds, then 2 health for another 3 seconds, then 1 health for another 3 seconds. I’ve tried using timers so far but with no luck.
I’m also attempting to replicate the functionality of printing to the console for messages to the player that appear for a certain amount of time. I’ve got something working that stacks and orders a text array, the elements of which are bound to 5 text boxes in a player hud. the issue again is with making them go away after x seconds. I’ve tried using timers again but it only works for one of the 6 text boxes.
this adds a message to the text boxes to test them, the printing is just for testing too
the function in the timer is simply counts to 20 over 2 seconds then calls the cancel timer event.
This is my function to add the messages to the text array variable
it works perfectly and stacks them downwards so the last message added is at the top of the display.
this is the function i currently have set up to remove the message items
My intention is to use something similar for the status effects
I see one issue with your code on screen 1.
Node outputs are cleared once scope of call (of event of function) is finished, so clear timer node is geting unused timer handler and it will fail. It probably outputs errors in the logs because of. You should store headler in to variable, if you don’t store it you will lose control over timer when scope that you set the timer in will finish
If you ever did any kind of text programming, outputs are like local varables, they are cleared and lost once scope (the brackets) they are declared in is finished
Not sure if this is related to your problem, so for now i post this as comment
i think i understand, i will promote to a variable and see what happens but is the scope the hadler is declared in the execute line from from my ‘x key event’ until it finishes.
i know i’ve had timers set and canceled like this running on seperate events before with no problem without storing the handle as a variable. and i also have print nodes in the count time function and they print on end until the clear timer node is triggered at which point the timer stops running.
there are no errors in the log with this.
I’ve updated it to look like this (i think this is what you meant) but it functions exactly the same as before. I think because the timer is looping the handle isn’t cleared because it runs until it’s told not to.
So i’ve updated the messages functions so that it gets the current value of the time counter variable (formerly new var 0) stores it to an array to use that as the new time.
This works mostly and stores the difference between messages to count down that instead.
if one message is cleared, and then another added before the stack clears, however, it breaks, and the messages added before the stack clears don’t disappear
Print Time function
store time and add message text
input to add messages and clear timer in event graph
I’m honestly not that sure what i’ve done here i did most of it between the hours of 2 and 5am and i’ve been staring at it for so long it’s starting to not make sense