Add chests, the beginnings of a machines API, and other things
This commit is contained in:
parent
3720070a28
commit
4d8312b79d
22 changed files with 557 additions and 16 deletions
|
|
@ -45,19 +45,21 @@ Player = {
|
|||
|
||||
e.wearing = {}
|
||||
|
||||
e.logical_height_offset = 0
|
||||
e:update_hp(p:get_hp())
|
||||
|
||||
e:update_inv()
|
||||
|
||||
return e
|
||||
end,
|
||||
update_inv = function(m)
|
||||
m.object:set_formspec_prepend [[
|
||||
e.object:set_formspec_prepend [[
|
||||
bgcolor[#000;true]
|
||||
background9[0,0;0,0;rgt_container_bg.png;true;16,16]
|
||||
style_type[button;border=false;bgimg=rgt_button_bg.png;bgimg_middle=8,8]
|
||||
listcolors[#fff0;#fff3;#0000;#444;#aaa]
|
||||
]]
|
||||
|
||||
e.inv = Inventory(p)
|
||||
|
||||
return e
|
||||
end,
|
||||
update_inv = function(m)
|
||||
local fs = "\
|
||||
formspec_version[10]\
|
||||
size[12,10]\
|
||||
|
|
@ -65,23 +67,27 @@ Player = {
|
|||
for x = 0, 7 do
|
||||
for y = 0, 3 do
|
||||
fs = fs.."\
|
||||
image["..(x *1.25 +1 -0.0625)..","..(y *1.25 +4.5 -0.0625)..";1.14,1.14;rgt_other_button_bg.png;8,8]\
|
||||
image["..(x *1.25 +1.125 -0.0625)..","..(y *1.25 +4.5 -0.0625)..";1.14,1.14;rgt_other_button_bg.png;8,8]\
|
||||
"
|
||||
end
|
||||
end
|
||||
fs = fs.."\
|
||||
list[current_player;main;1,4.5;8,4;]\
|
||||
list[current_player;main;1.125,4.5;8,4;]\
|
||||
list[current_player;craft;3,0.5;3,3;]\
|
||||
listring[]\
|
||||
list[current_player;craftpreview;7,1;1,1;]\
|
||||
"
|
||||
m.object:set_inventory_formspec(fs)
|
||||
end,
|
||||
set_logical_height_offset = function(m, offset)
|
||||
m.logical_height_offset = offset
|
||||
m.health_display:set_attach(m.object, nil, vector.new(0, 22 +m.logical_height_offset, 0))
|
||||
end,
|
||||
update_hp = function(m, hp)
|
||||
if not (m.health_display and m.health_display:is_valid()) then
|
||||
local pos = m.object:get_pos() or vector.zero()
|
||||
m.health_display = minetest.add_entity(pos, "rgt_player:health_display")
|
||||
m.health_display:set_attach(m.object, nil, vector.new(0, 22, 0))
|
||||
m.health_display:set_attach(m.object, nil, vector.new(0, 22 +m.logical_height_offset, 0))
|
||||
m.health_display:get_luaentity().owner = m
|
||||
end
|
||||
local tx = "[combine:90x90"
|
||||
|
|
@ -117,7 +123,7 @@ Player = {
|
|||
if def._wield_pos then
|
||||
pos = pos +def._wield_pos
|
||||
end
|
||||
local rot = def._wield_rot or def.type == "node" and vector.new(45, 40, 30) or (def.type == "tool" and vector.new(90, -45, 90) or vector.new(-90, -100, 90))
|
||||
local rot = def._wield_rot or def.type == "node" and vector.new(-45, 165, -30) or (def.type == "tool" and vector.new(90, -45, 90) or vector.new(-90, -100, 90))
|
||||
local scale = def._wield_scale or vector.new(0.2, 0.2, 0.2)
|
||||
|
||||
if type(scale) == "number" then
|
||||
|
|
@ -292,8 +298,7 @@ Player = {
|
|||
m.last_time = time
|
||||
end
|
||||
|
||||
-- Custom on-hover effects
|
||||
|
||||
-- Run on-hover callbacks
|
||||
m.pointed_node = nil
|
||||
|
||||
local pointed_found = false
|
||||
|
|
@ -321,6 +326,7 @@ Player = {
|
|||
end
|
||||
end
|
||||
elseif pointed and pointed.type == "node" and not m.pointed_node then
|
||||
pointed.node_under = minetest.get_node(pointed.under)
|
||||
m.pointed_node = pointed
|
||||
end
|
||||
end
|
||||
|
|
@ -331,9 +337,47 @@ Player = {
|
|||
m.pointed_obj = nil
|
||||
m.hover_trigger_range = nil
|
||||
end
|
||||
|
||||
|
||||
m.pos = pos
|
||||
|
||||
-- Hold-to-interact handling
|
||||
if m.interacting_with and m.ctl.place then
|
||||
if not m.interaction_start then
|
||||
m.interaction_start = time
|
||||
m.interaction_marker = minetest.add_entity(m.pointed_node.under, "display")
|
||||
m.interaction_marker:set_properties {
|
||||
visual = "sprite",
|
||||
textures = {"rgt_interact_progress_0.png"}
|
||||
}
|
||||
else
|
||||
if time -m.interaction_start > 1100000 then
|
||||
m.interaction_marker:remove()
|
||||
minetest.registered_nodes[minetest.get_node(m.interacting_with).name].on_interact(m.interacting_with, m)
|
||||
elseif time -m.interaction_start > 1000000 then
|
||||
m.interaction_marker:set_properties {
|
||||
textures = {"rgt_interact_progress_100.png"}
|
||||
}
|
||||
elseif time -m.interaction_start > 750000 then
|
||||
m.interaction_marker:set_properties {
|
||||
textures = {"rgt_interact_progress_75.png"}
|
||||
}
|
||||
elseif time -m.interaction_start > 500000 then
|
||||
m.interaction_marker:set_properties {
|
||||
textures = {"rgt_interact_progress_50.png"}
|
||||
}
|
||||
elseif time -m.interaction_start > 250000 then
|
||||
m.interaction_marker:set_properties {
|
||||
textures = {"rgt_interact_progress_25.png"}
|
||||
}
|
||||
end
|
||||
end
|
||||
elseif m.interacting_with and not m.ctl.place then
|
||||
m.interacting_with = nil
|
||||
m.interaction_start = nil
|
||||
m.interaction_marker:remove()
|
||||
m.interaction_marker = nil
|
||||
end
|
||||
|
||||
-- Run on_wield callbacks
|
||||
local w = p:get_wielded_item()
|
||||
local wname = w:get_name()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue