Jump to content

Possible bugs with current MapExplorer:RevealArea?


clearlove
  • Pending

I am trying to create an entity with a mapexplorer in my mod. I met a strange phenomenon that the MapExplorer sometimes "forgets" the map it has learned when revealing new areas to them. Is the AddMapExplorer designed for player_classified only? If not, I think this is a bug.

I used the following codes.

-- The file scripts/prefabs/worldmapexplorer.lua
local function fn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddMapExplorer()
    inst.entity:AddNetwork()
    inst.entity:SetCanSleep(false)
    inst.entity:Hide()
    inst:AddTag("CLASSIFIED")

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
      return inst
    end

    inst.persists = false

    return inst
end

return Prefab("worldmapexplorer", fn)

Then in the modmain.lua, simply use

AddPrefabPostInit("world", function(inst)
	inst.worldmapexplorer = GLOBAL.SpawnPrefab("worldmapexplorer")
end)

I uploaded this demo mod as the attatchment.

debug_explorer.zip


Steps to Reproduce

1. Reveal areas in the map to the TheWorld.worldmapexplorer by typing these to the console: 

local m=TheWorld.worldmapexplorer.MapExplorer local w,h = TheWorld.Map:GetSize() for x=-w*2,w,10 do for z=-h*2,h,10 do if TheWorld.Map:IsValidTileAtPoint(x,0,z) and m then m:RevealArea(x,0,z) end end end

2. Go to the cave, and return back. (This is necessary, if the player stays in the same world, repeating the third step does not produce unexcepted results)

3. Call RevealArea. You can run the following codes in the console to call RevealArea.

print("before RevealArea") print(TheWorld.worldmapexplorer.MapExplorer:RecordMap()) TheWorld.worldmapexplorer.MapExplorer:RevealArea(0, 0, 0) print("after RevealArea") print(TheWorld.worldmapexplorer.MapExplorer:RecordMap())

Note that when running the above codes, the map recording printed after revealing areas is still correct (A very long string).

4. Strange things happen if you check the data again. Run:

print(TheWorld.worldmapexplorer.MapExplorer:RecordMap())

One can only get a very short string.




User Feedback


There are no comments to display.



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