Forum

> > CS2D > Scripts > Under water breath function.
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Under water breath function.

15 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Under water breath function.

J4x
User Off Offline

Zitieren
Why this dont work?
1
2
3
4
5
6
addhook("movetile","breath")
function breath(id,x,y)
if tile(x,y,"property") == "water" then 
timer(1000,"parse","slap "..id.." 5")
end
end
3× editiert, zuletzt 27.01.11 22:18:37

alt Re: Under water breath function.

Yasday
User Off Offline

Zitieren
The x and y in the move hook is in pixels, the tile function needs x and y in tiles. Should be something like tile(math.floor(x/32),math.floor(y/32),"property")

Edit:
Didn't realize you used the movetile hook. Sorry.

tile(x,y,"property") returns a number, not a string.

alt Re: Under water breath function.

KimKat
GAME BANNED Off Offline

Zitieren
Blaze helped me out earlier with a similar Lua. Have a go at this...
Spoiler >
I think it works, but I am not sure. Please try it anyways.

alt Re: Under water breath function.

KimKat
GAME BANNED Off Offline

Zitieren
Strange, it's either the timer or the function z that is wrong. I have no idea why it doesn't work.

Perhaps replacing "z==14" with "tile(x,y,"property")==14" (without the quotes) will do, small things can have big impact.
I am not certified Lua learner though, but at least I try.

alt Re: Under water breath function.

J4x
User Off Offline

Zitieren
Edit: i solve it, i simplify the kimkat´s code
1
2
3
4
5
6
7
8
9
TileMaterial = {
[4] = "water" 
}
addhook("movetile","breath")
function breath(id,x,y)
if tile(x,y,"property") == 4 then
timer(1000,"parse","slap "..id.." 5")
end
end
thx very much for your help guys

alt Re: Under water breath function.

KimKat
GAME BANNED Off Offline

Zitieren
It doesn't look right though. Tile property 4 isn't that...

1
[4] = "Obstacle (No Shadow)"
How does it all make sense?! Lua logic is fail logic, if that occurs something is wrong.

Someone explain to me why the tile property 4 is the tile property water. When it's a obstacle with no shadow.

That makes no sense.
Spoiler >

alt Re: Under water breath function.

J4x
User Off Offline

Zitieren
Wait, so that number are not random ones? where do u find which number is each tile property? lol, i will corect it

1
2
3
4
5
6
7
8
9
TileMaterial = {
[14] = "water"
}
addhook("movetile","breath")
function breath(id,x,y)
if tile(x,y,"property") == 14 then
timer(1000,"parse","slap "..id)
end
end
is this correct?

alt Re: Under water breath function.

Yasday
User Off Offline

Zitieren
1
2
3
4
5
6
addhook("movetile","breath")
function breath(id,x,y)
if tile(x,y,"property") == 14 then
timer(1000,"parse","slap "..id.." 5")
end
end

should work...

alt Re: Under water breath function.

KimKat
GAME BANNED Off Offline

Zitieren
Yasday's script should indeed be absolutely functional as tile property 14 is water. But just to be sure could someone confirm that this works?

alt Re: Under water breath function.

J4x
User Off Offline

Zitieren
it will not work because of this
1
timer(1000,"parse","slap "..id.." 5")
in cs2d the slap just ask the id not the power so it the correct code is
1
timer(1000,"parse","slap "..id)

alt Re: Under water breath function.

palomino
User Off Offline

Zitieren
FN_Linkin Park hat geschrieben
it will not work because of this
1
timer(1000,"parse","slap "..id.." 5")
in cs2d the slap just ask the id not the power so it the correct code is
1
timer(1000,"parse","slap "..id)

It's the same thing, but HP won't go down. "5" is the quantity of lost HP.

alt Re: Under water breath function.

J4x
User Off Offline

Zitieren
no its not the same thing i used this and the console says me : player 1,5 not found
1
timer(1000,"parse","slap "..id.." 5")
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht