question about coding to change elements????

Talk about making games.

question about coding to change elements????

Postby tinkergnome » Mon Sep 03, 2012 8:17 pm

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
User avatar
tinkergnome
 
Posts: 16
Joined: Wed Oct 12, 2011 5:11 pm
Score: 1 Give a positive score

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

Postby skydereign » Tue Sep 04, 2012 1:32 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

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

Postby tinkergnome » Fri Sep 07, 2012 7:18 pm

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.
User avatar
tinkergnome
 
Posts: 16
Joined: Wed Oct 12, 2011 5:11 pm
Score: 1 Give a positive score

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

Postby tinkergnome » Fri Sep 07, 2012 7:36 pm

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.
User avatar
tinkergnome
 
Posts: 16
Joined: Wed Oct 12, 2011 5:11 pm
Score: 1 Give a positive score

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

Postby skydereign » Fri Sep 07, 2012 7:40 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

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

Postby tinkergnome » Fri Sep 07, 2012 7:54 pm

thanks again skydereign...
User avatar
tinkergnome
 
Posts: 16
Joined: Wed Oct 12, 2011 5:11 pm
Score: 1 Give a positive score

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

Postby Fojam » Sat Sep 08, 2012 2:42 pm

wait so the CreateTimer points to a integer variable? i did not know that...
CLICK TO GIVE ME POINTS

My Latest Projects:
Super Smash Bros: viewtopic.php?f=6&t=12307 PLEASE help by making sprites!
User avatar
Fojam
 
Posts: 513
Joined: Thu Mar 19, 2009 10:02 pm
Location: under your bed!!!
Score: 69 Give a positive score

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

Postby skydereign » Sat Sep 08, 2012 7:43 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest