Jump to content

Recommended Posts

So I've figured out how to convert world tiles to other types by looking at terraformer.lua, but one thing I've been trying to figure out is if I convert a non-land tile (tile type ID 1) into a land tile, how can I get the world to recalculate the borders (or "islands") without reloading the game?

 

Currently this is the function I'm using to change the tile at the cursor:

function c_setTile(newType)    local pos = TheInput:GetWorldPosition()    local x, y = TheWorld.Map:GetTileCoordsAtPoint(pos.x, pos.y, pos.z)    local oldType = TheWorld.Map:GetTileAtPoint(pos.x, pos.y, pos.z)    TheWorld.Map:SetTile(x, y, newType)    TheWorld.Map:RebuildLayer(oldType, x, y)    TheWorld.Map:RebuildLayer(newType, x, y)    TheWorld.minimap.MiniMap:RebuildLayer(oldType, x, y)    TheWorld.minimap.MiniMap:RebuildLayer(newType, x, y)end

 

When I use this on a water tile to make it into a land one, however, it doesn't change the land border beneath it, and using TheWorld.Map:GetIslandAtPoint(point) still gives 127, which is NO_ISLAND, or water. Reloading the game seems to fix this, but I've been unable to find a way to do it without that (the reason I'd like to be able to do so is to use it with Don't Starve Together, having the host be able to dynamically change the land). I haven't found anywhere you can set the island of a point or force a rebuild or anything of that sort.

 

Edit: I wanted to also note that I looked around and found this thread about changing turf and this thread about an out-of-game world editor, but neither of these seem to do exactly what I'm trying to do.

Edited by rezecib

There is something like ground undergound, its checked for on many ocassions in things that spawn some prefabs. ground underground is on the edges of the island, you can check that by removing tiles from the edge.

Yeah, I was noticing that (I called it the "land borders" in my post), but the little edges of dirty ground that you can see below the edge. Changing the tile doesn't update that, but reloading the game does seem to, which suggests there's a point in the saving/reloading process where it does update the ground, but I haven't been able to find it...

Yeah, I was noticing that (I called it the "land borders" in my post), but the little edges of dirty ground that you can see below the edge. Changing the tile doesn't update that, but reloading the game does seem to, which suggests there's a point in the saving/reloading process where it does update the ground, but I haven't been able to find it...

 

When I was checking for it, it was something in playercontroller.lua component. But it all go to complicated to make simple bridge so I never finished that.

 

I've looked in playercontroller and just about every else in the lua code. From what I can tell this is being handled in the C code, and that's not something I can really look at. Any Klei help?

  :spidercowers:

I've looked in playercontroller and just about every else in the lua code. From what I can tell this is being handled in the C code, and that's not something I can really look at. Any Klei help?

  :spidercowers:

I couldn't find solution for this problem back then, it would be nice to get some help on that matter.

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