diff --git a/data/systems.lua b/data/systems.lua index 4d8c627..e09f3ce 100644 --- a/data/systems.lua +++ b/data/systems.lua @@ -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, diff --git a/ship/init.lua b/ship/init.lua index f8a0350..f290168 100644 --- a/ship/init.lua +++ b/ship/init.lua @@ -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) diff --git a/utils.lua b/utils.lua index ab2ee18..2d1dbbd 100644 --- a/utils.lua +++ b/utils.lua @@ -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