Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 2115 116 117338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Here.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
map_objects = 0
function player_flashlight()
	for i=1,32,1 do
		id=image("gfx/sprites/flashlight.png",1,1,200+i)
		if i == 1 then map_objects =  id - 1 end
		imagecolor(id,255,255,255)
		imageblend(id,1)
		imagealpha(id,0.5)
		imagescale(id,1,1)
	end
end

player_flashlight()

addhook("startround","player_flashlight")
     
addhook("serveraction","server_serveraction")
function server_serveraction(id,button)
	if (button==1) then
		imagealpha(map_objects+id,0.0)
		parse([[sv_sound "flashlight.wav"]])
	else
		imagealpha(map_objects+id,0.5)
		parse([[sv_sound "flashlight.wav"]])
	end
end

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Oh, yeah, I forgot about that because I thought you wanted it like in the function you gave me >.>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function array(s,v)
	local t={}
	for i=1,s do t[i]=v end
	return t
end

map_objects = 0
flashlight_is_on = array(32,false)
function player_flashlight()
	for i=1,32,1 do
		id=image("gfx/sprites/flashlight.png",1,1,200+i)
		if i == 1 then map_objects = id - 1 end
		imagecolor(id,255,255,255)
		imageblend(id,1)
		imagealpha(id,0.5)
		imagescale(id,1,1)
		flashlight_is_on[id] = false
	end
end

player_flashlight()

addhook("startround","player_flashlight")

addhook("serveraction","server_serveraction")
function server_serveraction(id,button)
	if (button==1) then
		flashlight_is_on[id] = not flashlight_is_on[id]
		if flashlight_is_on[id] then
			imagealpha(map_objects+id,0.5)
		else
			imagealpha(map_objects+id,0.0)
		end
		parse([[sv_sound "flashlight.wav"]]) 
	end
end
edited 1×, last 13.12.09 04:55:02 am

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
You mean, the hook "movetile"?
info.txt has written
movetile(id,x,y)                         on moving on a different tile
-id: id of player who reached a new tile
-x: new tile x position (tiles)
-y: new tile y position (tiles)

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
@Starkkz
It's duplicate, you can't use functions or values names of used hooks.
1
2
3
:notok: addhook("[b]move[/b]","[b]move[/b]") 

:ok: addhook("move","move[b]s[/b]")

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
What is this?

1
attempt to concatenate a boolean value

I got this error when I test some lua script, and I don't what exactly that problem

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
@Admirdee
Boolean valuable returns only true (1) or false (0)
Probably you are using Boolean as normal valuable, that's problem.

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Hey guys, maybe I'm high/drunk but does setting an image's position exactly over another one (same x and y) delete the old one?
I've tried something like this:
1
2
3
4
5
addhook("projectile","flackos_projectile")
function flackos_projectile(id,wep,x,y)
	img = image("gfx/paintball/stain"..rsp..".bmp",0,0,0)--Global variable (!)
	imagepos(img,x,y,player(id,"rot"))
end

If I throw two or more snowballs exactly in the same position, the old sprite is deleted, and the new image gets the id of the old one.

old Re: Lua Scripts/Questions/Help

Starkkz
Moderator Off Offline

Quote
i need help with this buildings..

Quote
T = Turret
W = Wall III
P = Player Coordinates/Position.
G = Gate Field

TwGwT
W___W
G_P_G
W___W
TwGwT


how can i do that. but in command
Spawnobject. ( lua )

old Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Quote
use:
You must set id as player.
1
2
x=player(id,"tilex")
y=player(id,"tiley")
And parse("spawnobject "..x|+- value you want to spawn from player|.." "..y|+- value you want to spawn from player|.." |other stuff, see in cs2d help(server commands) and here|")

old Re: Lua Scripts/Questions/Help

Starkkz
Moderator Off Offline

Quote
i not copy it. the reason is i don't know how to do
spawnobject "..x.."-2

for example. it doesn't work.

thx Vectar666

old Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Quote
parse("spawnobject 8 "..x-2.." "..y-2.." 0 "..player(id,"team").." "..id)
It will spawn a turret(8) in tile x and y, with mode 0(i dont know whats this). Turret is for team of player, and created by player.
If it is not working, try not tilex, tiley, but just pixel x and y.
To do with pixels, replace this:
1
2
x=player(id,"tilex")
y=player(id,"tiley")

to this:
1
2
x=player(id,"x")
y=player(id,"y")
and make not x-2 or y-2, but x-64 or y-64
To the start Previous 1 2115 116 117338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview