OpenStarbound / OpenStarbound

172 stars 29 forks source link

Lua callback in celestial table work inconsistently #74

Closed Kilkenni closed 1 day ago

Kilkenni commented 2 weeks ago

Test case: The ship is orbiting a planet. ScriptPane with a button is called. button function:

    function btnDumpTp:onClick()
      --lblDebug:setText(sb.printJson(mel_tp.bookmarks))
      local shipLocation = celestial.shipLocation();
      if(shipLocation[1] == "coordinate") then
        lblDebug:setText(sb.printJson(celestial.planetName(shipLocation[2]))..world.timeOfDay())
        sb.logInfo("Location is "..sb.printJson(shipLocation[2]))
        sb.logInfo("Planet size is "..sb.printJson(celestial.planetSize(shipLocation[2])))
        sb.logInfo("Planet name is "..sb.printJson(celestial.planetName(shipLocation[2])))
      end
    end

I.e.

Expected behavior:

Real behavior:

Real behavior can be replicated:

Novaenia commented 2 weeks ago

this is probably because the client has to request the celestial chunk of the given coordinate from the server first if it doesn't exist in the local chunk cache. as a workaround, I've added code to ensure that the chunk of the ship location is already loaded by the time any celestial Lua code is ran. does the issue still occur for you?

Kilkenni commented 1 week ago

this is probably because the client has to request the celestial chunk of the given coordinate from the server first if it doesn't exist in the local chunk cache. as a workaround, I've added code to ensure that the chunk of the ship location is already loaded by the time any celestial Lua code is ran. does the issue still occur for you?

Unfortunately can't check right now because my build fails due to this issue when building libsystemd. Possible fix exists as a pull request for VCPKG but only for Windows rn (If I read the log correctly, linux_x64 autotest failed). Can I get a fresh build somewhere? (release version is 3 days old - apparently, these changes are not there yet)

Novaenia commented 1 week ago

Can I get a fresh build somewhere?

download the builds from the Actions tab (the nightly links on the README are also shortcuts to those)

Kilkenni commented 1 day ago

this is probably because the client has to request the celestial chunk of the given coordinate from the server first if it doesn't exist in the local chunk cache. as a workaround, I've added code to ensure that the chunk of the ship location is already loaded by the time any celestial Lua code is ran. does the issue still occur for you?

Thanks for help! It seems that you've fixed the problem.