Forum

> > CS2D > Scripts > Can't get tile info
Forums overviewCS2D overview Scripts overviewLog in to reply

English Can't get tile info

8 replies
To the start Previous 1 Next To the start

old Can't get tile info

KimKat
GAME BANNED Off Offline

Quote
I have a Lua script problem here. For some reason I can't get the tile info I need when player steps on a tile (such as water). I want to make players slowed down when they are stepping on water tiles (any). I've tried like anything, here's my result...
Spoiler >

old Re: Can't get tile info

JONY
User Off Offline

Quote
I would check the frame number for tile and not the property. And then you can check with editor what frame number is water and slow the player.
Btw on movetile you don't need to check if player exists

old Re: Can't get tile info

EngiN33R
Moderator Off Offline

Quote
Well, I may not understand something, but why are your ifs written like that:
1
if (_tile == (nums[0] and usgn>=0)) then

Why nums[0] and usgn>=0 are put in brackets? You can do it like
1
if (_tile == nums[0] and usgn>=0) then
It wouldn't break the code, but I think you planned something else...

old Re: Can't get tile info

KimKat
GAME BANNED Off Offline

Quote
JONY has written
I would check the frame number for tile and not the property. And then you can check with editor what frame number is water and slow the player.
Btw on movetile you don't need to check if player exists
But would really need a detailed explanation on what the tile(frame, property, walkable, deady, wall, obstacle, entity) values are. I'd like some examples on how to use it especially since the info.txt in the Lua folder of CS2D lacks info on how to use the tile(x,y,"value") that resides in the info.txt. No examples just plain hook and parameters.

EngiN33R you're right about that... I just thought it was somehow good to preserve the variables into their seperate brackets so that they live happy together, lol. I don't really know it's just my kind of scripting style. I know I've done something wrong in the script, I'm trying to figure it out... but I'd really just need some detailed information about the tile() function, how do I know what water tile is? I just really need that information.

old Re: Can't get tile info

SQ
Moderator Off Offline

Quote
Something like that?
It's only +few lines to make different speed levels for each tile prop.

By the way, for what purpose have you added "get_pairs" and array function?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
TileMaterial = {
	[0] = "Floor: Soundless",
	[1] = "Wall",
	[2] = "Obstacle",
	[3] = "Wall/ No Shadow",
	[4] = "Obstacle / No Shadow",
	[10] = "Floor: Dirt",
	[11] = "Floor: Snow",
	[12] = "Floor: Step",
	[13] = "Floor: Tile",
	[14] = "Floor: Water",
	[15] = "Floor: Metal",
	[16] = "Floor: Wood",
	[50] = "Deadly: Normal",
	[51] = "Deadly: Explosion",
	[52] = "Deadly: Toxic",
	[53] = "Deadly: Abyss"
	}

addhook("movetile","MoveTileHook")
function MoveTileHook(ID,X,Y)
	parse('hudtxt2 '..ID..' 2 "©102255102TILE: '..TileMaterial[tile(X,Y,"property")]..'" 320 220 1')
end

old Re: Can't get tile info

KimKat
GAME BANNED Off Offline

Quote
I previously used it in the array, just forgot or thought I still needed it. Which I clearly don't, lol. Anyways, thanks Blaze for sharing the tile info, and I know about the speed thingies, unless you mean another method of doing it.

Basicly I need just the TileMaterial together with number 14 how do I combind that in a script?

For instance when the player walks over some water tiles the player would get slowed down, how do I do that using your array? it's quite confusing.

old Re: Can't get tile info

SQ
Moderator Off Offline

Quote
It's not confusing.
Here you can set different speed for each tile in "TileSpeed" table.

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
TileMaterial = {
	[0] = "Floor: Soundless",
	[1] = "Wall",
	[2] = "Obstacle",
	[3] = "Wall/ No Shadow",
	[4] = "Obstacle / No Shadow",
	[10] = "Floor: Dirt",
	[11] = "Floor: Snow",
	[12] = "Floor: Step",
	[13] = "Floor: Tile",
	[14] = "Floor: Water",
	[15] = "Floor: Metal",
	[16] = "Floor: Wood",
	[50] = "Deadly: Normal",
	[51] = "Deadly: Explosion",
	[52] = "Deadly: Toxic",
	[53] = "Deadly: Abyss"
	}

TileSpeed = {[0] = 0,[1] = 0,[2] = 0,[3] = 0,[4] = 0,[10] = 0,
	[11] = 0,[12] = 0,[13] = 0,[14] = -20,[15] = 0,
	[16] = 0,[50] = 0,[51] = 0,[52] = 0,[53] = 0}

addhook("movetile","MoveTileHook")
function MoveTileHook(ID,X,Y)
	local Prop = tile(X,Y,"property")
	local SP = player(ID,"speedmod")
	local NewSP = TileSpeed[Prop]
	if (SP ~= NewSP) then parse("speedmod "..ID.." "..NewSP) end
	parse('hudtxt2 '..ID..' 2 "©102255102TILE: '..TileMaterial[Prop]..'" 320 220 1')
end

old Re: Can't get tile info

DC
Admin Off Offline

Quote
btw:
1
if (_tile == (nums[0] and usgn>=0)) then
is nonsense in this context.
(nums[0] and usgn>=0) can only be true or false (due to the logical and).

so you are checking if the tile property (_tile) is either true or false. all the time. that doesn't make sense because _tile is not even a boolean value but a number.

changing the brackets in logical terms will change the logical terms and their meaning (in most cases). don't add random brackets if you don't understand what you're doing.

the TileMaterial table/array posted by BlazingEyed contains alle the different values that tile(x,y,"property") can return + their descriptions.

example: tile(x,y,"property") will return 14 if the tile is water

old Re: Can't get tile info

KimKat
GAME BANNED Off Offline

Quote
I see... so tile(x,y,"value") only returns the values of the tile that the player currently stands on, basicly. I also realised that I failed quite miserably on the scripting part too, lol. My bad.

Anyways, I think there's no need for the thread no more as my questions has been answered. Thanks.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview