Jump to content

Recommended Posts

I have my modmain setup to use debug mode:

GLOBAL.CHEATS_ENABLED = true
GLOBAL.require('debugkeys')
GLOBAL.require('debugcommands')
GLOBAL.require('maputil')

But when I call GLOBAL.DrawWalkableGrid(), nothing happens. What's the simplest way to get this to render on the map?

7 hours ago, FerniFrenito said:

What do those functions do? It seems they're not used even once in the entire game code.

They're debug tools. They look as if they should add a draw layer on top of the map, but it doesn't seem to for me.

Edited by cybers2001
On 11/7/2025 at 12:08 PM, cybers2001 said:

I have my modmain setup to use debug mode:

GLOBAL.CHEATS_ENABLED = true
GLOBAL.require('debugkeys')
GLOBAL.require('debugcommands')
GLOBAL.require('maputil')

Off-topic tangent, but does this allow you to use the functions the devs use on RWP streams, like clicking on the map to teleport? I'd be interested in playing around with these, at least for content testing purposes and I'd like to know more (how to enable, etc.)

12 hours ago, Semind said:

Off-topic tangent, but does this allow you to use the functions the devs use on RWP streams, like clicking on the map to teleport? I'd be interested in playing around with these, at least for content testing purposes and I'd like to know more (how to enable, etc.)

These functions should be just for drawing lines on the map. The code suggests it visualizes the connections between land nodes, which I wanted to play with to see if I can better approximate travel distances between different POIs for a mod I'm working on. The graph functions mainly for worldgen purposes to ensure landdmasses are connected, which is different than pathfinder used for the characters themselves.

That being said, I did come up with a pretty nice tool that leverages node neighbors, though not for distance approximation:

local NAME_CONVERSIONS = {
    ["MoonIsland_Mine"]         = "MoonIsland",
    ["MoonIsland_IslandShards"] = "MoonIsland",
    ["MoonIsland_Beach"]        = "MoonIsland",
    ["MoonIsland_Forest"]       = "MoonIsland",
    ["MoonIsland_Baths"]        = "MoonIsland",
    ["MoonIslandRetrofit"]      = "MoonIsland",
}

local function GetName(topId)
    local task_name, _, _ = topId:match("(.*):(.*):(.*)")
    local name = task_name or topId
    return NAME_CONVERSIONS[name] or name
end

function GetTopologyInfoAt(pos)
    local graph = TheWorld.topology
    local nodes = {}
    local size = 0
    local unmatched = {}

    local function AddNeighbors(nodeId, matchingName)
        local node = graph.nodes[nodeId]
        if node == nil then return end
        size = size + node.area
        for _,v in pairs(node.neighbours) do
            if not nodes[v] then
                local topId = graph.ids[v] or ""
                local name = GetName(topId)
                if name == matchingName then
                    nodes[v] = true
                    AddNeighbors(v, matchingName)
                else
                    unmatched[name] = true
                end
            end
        end
    end
    
    local id = TheWorld.Map:GetNodeIdAtPoint(pos.x, pos.y, pos.z)
    local topId = graph.ids[id] or ""
    local name = GetName(topId)
    if name ~= "" then
        AddNeighbors(id, name)
    end

    local neighbors = {}
    for k,_ in pairs(unmatched) do
        table.insert(neighbors, k)
    end

    return { name=name, area=size, neighbors=neighbors }
end

With this code, you just call GetTopologyInfoAt() and pass in your position, and it will give you the "task type" name, approx biome surface area, and the names of the neighboring biomes.

Edited by cybers2001

Some debug entities only show up clientside, but I don't know if that's related to this.

The draw fn renders a yellow line for you, while the show fn reveals an area on the minimap for you (therefore you need to have the map undiscovered).

I don't know how to show the lines, but other mods use DebugRender and draw using it, so it must be real. Like for example, DrawLine(ThePlayer:GetPosition(), c_find("evergreen"):GetPosition()) supposedly draws a line using the debug render? But I don't know how to get that to show up. So I can only talk about the show fn.

It seems the commands create walkable voronoi connections on the minimap (aka between node cells). This becomes more apparent when you have a voronoi marker mod enabled.

No Voronoi Mod:

Spoiler

image.png.179f3b4df083e129f92b48d81ef27288.png

Voronoi Mod:

Spoiler

image.png.124fb0f3b3611980e7b72fa346ee6331.png

I did require"maputil" then ShowWalkableGrid() in the command prompt. I'm assuming the player needs to be fully initialized before doing these commands, but I could be wrong.

Edited by oregu
22 hours ago, oregu said:

Some debug entities only show up clientside, but I don't know if that's related to this.

The draw fn renders a yellow line for you, while the show fn reveals an area on the minimap for you (therefore you need to have the map undiscovered).

I don't know how to show the lines, but other mods use DebugRender and draw using it, so it must be real. Like for example, DrawLine(ThePlayer:GetPosition(), c_find("evergreen"):GetPosition()) supposedly draws a line using the debug render? But I don't know how to get that to show up. So I can only talk about the show fn.

It seems the commands create walkable voronoi connections on the minimap (aka between node cells). This becomes more apparent when you have a voronoi marker mod enabled.

No Voronoi Mod:

  Hide contents

image.png.179f3b4df083e129f92b48d81ef27288.png

Voronoi Mod:

  Hide contents

image.png.124fb0f3b3611980e7b72fa346ee6331.png

I did require"maputil" then ShowWalkableGrid() in the command prompt. I'm assuming the player needs to be fully initialized before doing these commands, but I could be wrong.

 

Ohh, that is very cool. Thanks!

I wrote up some tools that recursively iterate through node neighbors to determine approximate biome sizes and walking distances. If anyone's interested I can throw in some sneak peaks.

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