Jump to content

Is there a function to get the tile type the player is on?


Sykriss

Recommended Posts

 

That gives the coordinates (which solves one problem), but doesn't tell me what kind of tile (grass, dirt, asphalt, etc) is at those coordinates - which is essential to the functionality of the mod I plan on making using this method.

Link to comment
Share on other sites

function ayyLmao()	local wz = getPlayer():getZ();	local wx, wy = ISCoordConversion.ToWorld(getPlayer():getX(), getPlayer():getY(), wz);	wx = math.floor(wx);	wy = math.floor(wy);	local cell = getWorld():getCell();	local sq = cell:getGridSquare(wx, wy, wz);	local sqObjs = sq:getObjects();	local sqSize = sqObjs:size();	for i = sqSize-1, 0, -1 do		local obj = sqObjs:get(i);		print(obj:getSprite():getName())	endend

 

Something like this?

Link to comment
Share on other sites

easier way is:

getPlayer():getCurrentSquare(); -- single player only

or

getSpecificPlayer(player):getCurrentSquare(); -- for multiplayer and single player

where 'player' is the number provided it most cases.
 
with using ethanwdp's example you get:

function ayyLmao(player)	local sq = getSpecificPlayer(player):getCurrentSquare();	for i=0, sq:getObjects():size()-1 do		local obj = sq:getObjects():get(i);		print(obj:getSprite():getName())	endend
Link to comment
Share on other sites

  • 8 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...