Forum

> > CS2D > Scripts > Under water breath function.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Under water breath function.

15 replies
To the start Previous 1 Next To the start

old Under water breath function.

J4x
User Off Offline

Quote
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
edited 3×, last 27.01.11 10:18:37 pm

old Re: Under water breath function.

Yasday
User Off Offline

Quote
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.

old Re: Under water breath function.

KimKat
GAME BANNED Off Offline

Quote
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.

old Re: Under water breath function.

KimKat
GAME BANNED Off Offline

Quote
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.

old Re: Under water breath function.

J4x
User Off Offline

Quote
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

old Re: Under water breath function.

KimKat
GAME BANNED Off Offline

Quote
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 >

old Re: Under water breath function.

J4x
User Off Offline

Quote
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?

old Re: Under water breath function.

Yasday
User Off Offline

Quote
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...

old Re: Under water breath function.

KimKat
GAME BANNED Off Offline

Quote
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?

old Re: Under water breath function.

J4x
User Off Offline

Quote
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)

old Re: Under water breath function.

palomino
User Off Offline

Quote
FN_Linkin Park has written
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.

old Re: Under water breath function.

J4x
User Off Offline

Quote
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")
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview