Commit a7c5cea7 by Phil Hagelberg

Add systems to universe table in-sandbox.

Fixes #125.
parent af6cd886
Pipeline #7803522 failed with stage
in 2 minutes 30 seconds
Showing with 24 additions and 1 deletions
......@@ -34,11 +34,18 @@ local _ = { r=0, mass=0,
-- comm_boost (must be unlocked)
-- map
-- The positions for these systems are based on a listing of all habitable stars
-- within 20 light years of Sol from Project Rho:
-- http://www.projectrho.com/public_html/starmaps/mapindex.php#winch
-- Most but not all of the stars have been given colloquial names, a couple have
-- been omitted to tidy things up a bit, compare
-- https://p.hagelb.org/starmap.png vs https://p.hagelb.org/bussard_map.png
local sys = {
-- Tana
["Tana"] =
{gov="Tana", capitol = true,
x = -5.8, y=-2.4,
x = -4.8, y=-2.4,
asteroids = 4,
bodies = {
{r=0, x=0, y=0, dx=0, dy=0, mass=230000,
......
......@@ -14,6 +14,7 @@ local host_fs_proxy = require("host_fs_proxy")
-- for shuffling systems upon entry
local asteroid = require("asteroid")
local body = require("body")
local systems = require("data.systems")
local editor = require("polywell")
......@@ -77,9 +78,17 @@ local sandbox_require = function(ship, mod_name)
sandbox_loaded[mod_name] = true
end
local expose_system = function(sys)
local fields = {"x", "y", "r", "mass", "name", "pop",
"portal", "world", "station", "star"}
local bodies = lume.map(sys.bodies, utils.rfn(lume.pick, unpack(fields)))
return lume.merge({bodies=bodies}, lume.pick(sys, "x", "y", "gov"))
end
local universe_api = utils.readonly_proxy {
g = body.g,
max_accel = body.max_accel,
systems = lume.map(systems, expose_system),
}
local sandbox = function(ship)
......
......@@ -353,6 +353,13 @@ return {
end)
end,
rfn = function(fn, ...)
local partial_args = {...}
return function(...)
return fn(unpack(lume.concat({...}, partial_args)))
end
end,
find_by = function(ts, key, value)
for _,t in ipairs(ts) do
if(t[key] == value) then return t end
......
  • Hm, does this mean that the «map» upgrade no longer provides new data? I think previously buying the map was the only way to get the system list in-game.

  • Yeah, the data is available without buying the map now, which means technically the map is really just a form of convenience. If players want to write their own implementation I'd say that should be encouraged.

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment