Forum

> > CS2D > Scripts > About X,Y Position
Forums overviewCS2D overview Scripts overviewLog in to reply

English About X,Y Position

10 replies
To the start Previous 1 Next To the start

old About X,Y Position

X-Files
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
addhook("minute","sample.tm.minute91") 
function sample.tm.minute91(id)
x = player("id, tilex")
y = player("id, tiley")
t = player("id, tilex")+1
z = player("id, tiley")
	if tile(x,y, 'frame') == 2 and tile(t,z, 'frame') == 63 then
	spawnitem(6, x, y, 1)	
end	
end

this is for tibia and
i need to take x,y position of tile which is frame 2 and next frame is 63
but without use =player("id, tilex") code
because that code working only if player walks on x,y coordinate
but i want to use it without walking of player

problem is how can i take x,y coordinate of tile without using =player("tilex")
edited 2×, last 16.08.14 07:02:37 pm

old Re: About X,Y Position

Zeik
User Off Offline

Quote
@user X-Files: The coordinates of what tile you want to get? is not clear.

Don't know what you're trying to do but that code you wrote is wrong.

The function cs2d lua cmd player needs "id" as first parameter.
× player("tilex")
√ player(id, "tilex")
(unless it's a function from the tibia script)

The hook cs2d lua hook minute doesn't receive any parameter so:
× function sample.tm.minute91(id)
√ function sample.tm.minute91()

old Re: About X,Y Position

X-Files
User Off Offline

Quote
@user Zeik:yes its wrong its doesnt matter, i want get coordinates of tile which is has frame with id 2, and next tile has to be id 63
but i cant use =player("id, tilex") code
cause it just triggering by player act, but i want to do it different way.
for example if i use the lua i showed up there, its just working when player move on proper tile, but i need to do it without player act, it has to be triggered automaticly in every minute

old Re: About X,Y Position

Rainoth
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
-- minute hook
for a=0, map("xsize") do
	for b=0, map("ysize") do
		local c = a + 1
		if tile(a,b,"frame") == 2 and tile(c,b,"frame")==63 then
			msg("there's an instance of tile frames 2 and 63 being near one another at "..a.."|"..b)
		end
	end
end

old Re: About X,Y Position

Zeik
User Off Offline

Quote
@user Rainoth: isn't it a bit heavy?

@user X-Files I'm not sure that you're being clear about what you want.
What I understood is that you want to spawn an item in the position (x, y) every minute automatically (not triggered by a player)
If so then you just have to use the spawnitem(?) function in (x, y).

old Re: About X,Y Position

Rainoth
Moderator Off Offline

Quote
@user Zeik: Yes but he wants the item to spawn only on tile frame 63 if there's tile 2 on the right of it.

I don't see how it's heavy. Just loops the whole map.

old Re: About X,Y Position

Zeik
User Off Offline

Quote
@user X-Files:
1
2
3
4
addhook("minute","sample.tm.minute91")
function sample.tm.minute91()
     spawnitem(6, x, y, 1)
end

Just change x and y for the ones corresponding to the tile..
That's only if you want to spawn items just in that tile.

If not, use @user Rainoth's code. But note that his code is just checking for the tile at the right, and not all the surrounding ones.

Note: I don't know the function "spawnitem", but I assume that x and y are the coordinates of the tile in which the item is going to spawn.

old Re: About X,Y Position

X-Files
User Off Offline

Quote
@user Zeik: dude how i ll make that codes recognizes frames of tiles ? thats the important part, your codes doesnt work for that.

1
2
3
4
5
6
addhook("minute","sample.tm.minute91")
function sample.tm.minute91()
          if tile(x,y,"frame") == 2 and tile(t,y,"frame")==63 then 
       spawnitem(6, x, y, 1)
end
end
it has to be something like this, but x,y,t values are nil

old Re: About X,Y Position

Zeik
User Off Offline

Quote
I can't understand what you want but whatever, use @user Rainoth:'s code if you want to check if any of all the tiles in the map satisfy the condition.
edited 1×, last 16.08.14 10:49:10 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview