Differences From
Artifact [9accce5f34]:
6 6 -- client. it provides for initial signup and join,
7 7 -- managing the HUD, skinning the player model,
8 8 -- effecting weather changes, etc.
9 9
10 10 local lib = starlit.mod.lib
11 11
12 12 local function hudAdjustBacklight(img)
13 - local night = math.abs(minetest.get_timeofday() - .5) * 2
13 + local night = math.abs(core.get_timeofday() - .5) * 2
14 14 local opacity = night*0.8
15 15 return img:fade(opacity)
16 16 end
17 17
18 18 local userStore = lib.marshal.metaStore {
19 19 persona = {
20 20 key = 'starlit:persona';
................................................................................
66 66 starlit.type.user = lib.class {
67 67 name = 'starlit:user';
68 68 leds = leds;
69 69 construct = function(ident)
70 70 local name, luser
71 71 if type(ident) == 'string' then
72 72 name = ident
73 - luser = minetest.get_player_by_name(name)
73 + luser = core.get_player_by_name(name)
74 74 else
75 75 luser = ident
76 76 name = luser:get_player_name()
77 77 end
78 78 return {
79 79 entity = luser;
80 80 name = name;
................................................................................
113 113 }
114 114 end;
115 115 __index = {
116 116 --------------
117 117 -- overlays --
118 118 --------------
119 119 updateOverlays = function(self)
120 - -- minetest: because fuck you, that's why
120 + -- luanti: because fuck you, that's why
121 121 local engineGravity = starlit.constant.phys.engineGravity
122 122 local targetGravity = starlit.world.planet.gravity
123 123 local phys = {
124 124 speed = self.pheno:trait('speed',1);
125 125 jump = self.pheno:trait('jump',1);
126 126 gravity = targetGravity / engineGravity;
127 127 speed_climb = 1;
................................................................................
433 433 self.hud.elt.time = self:attachTextBox {
434 434 name = 'time';
435 435 align = {x=0, y=1};
436 436 pos = {x=0.5, y=1};
437 437 ofs = {x=0,y=-95};
438 438 text = function(user)
439 439 local cal = starlit.world.time.calendar[user.pref.calendar]
440 - return cal.time(minetest.get_timeofday())
440 + return cal.time(core.get_timeofday())
441 441 end;
442 442 }
443 443 self.hud.elt.temp = self:attachMeter {
444 444 name = 'temp';
445 445 align = {x=1, y=-1};
446 446 pos = {x=0, y=1};
447 447 ofs = {x=20, y=-20};
................................................................................
527 527 updateHUD = function(self)
528 528 for name, e in pairs(self.hud.elt) do
529 529 if e.update then e.update() end
530 530 end
531 531 self:updateLEDs()
532 532 end;
533 533 updateLEDs = function(self)
534 - local time = minetest.get_gametime()
534 + local time = core.get_gametime()
535 535 local function updateSide(name, ofs, tx)
536 536 local del = {}
537 537 local idx = 0
538 538 for i, l in ipairs(self.hud.led[name]) do
539 539 if time - l.origin > 3 then
540 540 if l.elt then self.entity:hud_remove(l.elt.id) end
541 541 self.hud.led.map[l.kind] = nil
................................................................................
605 605 inv:set_stack('hand', 1, hnd)
606 606 end;
607 607
608 608 ---------------------
609 609 -- intel-gathering --
610 610 ---------------------
611 611 clientInfo = function(self)
612 - return minetest.get_player_information(self.name)
612 + return core.get_player_information(self.name)
613 613 end;
614 614 species = function(self)
615 615 return starlit.world.species.index[self.persona.species]
616 616 end;
617 617 -- can the suit heater sustain its current internal temperature in an area of t°C
618 618 tempCanSustain = function(self, t)
619 619 if self:naked() then return false end
................................................................................
687 687
688 688 -- i feel like there has to be a better way
689 689 local posrng = starlit.world.seedbank[0x13f19] -- TODO player-specific seed
690 690 local cx = posrng:int(-500,500) --math.random(-500,500)
691 691 local iter, startPoint = 1
692 692 repeat local temp = -100
693 693 local cz = posrng:int(-500,500)
694 - local cy = minetest.get_spawn_level(cx, cz)
694 + local cy = core.get_spawn_level(cx, cz)
695 695 if cy then
696 696 startPoint = vector.new(cx,cy,cz)
697 697 temp = starlit.world.climate.eval(startPoint,.5,.5).surfaceTemp
698 698 end
699 699 iter = iter + 1
700 700 if iter > 100 then break end -- avoid infiniloop in pathological conditions
701 701 until temp > -2
................................................................................
705 705 onDie = function(self, reason)
706 706 local inv = self.entity:get_inventory()
707 707 local where = self.entity:get_pos()
708 708 local function dropInv(lst)
709 709 local l = inv:get_list(lst)
710 710 for i, o in ipairs(l) do
711 711 if o and not o:is_empty() then
712 - minetest.item_drop(o, self.entity, where)
712 + core.item_drop(o, self.entity, where)
713 713 end
714 714 end
715 715 inv:set_list(lst, {})
716 716 end
717 717 dropInv 'main'
718 718 dropInv 'starlit_suit'
719 719 self:updateSuit()
................................................................................
825 825 -- environment suit & body --
826 826 -----------------------------
827 827 suitStack = function(self)
828 828 return self.entity:get_inventory():get_stack('starlit_suit', 1)
829 829 end;
830 830 suitSound = function(self, sfx)
831 831 -- trigger a sound effect from the player's suit computer
832 - minetest.sound_play(sfx, {object=self.entity, max_hear_distance=4}, true)
832 + core.sound_play(sfx, {object=self.entity, max_hear_distance=4}, true)
833 833 end;
834 834 suitPowerStateSet = function(self, state, silent)
835 835 -- necessary to enable reacting to power state changes
836 836 -- e.g. to play sound effects, display warnings
837 837 local os
838 838 self:forSuit(function(s)
839 839 os=s:powerState()
................................................................................
1008 1008 return true
1009 1009 end
1010 1010 return false
1011 1011 end;
1012 1012
1013 1013 alarm = function(self, urgency, kind, minFreq)
1014 1014 minFreq = minFreq or 1.5
1015 - local time = minetest.get_gametime()
1015 + local time = core.get_gametime()
1016 1016 local led = leds[kind]
1017 1017
1018 1018 local ul = self.hud.led.map[kind]
1019 1019 if ul then
1020 1020 if time - ul.origin > minFreq then
1021 1021 ul.origin = time
1022 1022 else return end
................................................................................
1048 1048
1049 1049 --[[
1050 1050 freq = freq or 3
1051 1051 local urgencies = {
1052 1052 [1] = {sound = 'starlit-alarm'};
1053 1053 [2] = {sound = 'starlit-alarm-urgent'};
1054 1054 }
1055 - local gt = minetest.get_gametime()
1055 + local gt = core.get_gametime()
1056 1056 local urg = urgencies[urgency] or urgencies[#urgencies]
1057 1057
1058 1058 if gt - self.cooldownTimes.alarm < freq then return end
1059 1059
1060 1060 self.cooldownTimes.alarm = gt
1061 1061 self:suitSound(urg.sound)
1062 1062
................................................................................
1070 1070 }
1071 1071 elt.ofs.x = elt.ofs.x + where.ofs.x
1072 1072 elt.ofs.y = elt.ofs.y + where.ofs.y
1073 1073 local attached = self:attachImage(elt)
1074 1074 table.insert(self.hud.alarm, attached)
1075 1075
1076 1076 -- HATE. HATE. HAAAAAAAAAAATE
1077 - minetest.after(freq/2, function()
1077 + core.after(freq/2, function()
1078 1078 for k,v in pairs(self.hud.alarm) do
1079 1079 self.entity:hud_remove(v.id)
1080 1080 end
1081 1081 self.hud.alarm={}
1082 1082 end)
1083 1083 end]]
1084 1084 end;
................................................................................
1096 1096 ---------------
1097 1097 -- inventory --
1098 1098 ---------------
1099 1099 give = function(self, item)
1100 1100 item = ItemStack(item)
1101 1101 local inv = self.entity:get_inventory()
1102 1102 local function is(grp)
1103 - return minetest.get_item_group(item:get_name(), grp) ~= 0
1103 + return core.get_item_group(item:get_name(), grp) ~= 0
1104 1104 end
1105 1105 -- TODO notif popups
1106 1106 if is 'specialInventory' then
1107 1107 --[[
1108 1108 if is 'powder' then
1109 1109 if self:naked() then return item end
1110 1110 local cans = inv:get_list 'starlit_suit_canisters'
................................................................................
1120 1120 else
1121 1121 return inv:add_item('main', item)
1122 1122 end
1123 1123 end;
1124 1124 thrustUpon = function(self, item)
1125 1125 local r = self:give(st)
1126 1126 if not r:is_empty() then
1127 - return minetest.add_item(self.entity:get_pos(), r)
1127 + return core.add_item(self.entity:get_pos(), r)
1128 1128 end
1129 1129 end;
1130 1130 consume = function(self, stack, n)
1131 1131 n = n or 1
1132 1132 if n == 0 then n = stack:get_count() end
1133 1133 local fd = stack:take_item(n)
1134 1134 local stats = starlit.world.food.effectiveStats(fd)
................................................................................
1215 1215 u:statDelta('health', -5*biointerval)
1216 1216 end
1217 1217
1218 1218 if water == 0 then -- dying of thirst
1219 1219 u:statDelta('health', -20*biointerval)
1220 1220 end
1221 1221
1222 - if sp < 1.0 and minetest.get_gametime() - u.cooldownTimes.stamina > 5.0 then
1222 + if sp < 1.0 and core.get_gametime() - u.cooldownTimes.stamina > 5.0 then
1223 1223 u:statDelta('stamina', (u:phenoTrait('staminaRegen',1) * penaltyFromFatigue) / heatPenalty)
1224 1224 -- print('stam', u:effectiveStat 'stamina', u:phenoTrait('staminaRegen',1) / heatPenalty, heatPenalty)
1225 1225 end
1226 1226
1227 1227 local morale, mp = u:effectiveStat 'morale'
1228 1228 local pr = u:phenoTrait 'numinaRegen'
1229 1229 u:statDelta('numina', pr * penaltyFromFatigue * mp)
................................................................................
1240 1240 manv = 0x020;
1241 1241 snk = 0x040;
1242 1242 dig = 0x080;
1243 1243 put = 0x100;
1244 1244 zoom = 0x200;
1245 1245 }
1246 1246 -- this is the painful part
1247 -minetest.register_globalstep(function(delta)
1247 +core.register_globalstep(function(delta)
1248 1248 local doNothing,mustInit,mustHalt = 0,1,2
1249 1249 for id, user in pairs(starlit.activeUsers) do
1250 1250 local ent = user.entity
1251 1251 local bits = ent:get_player_control_bits()
1252 1252
1253 1253 local function what(b)
1254 1254 if bit.band(bits, b) ~= 0 and bit.band(user.action.bits, b) == 0 then