Page 1 of 1

question about coding to change elements????

PostPosted: Mon Sep 03, 2012 8:17 pm
by tinkergnome
hello there ....

i was wondering about what type of scripting could be used to change the interval speed of a timer??
example: say for instance i've created a timer & named it xyz with an interval of 250MS and then under
actions for a specific actor it would relate to.... wanted to have a keydown event to change the speed
+ or - 250 MS? how can i do that. or if expressing a keypress thru the timer actions with a scripting
item in code ????

i had an idea (perhaps completely wrong) about it in code:

if (keypress(key_z) == TRUE)
{
(xyz.time=xyz.time-25);
}
// the lower the interval number,... the faster the timer will move....

if anyone could let me know how i can do this,...... i'd be ever so thankful!!! :D

Re: question about coding to change elements????

PostPosted: Tue Sep 04, 2012 1:32 am
by skydereign
You can't change the default timer value, but you can actually change the length. Assuming timer has a length of 2000, you can still do this to trigger timer with only 1000ms.
Code: Select all
CreateTimer("Event Actor", "timer", 1000);

So, you can just use a variable, and whenever you call the CreateTimer for that timer, just use your variable. From there increasing the length and decreasing it is easy.

Re: question about coding to change elements????

PostPosted: Fri Sep 07, 2012 7:18 pm
by tinkergnome
thank you skydereign..... i'll take a close look at this. its very good to have you in the forum to help me out.
its very much appreciated, since i dont know everything.

Re: question about coding to change elements????

PostPosted: Fri Sep 07, 2012 7:36 pm
by tinkergnome
ok ? i just tried to do something with that ....... how .. exactly could someone change the timer length with a key down
type event..... i'm trying to figure it out.

Re: question about coding to change elements????

PostPosted: Fri Sep 07, 2012 7:40 pm
by skydereign
Any event that creates the some_timer
Code: Select all
CreateTimer("Event Actor", "some_timer", some_timer_length); // some_timer_length is a global variable

Key Down A -> Script Editor
Code: Select all
some_timer_length+=1000; // increases the length of the timer by one second

You can reduce the timer by subtracting from the variable, and you can set it to the length you want by setting it equal to something.

Re: question about coding to change elements????

PostPosted: Fri Sep 07, 2012 7:54 pm
by tinkergnome
thanks again skydereign...

Re: question about coding to change elements????

PostPosted: Sat Sep 08, 2012 2:42 pm
by Fojam
wait so the CreateTimer points to a integer variable? i did not know that...

Re: question about coding to change elements????

PostPosted: Sat Sep 08, 2012 7:43 pm
by skydereign
CreateTimer doesn't point to anything (its return value is an integer). You can pass it an int variable though, which allows you to change the length of the timer when it is called.