Index: mods/starlit-building/init.lua ================================================================== --- mods/starlit-building/init.lua +++ mods/starlit-building/init.lua @@ -9,12 +9,12 @@ ['starlit_building:pipe'] = 'myMod:stage3'; }; tool = { ['starlit:screwdriver'] = 'myMod:otherThing_stage1'; ['starlit:saw'] = function(node, tool) - minetest.replace_node(node, {name='myMod:stage1'}) - minetest.drop_item(node, 'starlit_building:pipe') + core.replace_node(node, {name='myMod:stage1'}) + core.drop_item(node, 'starlit_building:pipe') end; ['myMod:laserWrench'] = { allow = function(node, tool) ... end; handle = function(node, tool) ... end; }; @@ -83,21 +83,21 @@ rev = { sw = scmID; complexity = e.complexity or 1; } end - minetest.register_craftitem(id, { + core.register_craftitem(id, { short_description = e.name; description = starlit.ui.tooltip { title = e.name; desc = e.desc; props = props; }; stack_max = e.max or (e.mass and math.min(math.max(math.floor(500 / e.mass), 1), 500)) or 10; inventory_image = e.img; on_place = function(stack, luser, point) - local node = minetest.get_node(point.under) + local node = core.get_node(point.under) local function tryBuild() local p = B.path[node.name] if not p then return nil end if (not p.part) or (not p.part[id]) then return nil end local n = p.part[id] @@ -110,11 +110,11 @@ stack:take_item(1) end local pname = obj:get_name() local stg = B.stage.db[pname] node.name = pname - minetest.swap_node(point.under, node) + core.swap_node(point.under, node) -- TODO make a noise if stg.onBuild then stg.onBuild(point.under, luser, stack) end return stack @@ -127,11 +127,11 @@ p = p(stack, node, point) if p == nil then return nil end else stack:take_item(1) end - minetest.rotate_and_place(ItemStack(p), luser, point, true) + core.rotate_and_place(ItemStack(p), luser, point, true) -- TODO make a noise return stack end return tryBuild() or tryBegin() or stack @@ -179,11 +179,11 @@ local meta = { stage = id; recover = e.recover; } for k,v in pairs(e.meta or {}) do meta[k] = v end - minetest.register_node(id, { + core.register_node(id, { description = 'Construction'; drawtype = (e.box and 'nodebox') or (e.mesh and 'mesh') or 'regular'; paramtype = e.paramtype or (e.box or e.mesh or e.light) and 'light' or nil; Index: mods/starlit-eco/init.lua ================================================================== --- mods/starlit-eco/init.lua +++ mods/starlit-eco/init.lua @@ -165,11 +165,11 @@ { 0.600, 'starlit:precip'}; { 0.850, 'starlit:storm'}; { 0.900, 'starlit:tstorm'}; }; }) -minetest.register_craftitem('starlit_eco:fiber', { +core.register_craftitem('starlit_eco:fiber', { description = "Plant Fiber"; groups = {fiber = 1}; inventory_image = lib.image('starlit-eco-plant-fiber.png'):shift(lib.color(0,1,0)):render(); _starlit = { recover_vary = function(rng, ctx) Index: mods/starlit-eco/trees.lua ================================================================== --- mods/starlit-eco/trees.lua +++ mods/starlit-eco/trees.lua @@ -41,12 +41,12 @@ base.groups.falling_node = 1 local live = table.copy(base) live.drop = id live.groups.alive = 1 - minetest.register_node(id, base) - minetest.register_node(id..'_live', live) + core.register_node(id, base) + core.register_node(id..'_live', live) end regLog('starlit_eco:lambent_pine_log', { description = 'Lambent Pine Log'; drawtype = 'normal'; @@ -73,11 +73,11 @@ name = 'Lambent Pine Seed'; tex = lib.image('starlit-eco-plant-seeds.png'):shift{hue=150, sat=-.5, lum=.8}:render(); grow = {kind = 'tree', id = 'starlit_eco:lambent_pine'}; }) -minetest.register_node('starlit_eco:lambent_pine_bulb', { +core.register_node('starlit_eco:lambent_pine_bulb', { description = 'Lambent Pine Bulb'; drawtype = 'nodebox'; connects_to = {'starlit_eco:lambent_pine_needles'}; node_box = { type = 'connected'; @@ -105,11 +105,11 @@ 'starlit-eco-tree-lambent-pine-bulb.png'; }; _starlit = woodProps{}; }) -minetest.register_node('starlit_eco:lambent_pine_needles', { +core.register_node('starlit_eco:lambent_pine_needles', { description = 'Lambent Pine Needles'; groups = {plant = 1;}; drop = ''; tiles = { 'starlit-eco-tree-lambent-pine-needles.png'; @@ -126,21 +126,21 @@ 'starlit-eco-tree-starblossom-trunk.png'; }; _starlit = woodProps{}; }) -minetest.register_node('starlit_eco:starblossom_leaves', { +core.register_node('starlit_eco:starblossom_leaves', { description = 'Starblossom Leaves'; groups = {plant = 1;}; drop = ''; tiles = { 'starlit-eco-tree-starblossom-leaves.png'; 'starlit-eco-tree-starblossom-leaves.png'; }; _starlit = leafProps{}; }); -minetest.register_node('starlit_eco:starblossom_leaves_shine', { +core.register_node('starlit_eco:starblossom_leaves_shine', { description = 'Shining Starblossom Leaves'; groups = {plant = 1;}; drop = ''; paramtype = 'light'; light_source = 4; @@ -215,19 +215,19 @@ }; }; }; } -minetest.register_abm { +core.register_abm { label = "lambent pine fruiting"; nodenames = {'starlit_eco:lambent_pine_needles'}; neighbors = {'starlit_eco:lambent_pine_log_live'}; chance = 40; interval = 80; catch_up = true; action = function(pos, node) local po = pos:offset(0,-1,0) - if minetest.get_node(po).name == "air" then - minetest.add_node(po, {name='starlit_eco:lambent_pine_bulb'}) + if core.get_node(po).name == "air" then + core.add_node(po, {name='starlit_eco:lambent_pine_bulb'}) end end; } Index: mods/starlit-electronics/init.lua ================================================================== --- mods/starlit-electronics/init.lua +++ mods/starlit-electronics/init.lua @@ -120,11 +120,11 @@ error(string.format('object %q is not a %s', stack:get_name(), ty)) end if not stack or stack:is_empty() then fail() end - if minetest.get_item_group(stack:get_name(), ty) == 0 then fail() end + if core.get_item_group(stack:get_name(), ty) == 0 then fail() end return fn(stack, stack:get_definition()._starlit[ty], stack:get_meta(), ...) end @@ -237,11 +237,11 @@ dischargeRate = E.battery.dischargeRate; wasteHeat = function() return 0 end; }; starlit.item.battery.foreach('starlit_electronics:battery-gen', {}, function(id, def) - minetest.register_tool(id, { + core.register_tool(id, { short_description = def.name; groups = { battery = 1; dynamo = 1; electronic = 1; }; inventory_image = def.img or 'starlit-item-battery.png'; description = starlit.ui.tooltip { title = def.name; @@ -578,11 +578,11 @@ ----------- E.sw = {} function E.sw.findSchematicFor(item) local id = ItemStack(item):get_name() - local fm = minetest.registered_items[id]._starlit + local fm = core.registered_items[id]._starlit if not (fm and fm.reverseEngineer) then return nil end local id = fm.reverseEngineer.sw return id, starlit.item.sw.db[id] end @@ -651,11 +651,11 @@ for _, e in pairs(file.body.entries) do sz = sz + #e.title + #e.body + 0x10 -- header overhead end return sz elseif file.kind == 'research' then - local re = assert(minetest.registered_items[file.body.itemId]._starlit.reverseEngineer) + local re = assert(core.registered_items[file.body.itemId]._starlit.reverseEngineer) return starlit.item.sw.db[re.sw].size * file.body.progress elseif file.kind == 'sw' then return starlit.item.sw.db[file.body.pgmId].size elseif file.kind == 'genome' then return 0 -- TODO @@ -807,11 +807,11 @@ function E.chip.update(chip) chip:get_meta():set_string('description', E.chip.describe(chip)) end starlit.item.chip.foreach('starlit_electronics:chip-gen', {}, function(id, def) - minetest.register_craftitem(id, { + core.register_craftitem(id, { short_description = def.name; description = E.chip.describe(def, true); inventory_image = def.img or 'starlit-item-chip.png'; groups = {chip = 1}; _starlit = { @@ -835,11 +835,11 @@ lp = {name = 'Low-Power Chip', clockRate = 128e6, flash = 64e6, ram = 1e9, powerEfficiency = 1e11, size = 4}; carbon = {name = 'Carbon Chip', clockRate = 64e6, flash = 32e6, ram = 2e6, powerEfficiency = 2e10, size = 2, circ='carbon'}; } E.chip.tiers.foreach('starlit_electronics:genChips', {}, function(id, t) - id = t.id or string.format('%s:chip_%s', minetest.get_current_modname(), id) + id = t.id or string.format('%s:chip_%s', core.get_current_modname(), id) local circMat = t.circ or 'silicon'; starlit.item.chip.link(id, { name = t.name; clockRate = t.clockRate; flash = t.flash; @@ -940,11 +940,11 @@ sw = pgm else sw = {} for i, e in ipairs(chips) do if (not e:is_empty()) - and minetest.get_item_group(e:get_name(), 'chip') ~= 0 + and core.get_item_group(e:get_name(), 'chip') ~= 0 then for fl, inode in E.chip.files(e) do if fl.kind == 'sw' then local s = starlit.item.sw.db[fl.body.pgmId] table.insert(sw, { Index: mods/starlit-electronics/sw.lua ================================================================== --- mods/starlit-electronics/sw.lua +++ mods/starlit-electronics/sw.lua @@ -34,11 +34,11 @@ return function(user, ctx) local function cleanup() user.action.prog.shred = nil if user.action.sfx.shred then - minetest.sound_fade(user.action.sfx.shred, 1, 0) + core.sound_fade(user.action.sfx.shred, 1, 0) user.action.sfx.shred = nil end if user.action.fx.shred then user.action.fx.shred.abort() end @@ -52,13 +52,13 @@ end local shredTime = 1.0 local soundPitch = 1.0 -- TODO local pdraw = prop.powerDraw or 0 - if minetest.is_protected(what, user.entity:get_player_name()) then return end - local node = minetest.get_node(what) - local nd = minetest.registered_nodes[node.name] + if core.is_protected(what, user.entity:get_player_name()) then return end + local node = core.get_node(what) + local nd = core.registered_nodes[node.name] local elt, fab, vary if nd._starlit then fab = nd._starlit.recover or nd._starlit.fab vary = nd._starlit.recover_vary end @@ -88,11 +88,11 @@ return false elseif not user.action.prog.shred then cleanup() -- kill danglers -- begin user.action.prog.shred = 0 - user.action.sfx.shred = minetest.sound_play('starlit-nano-shred', { + user.action.sfx.shred = core.sound_play('starlit-nano-shred', { object = user.entity; max_hear_distance = prop.range*2; loop = true; pitch = soundPitch; }) @@ -100,18 +100,18 @@ else user.action.prog.shred = user.action.prog.shred + ctx.how.delta or 0 end --print('shred progress: ', user.action.prog.shred) if user.action.prog.shred >= shredTime then - minetest.remove_node(what) - minetest.check_for_falling(what) + core.remove_node(what) + core.check_for_falling(what) --print('shred complete') user:suitSound 'starlit-success' if fab then local vf = fab if vary then - local rng = (starlit.world.seedbank+0xa891f62)[minetest.hash_node_position(what)] + local rng = (starlit.world.seedbank+0xa891f62)[core.hash_node_position(what)] vf = vf + vary(rng, {}) end local items, charges = fabToItemsAndCharges(vf) for i, it in ipairs(items) do user:give(it) end -- TODO give gasses, liquids @@ -255,11 +255,11 @@ --[[ bgProc = function(user, ctx, interval, runState) if runState.flags.compiled == true then return false end -- only so many nanides to go around runState.flags.compiled = true - local time = minetest.get_gametime() + local time = core.get_gametime() local cyclesLeft = ctx.comp.cycles * interval for id, e in ipairs(ctx.file.body.conf) do if e.key == 'job' then local t = J.dec(e.value) Index: mods/starlit-material/init.lua ================================================================== --- mods/starlit-material/init.lua +++ mods/starlit-material/init.lua @@ -1,11 +1,11 @@ local lib = starlit.mod.lib local M = { canisterSizes = lib.registry.mk 'starlit_material:canister-size'; } M.canisterSizes.foreach('starlit_material:canister_link', {}, function(id, sz) - starlit.item.canister.link(minetest.get_current_modname() .. ':canister_' .. id, { + starlit.item.canister.link(core.get_current_modname() .. ':canister_' .. id, { name = sz.name; slots = sz.slots; vol = sz.vol; -- too big for suit? desc = sz.desc; }) Index: mods/starlit-tech/init.lua ================================================================== --- mods/starlit-tech/init.lua +++ mods/starlit-tech/init.lua @@ -16,11 +16,11 @@ attached_node = 1; } if def.group then for k,v in pairs(def.group((i/stages))) do grp[k]=v end end - minetest.register_node(stID(i), { + core.register_node(stID(i), { short_description = def.name; description = starlit.ui.tooltip { title = def.name; desc = def.desc; color = def.color; @@ -42,20 +42,20 @@ paramtype = 'light'; paramtype2 = 'wallmounted'; wallmounted_rotate_vertical = true; light_source = math.floor(lib.math.lerp(i/stages, 0, def.glow)); on_construct = i ~= 0 and function(pos) - local t = minetest.get_node_timer(pos) + local t = core.get_node_timer(pos) t:start(stageTimeout) if def.ctor then def.ctor(pos, (i/stages)) end end or nil; on_destruct = def.dtor and function(pos) def.dtor(pos, (i/stages)) end or nil; on_timer = i ~= 0 and function(pos) - local me = minetest.get_node(pos) - minetest.swap_node(pos, {name=stID(i-1), param2=me.param2}) + local me = core.get_node(pos) + core.swap_node(pos, {name=stID(i-1), param2=me.param2}) return i > 1 end or nil; _starlit = (function() local meta = { mass = def.mass; @@ -156,11 +156,11 @@ end; }; } end; } -minetest.register_node('starlit_tech:crate', { +core.register_node('starlit_tech:crate', { short_description = 'Crate'; description = starlit.ui.tooltip { title = 'Crate'; desc = 'A sturdy but lightweight aluminum storage crate.'; props = { {title='Mass', affinity='info', desc='100g'} }; @@ -201,11 +201,11 @@ shredPower = 3; }; }; }; on_construct = function(pos) - local m = minetest.get_meta(pos) + local m = core.get_meta(pos) local inv = m:get_inventory() inv:set_size('starlit:contents', 12) end; on_rightclick = function(pos, node, luser) if not luser then return end Index: mods/starlit/effect.lua ================================================================== --- mods/starlit/effect.lua +++ mods/starlit/effect.lua @@ -105,11 +105,11 @@ if not effect.anchor then goto skip end -- this intentionally excludes attached effects if ineffectrange(effect,d.pos,d.range) then effects[#effects+1] = {v=effect,i=id} end ::skip::end - local ppl = minetest.get_objects_inside_radius(d.pos,d.range) + local ppl = core.get_objects_inside_radius(d.pos,d.range) if #targets == 0 then targets = ppl else for _,p in pairs(ppl) do targets[#targets+1] = p end end end @@ -139,11 +139,11 @@ end end end starlit.effect.ensorcelled = function(player,effect) - if type(player) == 'string' then player = minetest.get_player_by_name(player) end + if type(player) == 'string' then player = core.get_player_by_name(player) end for _,s in pairs(starlit.effect.active) do if effect and (s.name ~= effect) then goto skip end for _,sub in pairs(s.subjects) do if sub.player == player then return s end end @@ -165,11 +165,11 @@ until idx >= #starlit.effect.active end end -- when a new effect is created, we analyze it and make the appropriate calls --- to minetest.after to queue up the events. each job returned needs to be +-- to core.after to queue up the events. each job returned needs to be -- saved in 'jobs' so they can be canceled if the effect is disjoined. no polling -- necessary :D starlit.effect.cast = function(proto) local s = table.copy(proto) @@ -176,11 +176,11 @@ s.jobs = s.jobs or {} s.vfx = s.vfx or {} s.sfx = s.sfx or {} s.impacts = s.impacts or {} s.subjects = s.subjects or {} s.delay = s.delay or 0 s.visual = function(subj, def) s.vfx[#s.vfx + 1] = { - handle = minetest.add_particlespawner(def); + handle = core.add_particlespawner(def); subject = subj; } end s.visual_caster = function(def) -- convenience function local d = table.copy(def) @@ -208,20 +208,20 @@ end return etbl end s.abort = function() for _,j in ipairs(s.jobs) do j:cancel() end - for _,v in ipairs(s.vfx) do minetest.delete_particlespawner(v.handle) end + for _,v in ipairs(s.vfx) do core.delete_particlespawner(v.handle) end for _,i in ipairs(s.sfx) do s.silence(i) end for _,i in ipairs(s.impacts) do i.effect:stop() end end s.release_subject = function(si) local t = s.subjects[si] for _,f in pairs(s.sfx) do if f.subject == t then s.silence(f) end end for _,f in pairs(s.impacts) do if f.subject == t then f.effect:stop() end end for _,f in pairs(s.vfx) do - if f.subject == t then minetest.delete_particlespawner(f.handle) end + if f.subject == t then core.delete_particlespawner(f.handle) end end s.subjects[si] = nil end local interpret_timespec = function(when) if when == nil then return 0 end @@ -234,20 +234,20 @@ log.err('invalid timespec ' .. dump(when)) return 0 end s.queue = function(when,fn) - local elapsed = s.starttime and minetest.get_server_uptime() - s.starttime or 0 + local elapsed = s.starttime and core.get_server_uptime() - s.starttime or 0 local timepast = interpret_timespec(when) if not timepast then timepast = 0 end local timeleft = s.duration - timepast local howlong = (s.delay + timepast) - elapsed if howlong < 0 then log.err('cannot time-travel! queue() called with `when` specifying timepoint that has already passed') howlong = 0 end - s.jobs[#s.jobs+1] = minetest.after(howlong, function() + s.jobs[#s.jobs+1] = core.after(howlong, function() -- this is somewhat awkward. since we're using a non-polling approach, we -- need to find a way to account for a caster or subject walking into an -- existing antimagic field, or someone with an existing antimagic aura -- walking into range of the anchor. so every time a effect effect would -- take place, we first check to see if it's in range of something nasty @@ -288,11 +288,11 @@ else specs[#specs+1] = { spec = {pos = spec.where} } end for _,sp in pairs(specs) do sp.spec.gain = sp.spec.gain or spec.gain local so = { - handle = minetest.sound_play(spec.sound, sp.spec, spec.ephemeral); + handle = core.sound_play(spec.sound, sp.spec, spec.ephemeral); ctl = spec; -- object = sp.obj; subject = sp.subject; } stbl[#stbl+1] = so @@ -310,12 +310,12 @@ end end) end s.silence = function(sound) if not sound.handle then return end - if sound.ctl.fade == 0 then minetest.sound_stop(sound.handle) - else minetest.sound_fade(sound.handle,sound.ctl.fade or 1,0) end + if sound.ctl.fade == 0 then core.sound_stop(sound.handle) + else core.sound_fade(sound.handle,sound.ctl.fade or 1,0) end end local startqueued, termqueued = false, false local myid = #starlit.effect.active+1 s.cancel = function() s.abort() @@ -367,11 +367,11 @@ timeleft = timeleft; timeelapsed = s.duration - timeleft; lastreturn = lastreturn; } if nr ~= false and iteration < itercount then - s.jobs[#s.jobs+1] = minetest.after(int.period, + s.jobs[#s.jobs+1] = core.after(int.period, function() iterate(nr) end) end end if int.after then s.queue(int.after, iterate) @@ -387,17 +387,17 @@ if s.sounds then for when,what in pairs(s.sounds) do s.play(when,what) end end starlit.effect.active[myid] = s if not termqueued then - s.jobs[#s.jobs+1] = minetest.after(s.delay + s.duration, function() + s.jobs[#s.jobs+1] = core.after(s.delay + s.duration, function() if s.terminate then s:terminate() end starlit.effect.active[myid] = nil end) end - s.starttime = minetest.get_server_uptime() + s.starttime = core.get_server_uptime() return s end -minetest.register_on_dieplayer(function(player) +core.register_on_dieplayer(function(player) starlit.effect.disjoin{target=player} end) Index: mods/starlit/element.lua ================================================================== --- mods/starlit/element.lua +++ mods/starlit/element.lua @@ -56,11 +56,11 @@ indicator); end end M.element.foreach('starlit:gen-forms', {}, function(id, m) - local eltID = F('%s:element_%s', minetest.get_current_modname(), id) + local eltID = F('%s:element_%s', core.get_current_modname(), id) -- local eltName = F('Elemental %s', lib.str.capitalize(m.name)) local tt = function(t, d, g) return starlit.ui.tooltip { title = t, desc = d; color = lib.color(0.1,0.2,0.1); @@ -80,11 +80,11 @@ if not (m.gas or m.liquid) then local brickID = eltID .. '_brick' local brickName = F('%s Brick', lib.str.capitalize(m.name)) m.form.brick = brickID - minetest.register_craftitem(brickID, { + core.register_craftitem(brickID, { short_description = brickName; description = tt(brickName, F('A small brick of %s, ready to be worked by a matter compiler', m.name), 1); inventory_image = img(lib.image 'starlit-item-brick.png'); wield_image = lib.image 'starlit-item-brick.png':colorize(m.color):render(); stack_max = 500; @@ -103,11 +103,11 @@ }); end --[[ local chunk = F('starlit-element-%s-powder.png', id); - minetest.register_craftitem(eltID, { + core.register_craftitem(eltID, { short_description = eltName; description = tt(eltName, F('A 1g chunk of elemental %s, ready to be worked by a cold matter compiler', m.name), 1); inventory_image = iblit(chunk); wield_image = powder; stack_max = 1000; -- 1kg @@ -129,11 +129,11 @@ M.metal.foreach('starlit:gen-forms', {}, function(id, m) if m.elemental then -- avoid multiple forms for same material m.form = M.element.db[m.elemental].form; else - local baseID = F('%s:metal_%s_', minetest.get_current_modname(), id) + local baseID = F('%s:metal_%s_', core.get_current_modname(), id) local brickID = baseID .. 'brick' local brickName = F('%s Brick', lib.str.capitalize(m.name)) m.form = m.form or {} m.form.brick = brickID local tt = function(t, d, g) @@ -157,11 +157,11 @@ local function img(s) return iblit(s:colorize(m.color):render()) end local mass = 1 - minetest.register_craftitem(brickID, { + core.register_craftitem(brickID, { short_description = brickName; description = tt(brickName, F('A small brick of %s, ready to be worked by a matter compiler', m.name), mass); inventory_image = img(lib.image('starlit-item-brick.png')); wield_image = lib.image 'starlit-item-brick.png':colorize(m.color):render(); groups = {metal = 1, brick = 1}; @@ -228,11 +228,11 @@ }; end starlit.item.canister = lib.registry.mk 'starlit:canister'; starlit.item.canister.foreach('starlit:item-gen', {}, function(id, c) - minetest.register_craftitem(id, { + core.register_craftitem(id, { short_description = c.name; description = canisterDesc(nil, c); inventory_image = c.image or 'starlit-item-element-canister.png'; groups = {canister = 1}; stack_max = 1; Index: mods/starlit/fab.lua ================================================================== --- mods/starlit/fab.lua +++ mods/starlit/fab.lua @@ -141,11 +141,11 @@ -- op = fQuant; -- }; item = { name = {"item", "items"}; string = function(x, n) - local i = minetest.registered_items[x] + local i = core.registered_items[x] return tostring(n) .. 'x ' .. i.short_description end; image = function(x, n) return ItemStack(x):get_definition().inventory_image end; Index: mods/starlit/food.lua ================================================================== --- mods/starlit/food.lua +++ mods/starlit/food.lua @@ -35,11 +35,11 @@ color = f.color; }; end F.foreach('starlit:gen-food', {}, function(id, f) - minetest.register_item(id, { + core.register_item(id, { type = f.itemType or 'none'; inventory_image = f.tex; short_description = f.name; description = foodTip(nil, f); on_use = function(st, luser) @@ -57,11 +57,11 @@ }; }) end) starlit.item.seed.foreach('starlit:gen-seed', {}, function(id, s) - minetest.register_item(id, { + core.register_item(id, { type = 'none'; inventory_image = s.tex; short_description = s.name; description = starlit.ui.tooltip { title = s.name; Index: mods/starlit/init.lua ================================================================== --- mods/starlit/init.lua +++ mods/starlit/init.lua @@ -1,11 +1,11 @@ -- [ʞ] starlit/init.lua -- ~ lexi hale -- ? basic setup, game rules, terrain -- © EUPL v1.2 -local T = minetest.get_translator 'starlit' +local T = core.get_translator 'starlit' -- TODO enforce latest engine version local mod = { -- subordinate mods register here @@ -14,16 +14,16 @@ } local lib = mod.lib starlit = { - ident = minetest.get_current_modname(); + ident = core.get_current_modname(); mod = mod; translator = T; constant = { - light = { --minetest units + light = { --luanti units dim = 3; lamp = 7; bright = 10; brightest = 14; -- only sun and growlights }; @@ -37,11 +37,11 @@ rad = { }; phys = { --- HACK HACK HAAAAAAAAAAACK - engineGravity = minetest.settings:get('movement_gravity') or 9.81 + engineGravity = core.settings:get('movement_gravity') or 9.81 }; }; activeUsers = { -- map of username -> user object @@ -73,11 +73,11 @@ fx = {}; type = {}; world = { defaultScenario = 'starlit_scenario:imperialExpat'; - seedbank = lib.math.seedbank(minetest.get_mapgen_setting 'seed'); + seedbank = lib.math.seedbank(core.get_mapgen_setting 'seed'); mineral = lib.registry.mk 'starlit:mineral'; material = { -- raw materials element = lib.registry.mk 'starlit:element'; -- elements are automatically sorted into the following categories -- if they match. however, it's possible to have a metal/gas/liquid @@ -179,11 +179,11 @@ jobs = {}; } -- TODO deal with core.DEFAULT_PHYSICS once it hits master -starlit.cfgDir = minetest.get_worldpath() .. '/' .. starlit.ident +starlit.cfgDir = core.get_worldpath() .. '/' .. starlit.ident local logger = function(module) local function argjoin(arg, nxt, ...) if arg and not nxt then return tostring(arg) end if not arg then return "(nil)" end @@ -192,11 +192,11 @@ local lg = {} local setup = function(fn, lvl) lvl = lvl or fn local function emit(...) local call = (fn == 'fatal') and error - or function(str) minetest.log(lvl, str) end + or function(str) core.log(lvl, str) end if module then call(string.format('[%s :: %s] %s',starlit.ident,module,argjoin(...))) else call(string.format('[%s] %s',starlit.ident,argjoin(...))) end end @@ -214,11 +214,11 @@ starlit.logger = logger local log = logger() function starlit.evaluate(name, ...) - local path = minetest.get_modpath(minetest.get_current_modname()) + local path = core.get_modpath(core.get_current_modname()) local filename = string.format('%s/%s', path, name) log.info('loading', filename) local chunk, err = loadfile(filename, filename) if not chunk then error(err) end return chunk(...) @@ -228,37 +228,37 @@ return starlit.evaluate(name..'.lua', ...) end function starlit.region.radiator.scan(pos,node) local R = starlit.region - local phash = minetest.hash_node_position(pos) + local phash = core.hash_node_position(pos) if R.radiator.sources[phash] then return end -- already loaded - node = node or minetest.get_node(pos) + node = node or core.get_node(pos) - local def = minetest.registered_nodes[node.name] + local def = core.registered_nodes[node.name] local cl = def._starlit and def._starlit.radiator if not cl then return nil end local min,max = cl.maxEffectArea and cl.maxEffectArea(pos) or nil if not min then assert(cl.radius, 'no radius callback for radiator') local r = cl.radius(pos) local vr = vector.new(r,r,r) min,max = pos-vr, pos+vr end - local id = R.radiator.store:insert_area(min,max, minetest.pos_to_string(pos)) + local id = R.radiator.store:insert_area(min,max, core.pos_to_string(pos)) R.radiator.sources[phash] = id end function starlit.region.radiator.unload(pos) local R = starlit.region - local phash = minetest.hash_node_position(pos) + local phash = core.hash_node_position(pos) local id = R.radiator.sources[phash] R.radiator.store:remove_area(id) R.radiator.sources[phash] = nil end -minetest.register_lbm { +core.register_lbm { label = 'build radiator index'; name = 'starlit:loadradiatorboxes'; nodenames = {'group:radiator'}; run_at_every_load = true; action = function(pos, node, dt) @@ -269,12 +269,12 @@ function starlit.startJob(id, interval, job) local lastRun local function start() - starlit.jobs[id] = minetest.after(interval, function() - local t = minetest.get_gametime() + starlit.jobs[id] = core.after(interval, function() + local t = core.get_gametime() local d = lastRun and t - lastRun or nil lastRun = t local continue = job(d, interval) if continue == true or continue == nil then start() @@ -309,27 +309,27 @@ starlit.include 'terrain' starlit.include 'interfaces' starlit.include 'compile' starlit.include 'suit' --- minetest.settings:set('movement_gravity', starlit.world.planet.gravity) -- ??? seriously??? +-- core.settings:set('movement_gravity', starlit.world.planet.gravity) -- ??? seriously??? -- THIS OVERRIDES THE GLOBAL SETTING *AND PERSISTS IT* WHAT IN THE SATANIC FUCK --------------- -- callbacks -- --------------- --- here we connect our types up to the minetest API +-- here we connect our types up to the luanti API local function userCB(fn) return function(luser, ...) local name = luser:get_player_name() local user = starlit.activeUsers[name] return fn(user, ...) end end -minetest.register_on_joinplayer(function(luser, lastLogin) +core.register_on_joinplayer(function(luser, lastLogin) -- TODO check that necessary CSMs are installed local user = starlit.type.user(luser) if lastLogin == nil then user:onSignup() @@ -337,15 +337,15 @@ user:onJoin() starlit.activeUsers[user.name] = user end) -minetest.register_on_leaveplayer(function(luser) +core.register_on_leaveplayer(function(luser) starlit.activeUsers[luser:get_player_name()]:onPart() end) -minetest.register_on_player_receive_fields(function(luser, formid, fields) +core.register_on_player_receive_fields(function(luser, formid, fields) local name = luser:get_player_name() local user = starlit.activeUsers[name] if not user then return false end if formid == '' then -- main menu return starlit.ui.userMenuDispatch(user,fields) @@ -364,19 +364,19 @@ starlit.activeUI[name] = nil end return true end) -minetest.register_on_respawnplayer(userCB(function(user) +core.register_on_respawnplayer(userCB(function(user) return user:onRespawn() end)) -minetest.register_on_dieplayer(userCB(function(user, reason) +core.register_on_dieplayer(userCB(function(user, reason) return user:onDie(reason) end)) -minetest.register_on_punchnode(function(pos,node,puncher,point) +core.register_on_punchnode(function(pos,node,puncher,point) local user = starlit.activeUsers[puncher:get_player_name()] local oldTgt = user.action.tgt user.action.tgt = point if bit.band(user.action.bits, 0x80)==0 then user.action.bits = bit.bor(user.action.bits, 0x80) @@ -405,27 +405,27 @@ end -- sigh --[[ core.noneitemdef_default.on_place = function(...) if not triggerPower(...) then - minetest.item_place(...) + core.item_place(...) end end core.noneitemdef_default.on_use = function(...) triggerPower(...) end core.noneitemdef_default.on_secondary_use = function(...) triggerPower(...) end ]] -minetest.register_item(":", { +core.register_item(":", { type = "none", wield_image = "wieldhand.png", wield_scale = {x=1,y=1,z=2.5}, on_secondary_use = function(...) triggerPower(...) end; -- on_use = function(...) print'base' end; after_use = function(i,u,n,p) if (u:is_player()) then triggerPower(i,u,p) end end; }) -minetest.register_item("starlit:_hand_dig", { +core.register_item("starlit:_hand_dig", { type = "none", wield_image = "wieldhand.png", wield_scale = {x=1,y=1,z=2.5}, tool_capabilities = { groupcaps = { @@ -436,11 +436,11 @@ looseClump = {maxlevel=1, times = {1.5, 2.5}}; }; } }) -minetest.register_on_player_inventory_action(function(luser, act, inv, p) +core.register_on_player_inventory_action(function(luser, act, inv, p) local name = luser:get_player_name() local user = starlit.activeUsers[name] -- allow UIs to update on UI changes local state = starlit.activeUI[name] if state then @@ -447,11 +447,11 @@ local ui = starlit.interface.db[state.form] ui:cb('onMoveItem', user, act, inv, p) end end) -minetest.register_on_player_hpchange(function(luser, delta, cause) +core.register_on_player_hpchange(function(luser, delta, cause) local user = starlit.activeUsers[luser:get_player_name()] if cause.type == 'fall' then delta = user:damageModifier('bluntForceTrauma', (delta * 50)) -- justification: a short fall can do around -- five points of damage, which is nearly 50% @@ -460,11 +460,11 @@ -- cranked by similarly end return delta end, true) -function minetest.handle_node_drops(pos, drops, digger) +function core.handle_node_drops(pos, drops, digger) local function jitter(pos) local function r(x) return x+math.random(-0.01, 0.01) end return vector.new( r(pos.x), r(pos.y), @@ -472,11 +472,11 @@ ) end for i, it in ipairs(drops) do if type(it) == 'string' then it = ItemStack(it) end if not it:is_empty() then - local ent = minetest.add_item(jitter(pos), it) + local ent = core.add_item(jitter(pos), it) if ent ~= nil then -- avoid crash when dropping unknown item local dp = vector.new(0,0,0) if digger then dp = digger:get_pos() end local delta = dp - ent:get_pos() ent:add_velocity(vector.new(delta.x,0,delta.z)); Index: mods/starlit/interfaces.lua ================================================================== --- mods/starlit/interfaces.lua +++ mods/starlit/interfaces.lua @@ -567,11 +567,11 @@ end end; render = function(state, user) local body = {kind='vert', w=6; mode='hw', spacing=.5, padding=1 } for i, l in ipairs(state.ctx.inv) do - local inv = minetest.get_meta(l.pos):get_inventory() + local inv = core.get_meta(l.pos):get_inventory() local w = l.w or 6 if l.label then table.insert(body, {kind = 'hbar'; text = l.label, w=w+.5, h = .5}) end table.insert(body, {kind = 'list'; Index: mods/starlit/species.lua ================================================================== --- mods/starlit/species.lua +++ mods/starlit/species.lua @@ -46,11 +46,11 @@ local d = ctx.how.delta local p = user.action.prog.sprint -- is the player currently holding any of WASD local isMoving = bit.band(0x0f, user.entity:get_player_control_bits()) ~= 0 if p and isMoving then - user.cooldownTimes.stamina = minetest.get_gametime() + user.cooldownTimes.stamina = core.get_gametime() p.cb = p.cb + cost*d if p.cb >= 5 then user:statDelta('stamina', -p.cb) p.cb = 0 if user:effectiveStat 'stamina' < cost then halt() end Index: mods/starlit/suit.lua ================================================================== --- mods/starlit/suit.lua +++ mods/starlit/suit.lua @@ -197,11 +197,11 @@ a.suit[name] = img end end end - minetest.register_tool(id, { + core.register_tool(id, { short_description = def.name; description = starlit.ui.tooltip { title = def.name; desc = def.desc; color = lib.color(.1, .7, 1); @@ -315,14 +315,14 @@ suitSlot = true; itemClass = 'canister'; }; } -minetest.register_allow_player_inventory_action(function(luser, act, inv, p) +core.register_allow_player_inventory_action(function(luser, act, inv, p) local user = starlit.activeUsers[luser:get_player_name()] local function grp(i,g) - return minetest.get_item_group(i:get_name(), g) ~= 0 + return core.get_item_group(i:get_name(), g) ~= 0 end local function checkBaseRestrictions(list) local restrictions = slotProps[list] if not restrictions then return nil, true end if restrictions.suitSlot then @@ -352,11 +352,11 @@ local function itemCanLeave(item, list) local rst, ok = checkBaseRestrictions(list) if not ok then return false end if rst == nil then return true end - if minetest.get_item_group(item:get_name(), 'specialInventory') then + if core.get_item_group(item:get_name(), 'specialInventory') then end if rst.maintenanceNode then return false end return true @@ -373,11 +373,11 @@ if not itemCanLeave(p.stack, p.listname) then return 0 end end return true end) -minetest.register_on_player_inventory_action(function(luser, act, inv, p) +core.register_on_player_inventory_action(function(luser, act, inv, p) local user = starlit.activeUsers[luser:get_player_name()] local function slotChange(slot,a,item) local s = slotProps[slot] if slot == 'starlit_suit' then user:updateSuit() Index: mods/starlit/terrain.lua ================================================================== --- mods/starlit/terrain.lua +++ mods/starlit/terrain.lua @@ -32,11 +32,11 @@ {rarity = 2, items = {'starlit:soil_clump'}}; {rarity = 3, items = {'starlit:soil_clump'}}; {rarity = 4, items = {'starlit:soil_clump'}}; }; } -minetest.register_node('starlit:soil', { +core.register_node('starlit:soil', { description = T 'Soil'; tiles = {'starlit-terrain-soil.png'}; groups = {looseClump = 2, soil = 1}; drop = soilDrop; sounds = soilSounds; @@ -46,11 +46,11 @@ recover = soilRec; }; }) -minetest.register_node('starlit:sand', { +core.register_node('starlit:sand', { description = T 'Sand'; tiles = {'starlit-terrain-sand.png'}; groups = {looseClump = 1, sand = 1, falling_node = 1}; drop = ''; sounds = sandSounds; @@ -58,11 +58,11 @@ kind = 'block'; fab = starlit.type.fab { element = { silicon = 25 } }; }; }) -minetest.register_node('starlit:lifesilt', { +core.register_node('starlit:lifesilt', { description = T 'Lifesilt'; tiles = {'starlit-terrain-lifesilt.png'}; groups = {looseClump = 1, lifesilt = 1, falling_node = 1}; drop = ''; sounds = sandSounds; @@ -70,11 +70,11 @@ kind = 'block'; recover = starlit.type.fab { element = { carbon = 16, silicon = 16, rubidium = 4 } }; }; }) -minetest.register_craftitem('starlit:soil_clump', { +core.register_craftitem('starlit:soil_clump', { short_description = T 'Soil'; description = starlit.ui.tooltip { title = T 'Soil'; desc = 'A handful of nutrient-packed soil, suitable for growing plants'; color = lib.color(0.3,0.2,0.1); @@ -81,11 +81,11 @@ }; inventory_image = 'starlit-item-soil.png'; groups = {looseClump = 2, soil = 1}; on_place = function(me, luser, point) if me:get_count() < 3 then return end - if minetest.place_node(point.above, {name = 'starlit:soil'}, luser) then + if core.place_node(point.above, {name = 'starlit:soil'}, luser) then me:take_item(3) end return me end; _starlit = { @@ -101,11 +101,11 @@ items = {'starlit:soil'}, rarity = 2; tool_groups = { 'shovel', 'trowel' }; }; }; } - minetest.register_node(def.name, { + core.register_node(def.name, { description = T 'Greengraze'; tiles = { def.img .. '.png'; 'starlit-terrain-soil.png'; { @@ -138,11 +138,11 @@ img = 'starlit-terrain-undergloam'; recover = soilRec; } for _, w in pairs {false,true} do - minetest.register_node('starlit:liquid_water' .. (w and '_flowing' or ''), { + core.register_node('starlit:liquid_water' .. (w and '_flowing' or ''), { description = T 'Water'; drawtype = 'liquid'; waving = 3; tiles = { { @@ -187,11 +187,11 @@ end starlit.world.mineral.foreach('starlit:mineral-generate', {}, function(node,m) local grp = {mineral = 1} - minetest.register_node(node, { + core.register_node(node, { short_description = m.name; description = starlit.ui.tooltip { title = m.name; desc = m.desc; color = m.tone; @@ -215,11 +215,11 @@ local seed = 0 -- grp.ore = 1 for i = 1, #m.name do seed = seed*50 + string.byte(m.name, i) end - minetest.register_ore { + core.register_ore { ore = node; ore_type = m.dist.kind; wherein = m.dist.among; clust_scarcity = m.dist.rare; clust_num_ores = m.dist.ores; @@ -305,9 +305,9 @@ }; }) -- map generation -minetest.register_alias('mapgen_stone', 'starlit:mineral_feldspar') -minetest.register_alias('mapgen_water_source', 'starlit:liquid_water') -minetest.register_alias('mapgen_river_water_source', 'starlit:liquid_water') +core.register_alias('mapgen_stone', 'starlit:mineral_feldspar') +core.register_alias('mapgen_water_source', 'starlit:liquid_water') +core.register_alias('mapgen_river_water_source', 'starlit:liquid_water') Index: mods/starlit/ui.lua ================================================================== --- mods/starlit/ui.lua +++ mods/starlit/ui.lua @@ -48,11 +48,11 @@ render = function(self, state, user) return self.pages[state.page].render(state, user) end; show = function(self, user) local state = self:begin(user) - minetest.show_formspec(user.name, self.id,self:render(state, user)) + core.show_formspec(user.name, self.id,self:render(state, user)) end; open = function(self, user, page, ...) user:suitSound 'starlit-nav' self:begin(user, page, ...) self:show(user) @@ -60,11 +60,11 @@ close = function(self, user) local state = starlit.activeUI[user.name] if state and state.form == self.id then self:cb('onClose', user) starlit.activeUI[user.name] = nil - minetest.close_formspec(user.name, self.id) + core.close_formspec(user.name, self.id) end end; }; construct = function(p) if not p.id then error('UI missing id') end @@ -100,11 +100,11 @@ } local lines = state.lines local cmod = string.format('^[hsl:%s:%s:%s', state.color.hue, state.color.sat*0xff, state.color.lum*0xff) - local E = minetest.formspec_escape + local E = core.formspec_escape if state.padding/2 > state.x then state.x = state.padding/2 end if state.padding/2 > state.y then state.y = state.padding/2 end local function btnColorDef(sel) local function climg(state,img) Index: mods/starlit/user.lua ================================================================== --- mods/starlit/user.lua +++ mods/starlit/user.lua @@ -8,11 +8,11 @@ -- effecting weather changes, etc. local lib = starlit.mod.lib local function hudAdjustBacklight(img) - local night = math.abs(minetest.get_timeofday() - .5) * 2 + local night = math.abs(core.get_timeofday() - .5) * 2 local opacity = night*0.8 return img:fade(opacity) end local userStore = lib.marshal.metaStore { @@ -68,11 +68,11 @@ leds = leds; construct = function(ident) local name, luser if type(ident) == 'string' then name = ident - luser = minetest.get_player_by_name(name) + luser = core.get_player_by_name(name) else luser = ident name = luser:get_player_name() end return { @@ -115,11 +115,11 @@ __index = { -------------- -- overlays -- -------------- updateOverlays = function(self) - -- minetest: because fuck you, that's why + -- luanti: because fuck you, that's why local engineGravity = starlit.constant.phys.engineGravity local targetGravity = starlit.world.planet.gravity local phys = { speed = self.pheno:trait('speed',1); jump = self.pheno:trait('jump',1); @@ -435,11 +435,11 @@ align = {x=0, y=1}; pos = {x=0.5, y=1}; ofs = {x=0,y=-95}; text = function(user) local cal = starlit.world.time.calendar[user.pref.calendar] - return cal.time(minetest.get_timeofday()) + return cal.time(core.get_timeofday()) end; } self.hud.elt.temp = self:attachMeter { name = 'temp'; align = {x=1, y=-1}; @@ -529,11 +529,11 @@ if e.update then e.update() end end self:updateLEDs() end; updateLEDs = function(self) - local time = minetest.get_gametime() + local time = core.get_gametime() local function updateSide(name, ofs, tx) local del = {} local idx = 0 for i, l in ipairs(self.hud.led[name]) do if time - l.origin > 3 then @@ -607,11 +607,11 @@ --------------------- -- intel-gathering -- --------------------- clientInfo = function(self) - return minetest.get_player_information(self.name) + return core.get_player_information(self.name) end; species = function(self) return starlit.world.species.index[self.persona.species] end; -- can the suit heater sustain its current internal temperature in an area of t°C @@ -689,11 +689,11 @@ local posrng = starlit.world.seedbank[0x13f19] -- TODO player-specific seed local cx = posrng:int(-500,500) --math.random(-500,500) local iter, startPoint = 1 repeat local temp = -100 local cz = posrng:int(-500,500) - local cy = minetest.get_spawn_level(cx, cz) + local cy = core.get_spawn_level(cx, cz) if cy then startPoint = vector.new(cx,cy,cz) temp = starlit.world.climate.eval(startPoint,.5,.5).surfaceTemp end iter = iter + 1 @@ -707,11 +707,11 @@ local where = self.entity:get_pos() local function dropInv(lst) local l = inv:get_list(lst) for i, o in ipairs(l) do if o and not o:is_empty() then - minetest.item_drop(o, self.entity, where) + core.item_drop(o, self.entity, where) end end inv:set_list(lst, {}) end dropInv 'main' @@ -827,11 +827,11 @@ suitStack = function(self) return self.entity:get_inventory():get_stack('starlit_suit', 1) end; suitSound = function(self, sfx) -- trigger a sound effect from the player's suit computer - minetest.sound_play(sfx, {object=self.entity, max_hear_distance=4}, true) + core.sound_play(sfx, {object=self.entity, max_hear_distance=4}, true) end; suitPowerStateSet = function(self, state, silent) -- necessary to enable reacting to power state changes -- e.g. to play sound effects, display warnings local os @@ -1010,11 +1010,11 @@ return false end; alarm = function(self, urgency, kind, minFreq) minFreq = minFreq or 1.5 - local time = minetest.get_gametime() + local time = core.get_gametime() local led = leds[kind] local ul = self.hud.led.map[kind] if ul then if time - ul.origin > minFreq then @@ -1050,11 +1050,11 @@ freq = freq or 3 local urgencies = { [1] = {sound = 'starlit-alarm'}; [2] = {sound = 'starlit-alarm-urgent'}; } - local gt = minetest.get_gametime() + local gt = core.get_gametime() local urg = urgencies[urgency] or urgencies[#urgencies] if gt - self.cooldownTimes.alarm < freq then return end self.cooldownTimes.alarm = gt @@ -1072,11 +1072,11 @@ elt.ofs.y = elt.ofs.y + where.ofs.y local attached = self:attachImage(elt) table.insert(self.hud.alarm, attached) -- HATE. HATE. HAAAAAAAAAAATE - minetest.after(freq/2, function() + core.after(freq/2, function() for k,v in pairs(self.hud.alarm) do self.entity:hud_remove(v.id) end self.hud.alarm={} end) @@ -1098,11 +1098,11 @@ --------------- give = function(self, item) item = ItemStack(item) local inv = self.entity:get_inventory() local function is(grp) - return minetest.get_item_group(item:get_name(), grp) ~= 0 + return core.get_item_group(item:get_name(), grp) ~= 0 end -- TODO notif popups if is 'specialInventory' then --[[ if is 'powder' then @@ -1122,11 +1122,11 @@ end end; thrustUpon = function(self, item) local r = self:give(st) if not r:is_empty() then - return minetest.add_item(self.entity:get_pos(), r) + return core.add_item(self.entity:get_pos(), r) end end; consume = function(self, stack, n) n = n or 1 if n == 0 then n = stack:get_count() end @@ -1217,11 +1217,11 @@ if water == 0 then -- dying of thirst u:statDelta('health', -20*biointerval) end - if sp < 1.0 and minetest.get_gametime() - u.cooldownTimes.stamina > 5.0 then + if sp < 1.0 and core.get_gametime() - u.cooldownTimes.stamina > 5.0 then u:statDelta('stamina', (u:phenoTrait('staminaRegen',1) * penaltyFromFatigue) / heatPenalty) -- print('stam', u:effectiveStat 'stamina', u:phenoTrait('staminaRegen',1) / heatPenalty, heatPenalty) end local morale, mp = u:effectiveStat 'morale' @@ -1242,11 +1242,11 @@ dig = 0x080; put = 0x100; zoom = 0x200; } -- this is the painful part -minetest.register_globalstep(function(delta) +core.register_globalstep(function(delta) local doNothing,mustInit,mustHalt = 0,1,2 for id, user in pairs(starlit.activeUsers) do local ent = user.entity local bits = ent:get_player_control_bits() Index: mods/starlit/world.lua ================================================================== --- mods/starlit/world.lua +++ mods/starlit/world.lua @@ -1,10 +1,10 @@ local lib = starlit.mod.lib local world = starlit.world function world.date() - local days = minetest.get_day_count() + local days = core.get_day_count() local year = math.floor(days / world.planet.orbit); local day = days % world.planet.orbit; return { year = year, day = day; season = day / world.planet.orbit + 0.5; -- begin summer @@ -19,16 +19,16 @@ -- this function provides the basis for temperature calculation, -- which is performed by adding this value to the ambient temperature, -- determined by querying nearby group:heatSource items in accordance -- with the inverse-square law function world.climate.eval(pos, tod, season) - local data = minetest.get_biome_data(pos) - local biome = world.ecology.biomes.db[minetest.get_biome_name(data.biome)] + local data = core.get_biome_data(pos) + local biome = world.ecology.biomes.db[core.get_biome_name(data.biome)] -- print('climate:', dump(data)) local heat, humid = data.heat, data.humidity heat = lerp(heat/100, heatRange.min, heatRange.max) - tod = tod or minetest.get_timeofday() + tod = tod or core.get_timeofday() heat = lerp(math.abs(tod - 0.5)*2, heat, heat + biome.nightTempDelta) -- print('base heat', heat) local td = world.date() heat = heat + gradient(biome.seasonalTemp, season or td.season) @@ -49,19 +49,19 @@ function world.climate.temp(pos, timeshift) --> irradiance at pos in W local cl = world.climate.eval(pos) local radCenters = starlit.region.radiator.store:get_areas_for_pos(pos, false, true) local irradiance = 0 for _,e in pairs(radCenters) do - local rpos = minetest.string_to_pos(e.data) - local rdef = assert(minetest.registered_nodes[assert(minetest.get_node(rpos)).name]) + local rpos = core.string_to_pos(e.data) + local rdef = assert(core.registered_nodes[assert(core.get_node(rpos)).name]) local rc = rdef._starlit.radiator local r_max = rc.radius(rpos) local dist_sq = vdsq(rpos,pos) if dist_sq <= r_max^2 then -- cheap bad way - -- if minetest.line_of_sight(rpos,pos) then + -- if core.line_of_sight(rpos,pos) then -- -- expensive way local obstruct = 0 local ray = Raycast(rpos, pos, true, true) for p in ray do @@ -87,31 +87,31 @@ return irradiance + cl.surfaceTemp end function world.ecology.biomeAt(pos) - return world.ecology.biomes.db[minetest.get_biome_name(minetest.get_biome_data(pos).biome)] + return world.ecology.biomes.db[core.get_biome_name(core.get_biome_data(pos).biome)] end -minetest.after(0, function() - world.climate.weatherMap.kind = minetest.get_perlin { +core.after(0, function() + world.climate.weatherMap.kind = core.get_perlin { seed = 0x925afe; octaves = 2; spread = vector.new(256,256,120); }; - world.climate.weatherMap.severity = minetest.get_perlin { + world.climate.weatherMap.severity = core.get_perlin { seed = 0x39de1d; octaves = 1; spread = vector.new(256,256,60); }; end) function world.climate.weatherAt(pos, timeshift) timeshift = timeshift or 0 - local wv = world.climate.weatherMap.kind:get_3d(vector.new(pos.x, pos.z, minetest.get_gametime() + timeshift)) - local sev = world.climate.weatherMap.severity:get_3d(vector.new(pos.x, pos.z, minetest.get_gametime() + timeshift)) + local wv = world.climate.weatherMap.kind:get_3d(vector.new(pos.x, pos.z, core.get_gametime() + timeshift)) + local sev = world.climate.weatherMap.severity:get_3d(vector.new(pos.x, pos.z, core.get_gametime() + timeshift)) local b = world.ecology.biomeAt(pos) local w = 'starlit:clear' for i,v in ipairs(b.weather) do if wv < v[1] then w = v[2] @@ -196,11 +196,11 @@ danger = 2; }) world.ecology.biomes.foreach('starlit:biome-gen', {}, function(id, b) b.def.name = id - minetest.register_biome(b.def) + core.register_biome(b.def) end) world.ecology.plants.foreach('starlit:plant-gen', {}, function(id, b) local stageCt = #b.stages local function stageID(n) @@ -246,20 +246,20 @@ } if st.swap then base.node_dig_prediction = "" function base.after_dig_node(pos, node, digger) node.name = stageID(st.swap) - minetest.swap_node(pos, node) + core.swap_node(pos, node) return true end end if st.biolum then base.light_source = st.biolum; end return base end for i, v in ipairs(b.stages) do local n = regStage(i, v) - minetest.register_node(stageID(i), n) + core.register_node(stageID(i), n) b.stageNodes[i] = stageID(i) end b.fullyGrown = stageID(stageCt) local dec = { @@ -267,11 +267,11 @@ decoration = b.stageNodes; height = 1; param2 = b.meshOpt or 0; } for k,v in pairs(b.decoration) do dec[k] = v end - b.decoration = minetest.register_decoration(dec) + b.decoration = core.register_decoration(dec) end) local toward = lib.math.toward local hfinterval = 1.5 starlit.startJob('starlit:temps', hfinterval, function(delta) @@ -287,11 +287,11 @@ -- too cold: -- x = beginning of danger zone -- κ × (x - Tₚ) = y where y < Tₚ -- our final change in temperature is computed as tΔC where t is time local kappa = starlit.constant.heat.thermalConductivity - local now = minetest.get_gametime() + local now = core.get_gametime() for name,user in pairs(starlit.activeUsers) do local tr = user:species().tempRange local t = starlit.world.climate.temp(user.entity:get_pos()) local weather,wsev = starlit.world.climate.weatherAt(user.entity:get_pos()) @@ -381,25 +381,25 @@ local dec = { deco_type = 'lsystem'; treedef = t.def; } for k,v in pairs(td) do dec[k]=v end - minetest.register_decoration(dec) + core.register_decoration(dec) end end) -minetest.register_abm { +core.register_abm { label = "plant growth"; nodenames = {'group:plant_grow'}; chance = 15; interval = 20; catch_up = true; action = function(pos, node) - local def = minetest.registered_nodes[node.name]._starlit.plant + local def = core.registered_nodes[node.name]._starlit.plant -- 5 W: maximum power for UV lamps -- 7 W: maximum solar power - local uv = (minetest.get_natural_light(pos) / 15) * 7 + local uv = (core.get_natural_light(pos) / 15) * 7 -- TODO compute artificial contribution local req = lib.tbl.defaults({ uv = 3; soil = 'soil'; temp = -10; @@ -409,9 +409,9 @@ -- TODO check other reqs if uv > req.uv then local plant = starlit.world.ecology.plants.db[def.id] local nextStage = plant.stageNodes[def.stage + 1] - minetest.swap_node(pos, {name=nextStage}) + core.swap_node(pos, {name=nextStage}) end end; } Index: mods/vtlib/color.lua ================================================================== --- mods/vtlib/color.lua +++ mods/vtlib/color.lua @@ -127,15 +127,15 @@ int = function(self) return bit.bor(bit.lshift(self:int24(), 8), math.floor(0xff*(self.alpha or 1.0))) end; fmt = function(self, text) return - minetest.colorize(self:hex(), text) + core.colorize(self:hex(), text) end; bg = function(self, text) return - text .. minetest.get_background_escape_sequence(self:hex()) + text .. core.get_background_escape_sequence(self:hex()) end; lum = function(self) return (self.red + self.green + self.blue) / 3 end; Index: mods/vtlib/dbg.lua ================================================================== --- mods/vtlib/dbg.lua +++ mods/vtlib/dbg.lua @@ -8,11 +8,11 @@ function dbg.debugger(area) local depth = 0 local d = {} function d.enter() depth = depth+1 end function d.exit() depth = depth-1 end - local mod = minetest.get_current_modname() + local mod = core.get_current_modname() if dbg.aloud then function d.report(fmt, ...) local where = debug.getinfo(2) local caller = debug.getinfo(3) if mod and (lastmod ~= mod or lastarea ~= area) then Index: mods/vtlib/init.lua ================================================================== --- mods/vtlib/init.lua +++ mods/vtlib/init.lua @@ -1,7 +1,7 @@ -local ident = minetest.get_current_modname() -local path = minetest.get_modpath(ident) +local ident = core.get_current_modname() +local path = core.get_modpath(ident) local lib = {} _G[ident] = lib local function Index: mods/vtlib/item.lua ================================================================== --- mods/vtlib/item.lua +++ mods/vtlib/item.lua @@ -14,11 +14,11 @@ end end end -- it is extremely unfortunate this function needs to exist. --- minetest needs to export its matching capabilities already +-- luanti needs to export its matching capabilities already fn.groupmatch = function(identity,item,exact) if exact == nil then exact = true end local count if type(identity) == 'table' then count = identity.count @@ -39,11 +39,11 @@ if lib.str.beginswith(identity, 'group:') then local stack = ItemStack(item) local groups = lib.str.explode(string.sub(identity,7), ',') for _,g in pairs(groups) do local rn,rv = lib.tbl.split(g,'=') - local gv = minetest.get_item_group(stack:get_name(), rn) + local gv = core.get_item_group(stack:get_name(), rn) if rv then if gv ~= tonumber(rv) then return false, stack end else if (not gv) or gv == 0 then return false, stack end end Index: mods/vtlib/marshal.lua ================================================================== --- mods/vtlib/marshal.lua +++ mods/vtlib/marshal.lua @@ -93,11 +93,11 @@ return encoder end function m.metaStore(map, prefix) report('generating metaStore for %s', dump(map)) - if prefix == true then prefix = minetest.get_current_modname() end + if prefix == true then prefix = core.get_current_modname() end local function keyFor(k) k = map[k].key if prefix then return prefix .. ':' .. k end return k end Index: mods/vtlib/math.lua ================================================================== --- mods/vtlib/math.lua +++ mods/vtlib/math.lua @@ -3,11 +3,11 @@ fn.vsep = function(vec) -- separate a vector into a direction + magnitude return vec:normalize(), vec:length() end --- minetest now only provides the version of this function that sqrts the result +-- luanti now only provides the version of this function that sqrts the result -- which is pointlessly wasteful much of the time fn.vdsq = function(a,b) local d = vector.subtract(a,b) return (d.x ^ 2) + (d.y ^ 2) + (d.z ^ 2) end Index: mods/vtlib/node.lua ================================================================== --- mods/vtlib/node.lua +++ mods/vtlib/node.lua @@ -66,23 +66,23 @@ end for name, inv in pairs(meta.inventory) do if only and not lib.tbl.has(only,name) then goto skip end for _, item in pairs(inv) do if not item:is_empty() then - minetest.add_item(offset(pos,0.4), item) + core.add_item(offset(pos,0.4), item) end end ::skip::end end; local force = function(pos,preload_for) - local n = minetest.get_node_or_nil(pos) + local n = core.get_node_or_nil(pos) if preload_for then lib.node.preload(pos,preload_for) end if n then return n end - minetest.load_area(pos) - return minetest.get_node(pos) + core.load_area(pos) + return core.get_node(pos) end; local amass = function(startpoint,names,directions) if not directions then directions = ofs.neighbors end local check = function(n) @@ -125,18 +125,18 @@ end; local is_air = function(pos) local n = force(pos) if n.name == 'air' then return true end - local d = minetest.registered_nodes[n.name] + local d = core.registered_nodes[n.name] if not d then return false end return (d.walkable == false) and (d.drawtype == 'airlike' or d.buildable_to == true) end; local is_clear = function(pos) if not lib.node.is_air(pos) then return false end - local ents = minetest.get_objects_inside_radius(pos,0.5) + local ents = core.get_objects_inside_radius(pos,0.5) if #ents > 0 then return false end return true end; local function boxwarp(nb, mogrifier, par) @@ -186,11 +186,11 @@ is_air = is_air; is_clear = is_clear; insert = function(item, slot, npos, user, inv) - inv = inv or minetest.get_meta(npos):get_inventory() + inv = inv or core.get_meta(npos):get_inventory() if inv:room_for_item(slot,item) then inv:add_item(slot,item) else repeat if user then local ui = user:get_inventory() @@ -197,27 +197,27 @@ if ui:room_for_item('main', item) then ui:add_item('main', item) break end end - minetest.add_item(npos, item) + core.add_item(npos, item) until true end end; install_bed = function(bed, where, dir) local bottom = bed .. '_bottom' local top = bed .. '_top' local d if type(dir) == 'number' then d = dir - dir = minetest.facedir_to_dir(d) + dir = core.facedir_to_dir(d) else - d = minetest.dir_to_facedir(dir) + d = core.dir_to_facedir(dir) end if not is_clear(where) and is_clear(where - dir) then return false end - minetest.set_node(where, {name = top, param2 = d}) - minetest.set_node(where - dir, {name = bottom, param2 = d}) + core.set_node(where, {name = top, param2 = d}) + core.set_node(where - dir, {name = bottom, param2 = d}) return true end; get_arrival_point = function(pos) local try = function(p) @@ -238,14 +238,14 @@ forneighbor = function(pos, n, fn) for _,p in pairs(n) do local sum = vector.add(pos, p) - local n = minetest.get_node(sum) + local n = core.get_node(sum) if n.name == 'ignore' then - minetest.load_area(sum) - n = minetest.get_node(sum) + core.load_area(sum) + n = core.get_node(sum) end if fn(sum, n) == false then break end end end; @@ -260,19 +260,19 @@ z = math.floor(pos.z / 16); } end; preload = function(pos, user) - minetest.load_area(pos) + core.load_area(pos) user:send_mapblock(lib.node.blockpos(pos)) end; discharger = function(pos) local below = force(vector.subtract(pos,{x=0,y=1,z=0})) if below.name == 'hopper:hopper' or below.name == 'hopper:hopper_side' then - local hopper = minetest.get_meta(below):get_inventory() + local hopper = core.get_meta(below):get_inventory() return function(i) if hopper:room_for_item('main',i) then return hopper:add_item('main',i), true end return i, false @@ -289,11 +289,11 @@ { items = {id} }; }; } local next_apn = tbl.after_place_node tbl.after_place_node = function(...) local pos, who, stack = ... - minetest.get_meta(pos):from_table(stack:get_meta():to_table()) + core.get_meta(pos):from_table(stack:get_meta():to_table()) if next_apn then return next_apn(...) end end local next_pm = tbl.preserve_metadata tbl.preserve_metadata = function(...) local pos, node, meta, drops = ... drops[1]:get_meta():from_table({fields = meta}) @@ -300,11 +300,11 @@ if next_pm then return next_pm(...) end end return tbl end; reg_autopreserve = function(id, tbl) - minetest.register_node(id, lib.node.autopreserve(id, tbl)) + core.register_node(id, lib.node.autopreserve(id, tbl)) end; boxwarp = boxwarp; boxwarped = boxwarped; } Index: mods/vtlib/obj.lua ================================================================== --- mods/vtlib/obj.lua +++ mods/vtlib/obj.lua @@ -4,34 +4,34 @@ local fn = {} local lib = ... -- WARNING: INEFFICIENT AS FUCK fn.identify = function(objref) --> objectid - for _, o in pairs(minetest.get_connected_players()) do + for _, o in pairs(core.get_connected_players()) do if objref == o then return o:get_player_name(), 'player' end end - for id, le in pairs(minetest.luaentities) do + for id, le in pairs(core.luaentities) do if le.object == objref then return id, 'entity' end end end fn.handle = lib.class { __newindex = function(self,key,newval) local hnd if self.player - then hnd = minetest.get_player_by_name(self._id) - else hnd = minetest.luaentities[self._id] + then hnd = core.get_player_by_name(self._id) + else hnd = core.luaentities[self._id] end if key == 'id' then if type(newval) == 'string' then - local p = minetest.get_player_by_name(newval) + local p = core.get_player_by_name(newval) if p then self._id = newval self.player = true return end end - if minetest.luaentities[newval] then + if core.luaentities[newval] then self._id = newval self.player = false else error('attempted to assign invalid ID to entity handle') end elseif key == 'obj' then local no, kind = fn.identify(newval) @@ -46,13 +46,13 @@ hnd:set_item(newval) end end; __index = function(self,key) local hnd if self.player then - hnd = minetest.get_player_by_name(self._id) + hnd = core.get_player_by_name(self._id) else - hnd = minetest.luaentities[self._id] + hnd = core.luaentities[self._id] end if key == 'online' then return hnd ~= nil elseif key == 'id' then if self.player then return nil @@ -87,14 +87,14 @@ end end end; construct = function(h) local kind, id - if type(h) == 'string' and minetest.get_player_by_name(h) ~= nil then + if type(h) == 'string' and core.get_player_by_name(h) ~= nil then kind = 'player'; id = h - elseif minetest.luaentities[h] then + elseif core.luaentities[h] then kind = 'entity'; id = h else id, kind = fn.identify(h) end if not id then Index: mods/vtlib/str.lua ================================================================== --- mods/vtlib/str.lua +++ mods/vtlib/str.lua @@ -16,12 +16,12 @@ ['\xf4'] = '\0'; }; } local utf8 -if _G.minetest then - if minetest.global_exists 'utf8' then +if _G.core then + if core.global_exists 'utf8' then utf8 = _G.utf8 end else utf8 = _G.utf8 end @@ -204,11 +204,11 @@ end; meta_armor = function(str,mark_struct) -- binary values stored in metadata need to be sanitized so -- they don't contain values that will disrupt parsing of the - -- KV store, as minetest (stupidly) uses in-band signalling + -- KV store, as luanti (stupidly) uses in-band signalling local sanitized = string.gsub(str, '.', function(char) if sanitable.from[char] then return '\xfe' .. sanitable.from[char] else return char end end) Index: mods/vtlib/ui.lua ================================================================== --- mods/vtlib/ui.lua +++ mods/vtlib/ui.lua @@ -12,11 +12,11 @@ end; attach = function(self, elt, x, y, w, h, ...) local content = '' if self.width - self.curs.x < w then self:nl() end for _, v in pairs{...} do - content = content .. ';' .. minetest.formspec_escape(tostring(v)) + content = content .. ';' .. core.formspec_escape(tostring(v)) end self.src = self.src .. string.format('%s[%f,%f;%f,%f%s]', elt, x,y, w,h, content) if h > self.curs.maxh then self.curs.maxh = h end end; add = function(self, elt, w, h, ...) @@ -47,11 +47,11 @@ return function(a) local color = a.color and a.color:readable(0.65, 1.0) if color == nil then color = l.color(.5,.5,.5) end local str = a.title if a.desc then - str = str .. '\n' .. color:fmt(minetest.wrap_text(a.desc,60)) + str = str .. '\n' .. color:fmt(core.wrap_text(a.desc,60)) end if a.props then -- str = str .. '\n' for _,prop in pairs(a.props) do local c @@ -67,11 +67,11 @@ if prop.title then str = str .. c:brighten(1.2):fmt(prop.title) .. ': ' end - local lines = minetest.wrap_text(prop.desc, 55, true) + local lines = core.wrap_text(prop.desc, 55, true) str = str .. c:fmt(lines[1]) for i=2,#lines do str = str .. '\n' .. string.rep(' ',5) .. c:fmt(lines[i]) end end Index: starlit.ct ================================================================== --- starlit.ct +++ starlit.ct @@ -44,31 +44,31 @@ $ curl https://c.hale.su/starlit/uv/asset.cpxz | xzcat | cpio -i ~~~ eventually i might make proper release tarballs available that bundle the game and assets together, but the game isn't stable enough to do that yet. ## engine -starlit is developed against a bleeding-edge version of minetest. it definitely won't work with anything older than v5.7, and ideally you should build directly from master. +starlit is developed against a bleeding-edge version of Luanti. it definitely won't work with anything older than v5.7, and ideally you should build directly from master. -starlit is best used with a patched version of minetest, though it is compatible with vanilla. the recommended patches are: +starlit is best used with a patched version of Luanti, though it is compatible with vanilla. the recommended patches are: * [>p11143 11143] - fix third-person view orientation p11143: https://github.com/minetest/minetest/pull/11143.diff ### shadows -i was delighted to see dynamic shadows land in minetest, and i hope the implementation will eventually mature. however, as it stands, there are severe issues with shadows that make them essentially incompatible with complex meshes like the Starlit player character meshes. for the sake of those who don't mind these glitches, Starlit does enable shadows, but i unfortunately have to recommend that you disable them until the minetest devs get their act together on this feature. +i was delighted to see dynamic shadows land in Luanti, and i hope the implementation will eventually mature. however, as it stands, there are severe issues with shadows that make them essentially incompatible with complex meshes like the Starlit player character meshes. for the sake of those who don't mind these glitches, Starlit does enable shadows, but i unfortunately have to recommend that you disable them until the Luanti devs get their act together on this feature. ## gameplay -starlit is somewhat unusual in how it uses the minetest engine. it's a voxel game but not of the minecraft variety. you do have some control over your environment, but it's limited and exerting it is much more expensive than you might be used to -- the focus of the game is figuring out how to work with nature, not against it. Farthest Shadow has little patience for those who do not show her the respect a living world is due, and she is unconcerned with human virtues like "mercy" or "fairness" or "proportionate retribution". +starlit is somewhat unusual in how it uses the Luanti engine. it's a voxel game but not of the minecraft variety. you do have some control over your environment, but it's limited and exerting it is much more expensive than you might be used to -- the focus of the game is figuring out how to work with nature, not against it. Farthest Shadow has little patience for those who do not show her the respect a living world is due, and she is unconcerned with human virtues like "mercy" or "fairness" or "proportionate retribution". this is to say, starlit is [*mean], by design. * chance plays an important role. your escape pod might land in the midst of a lush, temperate forest with plenty of nearby shipwrecks to scavenge. or it might land in the exact geographic center of a vast, harsh desert that your suit's cooling systems can't protect you from, ten klicks from anything of value. "unfair", you say? tough. Farthest Shadow doesn't care about your feelings. * death is much worse than a slap on the wrist. when you die, you drop your possessions and your suit, and respawn naked at your spawn point. this is a serious danger, as you might be kilometers away from your spawn point -- and there's no guarantee someone else won't take your suit before you can find your way back to it. good luck crossing long distances without climate control! if you haven't carefully prepared for this eventuality by keeping a spare suit by your spawn point, death can be devastating, to the point of making the game unsurvivable without another player's help. ### scenarios -your starting character configuration depends on the scenario you select. (right now this is configured in minetest settings, which is intensely awkward, but i don't have a better solution). the scenario controls your species, sex, and starting inventory. [*neither species nor sex is cosmetic]; e.g. human females are physically weaker but psionically stronger than males. the current playable scenarios are: +your starting character configuration depends on the scenario you select. (right now this is configured in Luanti settings, which is intensely awkward, but i don't have a better solution). the scenario controls your species, sex, and starting inventory. [*neither species nor sex is cosmetic]; e.g. human females are physically weaker but psionically stronger than males. the current playable scenarios are: #### Imperial Expat [*phenotype]: human female [*starting gear]: Commune survival kit > Hoping to escape a miserable life deep in the grinding gears of the capitalist machine for the bracing freedom of the frontier, you sought entry as a colonist to the new Commune world of Thousand Petal. Fate -- which is to say, terrorists -- intervened, and you wound up stranded on Farthest Shadow with little more than the nanosuit on your back, ship blown to tatters and your soul thoroughly mauled by the explosion of a twisted alien artifact -- which SOMEONE neglected to inform you your ride would be carrying. @@ -161,6 +161,6 @@ a Contextual ability is triggered in a specific situation, usually by interacting with a certain kind of object. Contextual abilities often require specialized equipment, to the point that many Starlit practitioners maintain their own Psionics Lab. ## legal starlit source code (*.lua, *.conf, *.txt, *.csd files) is released under the GNU AGPLv3. assets (images, sounds, models, and anything else in the repo that doesn't qualify as source code) are released under the CC-BY-NC-SA 3.0 license. -sound files with the prefix `default-` are taken from Minetest Game, whose assets are available under the CC-BY-SA 3.0 license. +sound files with the prefix `default-` are taken from Luanti Game, whose assets are available under the CC-BY-SA 3.0 license.