View unanswered posts | View active topics It is currently Thu Dec 26, 2024 6:12 pm



Reply to topic  [ 4 posts ] 
 Timer troubles 
Author Message
User avatar

Joined: Mon Jun 28, 2010 10:06 pm
Posts: 461
Location: STEPPING INTO THE RING
Reply with quote
Post Timer troubles
First of all, you attach a script with
Code:
ScriptFile = ContentFile
[tab]FilePath = pathandstuff

right?
Second of all
a timer would go like
Code:
function Create(self)
[tab]self.timer = Timer()
end

function Update(self)
codeandsuch
[tab]timer.TimeTillSimMS(#s)
end

right?

Finnaly how would i reset that and maybe make a cooldown sequence so you cant exploit the code to constantly use the code controlled by said timer?


Sat Mar 05, 2011 1:25 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Timer troubles
You attached the script wrongly.

To attach you simply use ScriptPath = Mod.rte/Bla/TheFile.lua

Now, one thing with lua is that tabbing doesn't really matter.

And to reset timers you use TimerName:Reset();


Sat Mar 05, 2011 1:35 am
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Timer troubles
Tabbing doesn't matter to the parser, but it does matter for readability. I'm way more likely to help somebody whose code is tabbed and readable (or, hey, you could even put in comments) than if their code is a big lump of characters.
Anyway, back on-topic:
Your Update function wouldn't do anything, currently - Timer:LeftTillSimMS() returns how long it'll be before a time is reached (in milliseconds). As well, you left out the "self." before the timer. As well, make sure that when you're calling a function, you use ":", not ".". This code would work, if you want the code to execute when 3 seconds has passed:
Code:
function Create(self)
[tab]self.timer = Timer()
end

function Update(self)
[tab]if self.timer.IsPastSimMS(3000) then
[tab][tab]<do something>
[tab]end
end


Sat Mar 05, 2011 1:54 am
Profile WWW
User avatar

Joined: Mon Jun 28, 2010 10:06 pm
Posts: 461
Location: STEPPING INTO THE RING
Reply with quote
Post Re: Timer troubles
EDIT: ninja'd

ok I will try that


Sat Mar 05, 2011 2:00 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.257s | 13 Queries | GZIP : Off ]