Forum

> > CS2D > Scripts > Image functions timer.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Image functions timer.

11 replies
To the start Previous 1 Next To the start

old Image functions timer.

Mora
User Off Offline

Quote
Hello again us
Just i tryed to do somethings with image that owned by timer(their funct)
1
timer(5000, 'ipervu',id)
Normal
1
2
3
4
timer(5000,'imagealpha',iperv,0.5)
timer(5000,'tween_alpha',iperv, 2000, 1.0)
timer(10000,'tween_alpha',iperv, 2000, 0.0)
timer(12000, 'freeimage',iperv)
1
LUA ERROR: bad argument #1 to '?' (number expected, got string)
What to do with?
also this error happened all the time after 2 sec.
Thank you

old Re: Image functions timer.

Dousea
User Off Offline

Quote
It needs the full code to see the source of "2 seconds loop" problem, user Mora. Well cs2d lua cmd timer transforms the argument to string as it mentioned somewhere, what you need is changing the type using tonumber function. After that you trying to send more than one argument to the function. It will be passed as cs2d lua cmd timer's "count" argument. What you need is to delete the rest of argument and using one function to do all your commands.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
timer (5000, "imagesettings")

function imagesettings ()
	imagealpha (iperv, 0.5)
	tween_alpha (iperv, 2000, 1.0)
	timer (5000, "imagesettingsfadeout")
	
	function imagesettingsfadeout ()
		tween_alpha (iperv, 2000, 0.0)
		timer (2000, "imagesettingsdeleteimage")
		
		function imagesettingsdeleteimage ()
			freeimage (iperv)
		end
	end
end
edited 1×, last 04.08.14 11:47:14 am

old Re: Image functions timer.

Mora
User Off Offline

Quote
@user Dousea: can it be like:
1
2
3
4
5
6
7
8
9
10
timer (5000, imagesettings)

function imagesettings ()
     tween_alpha (iperv, 2000, 1.0)
     timer (5000, imagesettingsfadeout)

     function imagesettingsfadeout ()
          tween_alpha (iperv, 2000, 0.0)
     end
end
So is better, as someone tell me...
1
LUA ERROR: sys/lua/teatr.lua:84: bad argument #2 to 'timer' (string expected, got nil)
Thank you @user Dousea:
and one:
When it do require tonumber?
as in this is:
http://www.unrealsoftware.de/forum_posts.php?post=374211&start=0

old Re: Image functions timer.

Dousea
User Off Offline

Quote
Sorry, fixed the code up there. Well it requires tonumber function when you need it. Something like table will require it too if you want to change something with "index".

old Re: Image functions timer.

Mora
User Off Offline

Quote
@user MikuAuahDark: u're so pro and ur timer is good:) but i need timer as test, not for mods, global things, just a little Cinema script :<
@user Dousea: Thank you so much good people you did help me a lot.

old Re: Image functions timer.

MikuAuahDark
User Off Offline

Quote
what do you mean as test?
do you mean usage example?

1
2
3
4
5
6
-- install timerEx.lua as usual script

addhook("spray","_spray")
function _spray(id)
	timerEx(5000,msg2,1,id,"This message is shown 5 seconds later!")
end

5000 = time in ms
msg2 = the cs2d lua cmd msg2 function(you can add quote if you want)
1 = count, execute x times.
id = player id
and then you already know the last arguments.

then how do i free the timer? simple
1
2
3
4
-- somewhere at your script
timer_id=timerEx(...)
-- later
fretimerEx(timer_id)

old Re: Image functions timer.

Mora
User Off Offline

Quote
@user MikuAuahDark: not, i mean i need standart timer for test one script(mi maki this scpetz) that use images.
I do understand it now and dont need others, even if it is more easy...
Huh i guess my englis is understandable...
Miku >


Someone know what here is wrong?
1
2
3
4
5
6
7
8
9
10
11
12
13
function zak()
timer (62000, "imzaks")
function imzaks ()
     tween_alpha (izzat, 2000, 1.0)
msg("©100100255 We won the battle of LA, but too many children were killed there...")
msg("©100100255 Our base was destroyed. The war continues.")
     timer (74000, "imfadezaks")

     function imfadezaks ()
          tween_alpha (izzat, 2000, 0.0)
     end
end
end
edited 2×, last 04.08.14 04:17:11 pm

old Re: Image functions timer.

Mora
User Off Offline

Quote
@user MikuAuahDark: but others is works:
1
2
3
4
5
6
7
8
9
10
11
12
function tree()
timer (36000, "imtrees")
function imtrees ()
     tween_alpha (itri, 2000, 1.0)
msg("©100100255 Well. All living things? OK.")
msg("©100100255 Nominated to a police Department, the General said there is the command center.")
     timer (46000, "imfadetrees")
     
     function imfadetrees ()
          tween_alpha (itri, 2000, 0.0)
     end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview