Forum

> > CS2D > Scripts > Timer never comes back
Forums overviewCS2D overview Scripts overviewLog in to reply

English Timer never comes back

4 replies
To the start Previous 1 Next To the start

old Timer never comes back

Mami Tomoe
User Off Offline

Quote
Hi!
I need help with.... LUA!
OK so this is a timer that will call a function after 2 minutes and 22 seconds:

1
timer(133200,"themeOver",tonumber(id))

This is the function:
1
2
3
function themeOver(id)
	themePlaying[tonumber(id)]=false
end

But my problem is that the song is finished but the timer never calls the function!

old Re: Timer never comes back

Bowlinghead
User Off Offline

Quote
Try:
1
timer(133200,"themeOver",""..id.."")
(parsing parameter as string)

• You already have tonumber() in your function
cs2d.net has written
Moreover it can pass an optional string parameter ("parameter") to this function
edited 1×, last 15.04.17 08:23:27 pm

old Re: Timer never comes back

Mami Tomoe
User Off Offline

Quote
More >


Hi, instead of creating a new topic I will use this one instead.
I have the same problem again with this:
1
2
3
4
5
6
7
8
9
if isNight()==false then
			parse("sv_sound2 "..id.." terraria/themes/01 - Overworld Day.ogg")
			themePlayingDay[id]=true
			timer(140000,"themeOverDay",""..id.."")
		else
			parse("sv_sound2 "..id.." terraria/themes/03 - Overworld Night.ogg")
			themePlayingNight[id]=true
			timer(120000,"themeOverNight",""..id.."")
		end
And I use what you told me
please help!
edited 1×, last 08.05.17 07:19:40 pm

old Re: Timer never comes back

Cloudy71
BANNED Off Offline

Quote
You can also try inserting
tostring(id)
as parameter and in the timer's function use
1
2
id = tonumber(id)
themePlayingDay[id] = false
It should work. If it won't, there's probably another mistake.

Using
""..id..""
is really NOT working example.

old Re: Timer never comes back

Mami Tomoe
User Off Offline

Quote
This worked:
1
2
3
4
5
6
7
8
9
if isNight()==false then
			parse("sv_sound2 "..id.." terraria/themes/01 - Overworld Day.ogg")
			themePlayingDay[id]=true
			timer(140000,"themeOverDay",id)
		else
			parse("sv_sound2 "..id.." terraria/themes/03 - Overworld Night.ogg")
			themePlayingNight[id]=true
			timer(120000,"themeOverNight",id)
		end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview