Proper use of timers

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
Matokage
Slime Knight
Posts: 275
Joined: Sat May 26, 2012 11:48 pm
Contact:

Proper use of timers

Post by Matokage »

I'm building a script where after certain time it decrements a variable at an X value, but when i run the script it simply overload

Code: Select all

plotscript,wearing,begin
	decrement (stamina,1)
	decrement (watermeter,1)
	decrement (foodmeter,1)
	set timer (0,5,18,wearing)
end
I Also tried

Code: Select all

plotscript,wearing,begin
	decrement (stamina,1)
	decrement (watermeter,1)
	decrement (foodmeter,1)
	timer

plotscript,timer,begin
	set timer (0,5,18,wearing)
end
But it overloaded too.

What am I doing wrong?
"I can't buy food with glory"
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

"wearing" calls the script called "wearing". You need to write "@wearing", which is the ID number of the wearing script. You should only call settimer in the wearing script if you want the script to be triggered repeatedly every 5 seconds.

Code: Select all

script,wearing,begin
   decrement (stamina,1)
   decrement (watermeter,1)
   decrement (foodmeter,1)
end

plotscript,timer,begin
   set timer (0,5,18,@wearing)
end
User avatar
Gizmog
Metal King Slime
Posts: 2622
Joined: Tue Feb 19, 2008 5:41 am

Post by Gizmog »

TMC wrote: You should only call settimer in the wearing script if you want the script to be triggered repeatedly every 5 seconds.
would that not be the case for a system where you get hungrier and tireder and thirstier?
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Probably, but what did he mean by "decrements a variable at an X value" anyway?
User avatar
Gizmog
Metal King Slime
Posts: 2622
Joined: Tue Feb 19, 2008 5:41 am

Post by Gizmog »

I think the problem is he's hitting the script interpreter's limit for circular calls? As for his statement I think he means he wants a script where every 5 seconds you get hungrier, thirstier/whatever.
User avatar
Matokage
Slime Knight
Posts: 275
Joined: Sat May 26, 2012 11:48 pm
Contact:

Post by Matokage »

Gizmog wrote:I think the problem is he's hitting the script interpreter's limit for circular calls? As for his statement I think he means he wants a script where every 5 seconds you get hungrier, thirstier/whatever.
Well, giz, you got the idea. [s]Is there any example script for this somewhere?[/s]
I see that TMC has posted a example, let me test that and will report in a minute.

Reporting
[s]Time Passes but the values stays the same, it just decremented once[/s]
Fixed that
finally understand what to do. Thanks dudes!
Last edited by Matokage on Wed Feb 25, 2015 3:01 pm, edited 3 times in total.
"I can't buy food with glory"
Post Reply