mirror of
https://github.com/mt-mods/spacesuit.git
synced 2026-07-06 10:36:53 -06:00
core -> minetest and fix some formating/style (#16)
Co-authored-by: Sheriff_U3 <sheriff_u3@noreply.codeberg.org>
This commit is contained in:
+2
-1
@@ -4,8 +4,9 @@ globals = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
read_globals = {
|
read_globals = {
|
||||||
-- Minetest
|
-- Luanti
|
||||||
"minetest",
|
"minetest",
|
||||||
|
"core",
|
||||||
|
|
||||||
-- Deps
|
-- Deps
|
||||||
"armor",
|
"armor",
|
||||||
|
|||||||
+4
-6
@@ -1,6 +1,4 @@
|
|||||||
|
core.register_craft({
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "spacesuit:helmet",
|
output = "spacesuit:helmet",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
||||||
@@ -9,7 +7,7 @@ minetest.register_craft({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = "spacesuit:chestplate",
|
output = "spacesuit:chestplate",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"default:steel_ingot", "default:mese", "default:steel_ingot"},
|
{"default:steel_ingot", "default:mese", "default:steel_ingot"},
|
||||||
@@ -18,7 +16,7 @@ minetest.register_craft({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = "spacesuit:pants",
|
output = "spacesuit:pants",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"default:steel_ingot", "wool:white", "default:steel_ingot"},
|
{"default:steel_ingot", "wool:white", "default:steel_ingot"},
|
||||||
@@ -27,7 +25,7 @@ minetest.register_craft({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = "spacesuit:boots",
|
output = "spacesuit:boots",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"default:steel_ingot", "wool:white", "default:steel_ingot"},
|
{"default:steel_ingot", "wool:white", "default:steel_ingot"},
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
default
|
|
||||||
3d_armor
|
|
||||||
+5
-7
@@ -10,9 +10,7 @@ local function check_player(player, timer)
|
|||||||
local has_chestplate = armor_inv:contains_item("armor", "spacesuit:chestplate")
|
local has_chestplate = armor_inv:contains_item("armor", "spacesuit:chestplate")
|
||||||
local has_pants = armor_inv:contains_item("armor", "spacesuit:pants")
|
local has_pants = armor_inv:contains_item("armor", "spacesuit:pants")
|
||||||
local has_boots = armor_inv:contains_item("armor", "spacesuit:boots")
|
local has_boots = armor_inv:contains_item("armor", "spacesuit:boots")
|
||||||
|
|
||||||
local has_full_suit = has_helmet and has_chestplate and has_pants and has_boots
|
local has_full_suit = has_helmet and has_chestplate and has_pants and has_boots
|
||||||
|
|
||||||
local armor_list = armor_inv:get_list("armor")
|
local armor_list = armor_inv:get_list("armor")
|
||||||
|
|
||||||
-- does the player wear a suit?
|
-- does the player wear a suit?
|
||||||
@@ -24,7 +22,7 @@ local function check_player(player, timer)
|
|||||||
if not stack:is_empty() then
|
if not stack:is_empty() then
|
||||||
local name = stack:get_name()
|
local name = stack:get_name()
|
||||||
if name:sub(1, 10) == "spacesuit:" then
|
if name:sub(1, 10) == "spacesuit:" then
|
||||||
local use = minetest.get_item_group(name, "armor_use") * timer or 0
|
local use = (core.get_item_group(name, "armor_use") * timer) or 0
|
||||||
armor:damage(player, i, stack, use)
|
armor:damage(player, i, stack, use)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -34,10 +32,10 @@ local function check_player(player, timer)
|
|||||||
|
|
||||||
elseif not has_full_suit then
|
elseif not has_full_suit then
|
||||||
-- check if player is in vacuum without spacesuit
|
-- check if player is in vacuum without spacesuit
|
||||||
local is_admin = minetest.check_player_privs(player:get_player_name(), "privs")
|
local is_admin = core.check_player_privs(player:get_player_name(), "privs")
|
||||||
if not is_admin then
|
if not is_admin then
|
||||||
local ppos = player:get_pos()
|
local ppos = player:get_pos()
|
||||||
local node = minetest.get_node(ppos)
|
local node = core.get_node(ppos)
|
||||||
if node.name == "vacuum:vacuum" then
|
if node.name == "vacuum:vacuum" then
|
||||||
-- player does not wear a suit, let him/her suffer!
|
-- player does not wear a suit, let him/her suffer!
|
||||||
local breath = player:get_breath()
|
local breath = player:get_breath()
|
||||||
@@ -53,10 +51,10 @@ local function check_player(player, timer)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local timer = 0
|
local timer = 0
|
||||||
minetest.register_globalstep(function(dtime)
|
core.register_globalstep(function(dtime)
|
||||||
timer = timer + dtime;
|
timer = timer + dtime;
|
||||||
if timer >= 2 then
|
if timer >= 2 then
|
||||||
for _,player in ipairs(minetest.get_connected_players()) do
|
for _,player in ipairs(core.get_connected_players()) do
|
||||||
check_player(player, timer)
|
check_player(player, timer)
|
||||||
end
|
end
|
||||||
timer = 0
|
timer = 0
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
|
|
||||||
local HUD_POSITION = {x = 0.09, y = 0.4}
|
local HUD_POSITION = {x = 0.09, y = 0.4}
|
||||||
local OFFSET_LABEL = {x = 0, y = -16}
|
local OFFSET_LABEL = {x = 0, y = -16}
|
||||||
local OFFSET_LEVEL = {x = 0, y = 16}
|
local OFFSET_LEVEL = {x = 0, y = 16}
|
||||||
local OFFSET_WARNING = {x = 0, y = -34}
|
local OFFSET_WARNING = {x = 0, y = -34}
|
||||||
local OFFSET_BAR = {x = 0, y = 0}
|
local OFFSET_BAR = {x = 0, y = 0}
|
||||||
local HUD_ALIGNMENT = {x = 1, y = 0}
|
local HUD_ALIGNMENT = {x = 1, y = 0}
|
||||||
|
|
||||||
local hud = {} -- playername -> data
|
local hud = {} -- playername -> data
|
||||||
|
|
||||||
|
|
||||||
local setup_hud = function(player)
|
local setup_hud = function(player)
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
local hud_data = {}
|
local hud_data = {}
|
||||||
@@ -71,7 +68,6 @@ local setup_hud = function(player)
|
|||||||
scale = {x = 100, y = 100},
|
scale = {x = 100, y = 100},
|
||||||
number = 0xFF0000
|
number = 0xFF0000
|
||||||
})
|
})
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local remove_hud = function(player)
|
local remove_hud = function(player)
|
||||||
@@ -141,15 +137,13 @@ local update_hud = function(player, has_full_suit, armor_list)
|
|||||||
-- red
|
-- red
|
||||||
color = get_color(255,0,0)
|
color = get_color(255,0,0)
|
||||||
player:hud_change(hud_data.o2_fg, "text", "spacesuit_o2_levels_fg_red.png")
|
player:hud_change(hud_data.o2_fg, "text", "spacesuit_o2_levels_fg_red.png")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
player:hud_change(hud_data.o2_label, "number", color)
|
player:hud_change(hud_data.o2_label, "number", color)
|
||||||
player:hud_change(hud_data.o2_level, "number", color)
|
player:hud_change(hud_data.o2_level, "number", color)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
core.register_on_leaveplayer(function(player)
|
||||||
-- remove stale hud data
|
-- remove stale hud data
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
hud[playername] = nil
|
hud[playername] = nil
|
||||||
@@ -170,9 +164,8 @@ spacesuit.set_player_wearing = function(player, has_full_suit, has_helmet, armor
|
|||||||
elseif not hud_data and has_helmet then
|
elseif not hud_data and has_helmet then
|
||||||
-- player started wearing
|
-- player started wearing
|
||||||
setup_hud(player)
|
setup_hud(player)
|
||||||
minetest.after(0.1, function()
|
core.after(0.1, function()
|
||||||
update_hud(player, has_full_suit, armor_list)
|
update_hud(player, has_full_suit, armor_list)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
|
|
||||||
spacesuit = {
|
spacesuit = {
|
||||||
armor_use = tonumber(minetest.settings:get("spacesuit.armor_use")) or 70,
|
armor_use = tonumber(core.settings:get("spacesuit.armor_use")) or 70,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local MP = core.get_modpath("spacesuit")
|
||||||
local MP = minetest.get_modpath("spacesuit")
|
|
||||||
|
|
||||||
dofile(MP.."/suit.lua")
|
dofile(MP.."/suit.lua")
|
||||||
dofile(MP.."/crafts.lua")
|
dofile(MP.."/crafts.lua")
|
||||||
dofile(MP.."/hud.lua")
|
dofile(MP.."/hud.lua")
|
||||||
dofile(MP.."/drowning.lua")
|
dofile(MP.."/drowning.lua")
|
||||||
|
|
||||||
print("[OK] Spacesuit")
|
|
||||||
|
|||||||
@@ -1,16 +1,19 @@
|
|||||||
|
|
||||||
# Spacesuit
|
# Spacesuit
|
||||||
|
|
||||||
[](https://github.com/mt-mods/spacesuit/actions)
|
[](https://github.com/mt-mods/spacesuit/actions)
|
||||||
|
[forum topic](https://forum.luanti.org/viewtopic.php?p=185473)
|
||||||
|
|
||||||
Spacesuit mod for minetest
|
Spacesuit mod for Luanti/Minetest
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
# Dependencies
|
|
||||||
* 3d_armor
|
* 3d_armor
|
||||||
|
|
||||||
# Features
|
## Features
|
||||||
|
|
||||||
* Breathe in vacuum or water
|
* Breathe in vacuum or water
|
||||||
|
|
||||||
# Attributions
|
## Attributions
|
||||||
* Spacesuit textures: Anonymous_moose (https://forum.minetest.net/viewtopic.php?p=185473#p185473)
|
|
||||||
* textures/spacesuit_overlay.png (https://github.com/bas080/minetest_vignette)
|
* Spacesuit textures: [Anonymous_moose](https://forum.luanti.org/memberlist.php?mode=viewprofile&u=7281)
|
||||||
|
* textures/spacesuit_overlay.png [bas080](https://github.com/bas080/minetest_vignette)
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
|
|
||||||
|
|
||||||
armor:register_armor("spacesuit:helmet", {
|
armor:register_armor("spacesuit:helmet", {
|
||||||
description = "Spacesuit Helmet",
|
description = "Spacesuit Helmet",
|
||||||
inventory_image = "spacesuit_inv_helmet.png",
|
inventory_image = "spacesuit_inv_helmet.png",
|
||||||
groups = {armor_head=5, armor_heal=1, armor_use=spacesuit.armor_use, not_repaired_by_anvil=1},
|
groups = {
|
||||||
|
armor_head = 5,
|
||||||
|
armor_heal = 1,
|
||||||
|
armor_use = spacesuit.armor_use,
|
||||||
|
not_repaired_by_anvil = 1
|
||||||
|
},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
wear_represents = "spacesuit_wear",
|
wear_represents = "spacesuit_wear",
|
||||||
})
|
})
|
||||||
@@ -11,7 +14,12 @@ armor:register_armor("spacesuit:helmet", {
|
|||||||
armor:register_armor("spacesuit:chestplate", {
|
armor:register_armor("spacesuit:chestplate", {
|
||||||
description = "Spacesuit Chestplate",
|
description = "Spacesuit Chestplate",
|
||||||
inventory_image = "spacesuit_inv_chestplate.png",
|
inventory_image = "spacesuit_inv_chestplate.png",
|
||||||
groups = {armor_torso=8, armor_heal=1, armor_use=spacesuit.armor_use, not_repaired_by_anvil=1},
|
groups = {
|
||||||
|
armor_torso = 8,
|
||||||
|
armor_heal = 1,
|
||||||
|
armor_use = spacesuit.armor_use,
|
||||||
|
not_repaired_by_anvil = 1
|
||||||
|
},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
wear_represents = "spacesuit_wear",
|
wear_represents = "spacesuit_wear",
|
||||||
})
|
})
|
||||||
@@ -19,7 +27,12 @@ armor:register_armor("spacesuit:chestplate", {
|
|||||||
armor:register_armor("spacesuit:pants", {
|
armor:register_armor("spacesuit:pants", {
|
||||||
description = "Spacesuit Pants",
|
description = "Spacesuit Pants",
|
||||||
inventory_image = "spacesuit_inv_pants.png",
|
inventory_image = "spacesuit_inv_pants.png",
|
||||||
groups = {armor_legs=7, armor_heal=1, armor_use=spacesuit.armor_use, not_repaired_by_anvil=1},
|
groups = {
|
||||||
|
armor_legs = 7,
|
||||||
|
armor_heal = 1,
|
||||||
|
armor_use = spacesuit.armor_use,
|
||||||
|
not_repaired_by_anvil = 1
|
||||||
|
},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
wear_represents = "spacesuit_wear",
|
wear_represents = "spacesuit_wear",
|
||||||
})
|
})
|
||||||
@@ -27,7 +40,12 @@ armor:register_armor("spacesuit:pants", {
|
|||||||
armor:register_armor("spacesuit:boots", {
|
armor:register_armor("spacesuit:boots", {
|
||||||
description = "Spacesuit Boots",
|
description = "Spacesuit Boots",
|
||||||
inventory_image = "spacesuit_inv_boots.png",
|
inventory_image = "spacesuit_inv_boots.png",
|
||||||
groups = {armor_feet=4, armor_heal=1, armor_use=spacesuit.armor_use, not_repaired_by_anvil=1},
|
groups = {
|
||||||
|
armor_feet = 4,
|
||||||
|
armor_heal = 1,
|
||||||
|
armor_use = spacesuit.armor_use,
|
||||||
|
not_repaired_by_anvil = 1
|
||||||
|
},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
wear_represents = "spacesuit_wear",
|
wear_represents = "spacesuit_wear",
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user