Source Code Functions and Object Definitions


JadenVanadium

Recommended Posts

I'm playing with an idea for a future mod, but I've run into a wall (literally) with how the game handles turfs, and path-finding. Via experimentation, and some borrowing of the game's various open source code, I've created a function that when supplied a point (x,y,z), changes the turf at that location between dirt (No turf), and impassable (water or abyss). The function is currently optimized to be used from the console.

Example: http://prntscr.com/8aozwn

 

I have two basic issues with how it works now that I can't seem to solve. First, while the surface of the tile updates visually, and most tests treat it as the tile that I've changed it to, neither the walls of the land fit to that new tile, nor is your ability to walk on that tile changed, until you reload the world.

Example: http://prntscr.com/8aubz1

(Weirdly, birds still land with regards to the visual turf, nothing else can walk on it though)

 

My second issue is that although when the world is reloaded it can be walked on and interacted with in almost every normal way, most path-finding and mob logic still treats the tile as if it is impassable, which is not very useful. I believe the perpetrator is specifically this function, which is seemingly defined nowhere in the open source, always returns false if there is an originally impassable tile between the two points, even if it is now fully passable:

GetWorld().Pathfinder:IsClear(p0.x, p0.y, p0.z, p1.x, p1.y, p1.z, {ignorewalls = true/false, ingorecreep=true/false})

From experimentation, the table at the end can be omitted and they default to true. Its purpose seems to be to check between two points (p0 and p1) to see if a straight path can be drawn between them that does not intersect any impassable turf, but as I said before, it always returns false if one of the points is located on or on the far side of an originally impassable tile, even if it is no longer impassable. What's odd about it is that the return can change from true to false if you create an island by destroying turf between two points that originally returned true, even if you haven't actually reloaded the game and can still walk on them, and this also seems to be reversable, but the opposite can not be done, by creating turf on originally impassable land, even when you reload the game. How would the function know if the tile was originally impassable, and why is it that almost nothing else checks for the same thing?

 

Are there lingering tags I have to remove or add to it? How do I check what indexes an object has? And how would I go about updating the walls without restarting? etcetera??

 

Any help is appreciated!!! O u O

 

 

 

P.S. Here's the crude function I've defined that switches the turf. It's basically the components/terraformer.lua/Terraform(pt) function code reformatted to fit my specific needs.

http://pastebin.com/4c1mAuQf

Link to comment
Share on other sites

Doesn't look like anyone is actually going to supply meaningful input to this topic so I might as well put my progress here in case anyone does happen to read it.

I've learned a bit more about lua and figured out that I can find all the valid keys a programatic object has, and developed a function for that specific purpose. This has been a huge advancement for me, because instead of digging around in already written code to see if something looks interesting, I can simply find keys that I feel like changing. I've also written that function in my consolecommands.lua file, for ease of use.

Example code: http://pastebin.com/wW28pUnd

Example usage: http://prntscr.com/8dhm9h

 

If any new modder sees this, feel free to use it. It is an amazing tool that I have created.

Well, despite having this, I still can't seem to fix my issue. I've figured out how to re-render the walls without restarting the save by using a command:

GetMap().Map.Finalize(ground.Map, 0 or 1)

 

So if I set my function to destroy land, then the walls fix and render correctly, which means operating in that direction is a complete success (Woo!)

However, the reverse is not true. While creating land does fix the rendered walls as well as creates the meta-walls at the edge of the new space, it does not destroy the old meta walls, which means the player still can't pass over to newly created turf without reloading the save. I'm currently trying to figure out how to selectively or indiscriminately delete all the meta walls, but I haven't figured it out yet, because the function I used, Finalize(), is another function that is nowhere in the open source lua documents. Similarly, it's only used in one place, twice, and the only difference between the two usages is that it supplies either 1 or 0 as the second argument depending on if the player is in the caves or not.

 

So while I've gotten closer to my solution, I now have two problems to work out: I don't know how the Map:IsClear function works, nor the Pathfinder:Finalize function, and both of them exist only in the compiled program, from what I can tell.

Can anyone help me figure out what these functions are specifically doing?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.