mirror of
https://github.com/minetest-mods/digtron.git
synced 2024-10-02 07:33:07 +02:00
finishing up technic power tap, other misc fixes
This commit is contained in:
parent
65f5ac8520
commit
d582f106aa
@ -1,6 +1,8 @@
|
||||
DigtronLayout = {}
|
||||
DigtronLayout.__index = DigtronLayout
|
||||
|
||||
local modpath_awards = minetest.get_modpath("awards")
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
-- Creation
|
||||
|
||||
@ -147,8 +149,9 @@ function DigtronLayout.create(pos, player)
|
||||
to_test:set_if_not_in(tested, testpos.x, testpos.y - 1, testpos.z, true)
|
||||
to_test:set_if_not_in(tested, testpos.x, testpos.y, testpos.z + 1, true)
|
||||
to_test:set_if_not_in(tested, testpos.x, testpos.y, testpos.z - 1, true)
|
||||
elseif minetest.registered_nodes[node.name].buildable_to ~= true then
|
||||
elseif not minetest.registered_nodes[node.name] or minetest.registered_nodes[node.name].buildable_to ~= true then
|
||||
-- Tracks whether the digtron is hovering in mid-air. If any part of the digtron array touches something solid it gains traction.
|
||||
-- Allowing unknown nodes to provide traction, since they're not buildable_to either
|
||||
self.traction = self.traction + 1
|
||||
end
|
||||
|
||||
@ -324,6 +327,13 @@ function DigtronLayout.write_layout_image(self, player)
|
||||
local old_def = minetest.registered_nodes[old_node.name]
|
||||
minetest.remove_node(oldpos)
|
||||
|
||||
if modpath_awards then
|
||||
-- We're about to tell the awards mod that we're digging a node, but we
|
||||
-- don't want it to count toward any actual awards. Pre-decrement.
|
||||
local data = awards.players[player:get_player_name()]
|
||||
awards.increment_item_counter(data, "count", old_node.name, -1)
|
||||
end
|
||||
|
||||
for _, callback in ipairs(minetest.registered_on_dignodes) do
|
||||
-- Copy pos and node because callback can modify them
|
||||
local pos_copy = {x=oldpos.x, y=oldpos.y, z=oldpos.z}
|
||||
@ -347,6 +357,13 @@ function DigtronLayout.write_layout_image(self, player)
|
||||
minetest.get_meta(new_pos):from_table(node_image.meta)
|
||||
minetest.log("action", string.format("%s adds Digtron component %s at (%d, %d, %d)", player:get_player_name(), node_image.node.name, node_image.pos.x, node_image.pos.y, node_image.pos.z))
|
||||
|
||||
if modpath_awards then
|
||||
-- We're about to tell the awards mod that we're placing a node, but we
|
||||
-- don't want it to count toward any actual awards. Pre-decrement.
|
||||
local data = awards.players[player:get_player_name()]
|
||||
awards.increment_item_counter(data, "place", new_node.name, -1)
|
||||
end
|
||||
|
||||
for _, callback in ipairs(minetest.registered_on_placenodes) do
|
||||
-- Copy pos and node because callback can modify them
|
||||
local pos_copy = {x=new_pos.x, y=new_pos.y, z=new_pos.z}
|
||||
|
@ -2,6 +2,8 @@
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
|
||||
local modpath_awards = minetest.get_modpath("awards")
|
||||
|
||||
minetest.register_node("digtron:empty_crate", {
|
||||
description = S("Digtron Crate (Empty)"),
|
||||
_doc_items_longdesc = digtron.doc.empty_crate_longdesc,
|
||||
@ -34,6 +36,13 @@ minetest.register_node("digtron:empty_crate", {
|
||||
local old_node = node_image.node
|
||||
minetest.remove_node(old_pos)
|
||||
|
||||
if modpath_awards then
|
||||
-- We're about to tell the awards mod that we're digging a node, but we
|
||||
-- don't want it to count toward any actual awards. Pre-decrement.
|
||||
local data = awards.players[clicker:get_player_name()]
|
||||
awards.increment_item_counter(data, "count", old_node.name, -1)
|
||||
end
|
||||
|
||||
for _, callback in ipairs(minetest.registered_on_dignodes) do
|
||||
-- Copy pos and node because callback can modify them
|
||||
local pos_copy = {x=old_pos.x, y=old_pos.y, z=old_pos.z}
|
||||
|
@ -6,36 +6,48 @@ local size = 3/16
|
||||
|
||||
local max_dig_cost = math.max(digtron.config.dig_cost_cracky, digtron.config.dig_cost_crumbly, digtron.config.dig_cost_choppy, digtron.config.dig_cost_default)
|
||||
|
||||
local get_formspec_string = function(current_val, current_max)
|
||||
return "size[4.5,0.6]" ..
|
||||
default.gui_bg ..
|
||||
default.gui_bg_img ..
|
||||
default.gui_slots ..
|
||||
"field[0.2,0.3;1,1;value;;".. current_val .. "]" ..
|
||||
"button[1,0;1,1;maximize;" .. S("Maximize\nPower") .."]" ..
|
||||
"label[2,0;"..S("Maximum Power\nRequired: @1", current_max) .."]"..
|
||||
"button[3.5,0;1,1;refresh;" .. S("Refresh\nMax") .."]"
|
||||
end
|
||||
|
||||
local connector_groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 8, technic_machine=1, technic_hv=1}
|
||||
if not minetest.get_modpath("technic") then
|
||||
-- Technic is not installed, hide this away.
|
||||
connector_groups.not_in_creative_inventory = 1
|
||||
end
|
||||
|
||||
minetest.register_node("digtron:power_connector", {
|
||||
description = S("DPC"),
|
||||
description = S("Digtron HV Power Connector"),
|
||||
_doc_items_longdesc = digtron.doc.power_connector_longdesc,
|
||||
_doc_items_usagehelp = digtron.doc.power_connector_usagehelp,
|
||||
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 8, technic_machine=1, technic_hv=1},
|
||||
tiles = {"digtron_plate.png"},
|
||||
_digtron_formspec = get_formspec_string(0,0),
|
||||
groups = connector_groups,
|
||||
tiles = {"digtron_plate.png^digtron_power_connector_top.png^digtron_digger_yb_frame.png", "digtron_plate.png^digtron_digger_yb_frame.png",
|
||||
"digtron_plate.png^digtron_digger_yb_frame.png^digtron_power_connector_side.png", "digtron_plate.png^digtron_digger_yb_frame.png^digtron_power_connector_side.png",
|
||||
"digtron_plate.png^digtron_digger_yb_frame.png^digtron_power_connector_side.png", "digtron_plate.png^digtron_digger_yb_frame.png^digtron_power_connector_side.png",
|
||||
},
|
||||
connect_sides = {"bottom", "top", "left", "right", "front", "back"},
|
||||
drawtype = "nodebox",
|
||||
sounds = digtron.metal_sounds,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
-- node_box = {
|
||||
-- type = "fixed",
|
||||
-- fixed = {
|
||||
-- {-0.5, 0.5, -0.5, 0.5, 0, 0.5}, -- NodeBox1
|
||||
-- {-0.1875, 0, -0.1875, 0.1875, -0.5, 0.1875}, -- NodeBox2
|
||||
-- {-0.3125, -0.0625, -0.3125, 0.3125, -0.1875, 0.3125}, -- NodeBox3
|
||||
-- {-0.3125, -0.25, -0.3125, 0.3125, -0.375, 0.3125}, -- NodeBox4
|
||||
-- }
|
||||
-- },
|
||||
|
||||
connects_to = {"group:technic_hv_cable"},
|
||||
node_box = {
|
||||
type = "connected",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, -- NodeBox1
|
||||
{-0.1875, 0, -0.1875, 0.1875, 0.5, 0.1875}, -- NodeBox2
|
||||
{-0.3125, 0.0625, -0.3125, 0.3125, 0.1875, 0.3125}, -- NodeBox3
|
||||
{-0.3125, 0.25, -0.3125, 0.3125, 0.375, 0.3125}, -- NodeBox4
|
||||
{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, -- Main body
|
||||
{-0.1875, 0, -0.1875, 0.1875, 0.5, 0.1875}, -- post
|
||||
{-0.3125, 0.0625, -0.3125, 0.3125, 0.1875, 0.3125}, -- vane
|
||||
{-0.3125, 0.25, -0.3125, 0.3125, 0.375, 0.3125}, -- vane
|
||||
},
|
||||
connect_front = {-size, -size, -0.5, size, size, size}, -- z-
|
||||
connect_back = {-size, -size, size, size, size, 0.5 }, -- z+
|
||||
@ -43,15 +55,20 @@ minetest.register_node("digtron:power_connector", {
|
||||
connect_right = {-size, -size, -size, 0.5, size, size}, -- x+
|
||||
},
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", get_formspec_string(0,0))
|
||||
end,
|
||||
|
||||
technic_run = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local eu_input = meta:get_int("HV_EU_input")
|
||||
local demand = meta:get_int("HV_EU_demand")
|
||||
meta:set_string("infotext", S("Digtron Power @1/@2\nRight-click to update", eu_input, demand))
|
||||
meta:set_string("infotext", S("Digtron Power @1/@2", eu_input, demand))
|
||||
end,
|
||||
|
||||
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
||||
local layout = DigtronLayout.create(pos, player)
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
local layout = DigtronLayout.create(pos, sender)
|
||||
local max_cost = 0
|
||||
for _, node_image in pairs(layout.builders) do
|
||||
max_cost = max_cost + digtron.config.build_cost
|
||||
@ -59,11 +76,22 @@ minetest.register_node("digtron:power_connector", {
|
||||
for _, node_image in pairs(layout.diggers) do
|
||||
max_cost = max_cost + max_dig_cost
|
||||
end
|
||||
local current_max = max_cost * digtron.config.power_ratio
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("HV_EU_demand", max_cost * digtron.config.power_ratio)
|
||||
|
||||
if fields.maximize then
|
||||
meta:set_int("HV_EU_demand", current_max)
|
||||
elseif fields.value ~= nil then
|
||||
local number = tonumber(fields.value) or 0
|
||||
local number = math.min(math.max(number, 0), current_max)
|
||||
meta:set_int("HV_EU_demand", number)
|
||||
end
|
||||
|
||||
meta:set_string("formspec", get_formspec_string(meta:get_int("HV_EU_demand"), current_max))
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
|
||||
technic.register_machine("HV", "digtron:power_connector", technic.receiver)
|
||||
if minetest.get_modpath("technic") then
|
||||
technic.register_machine("HV", "digtron:power_connector", technic.receiver)
|
||||
end
|
@ -100,6 +100,15 @@ if minetest.get_modpath("technic") then
|
||||
{"","default:steel_ingot",""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "digtron:power_connector",
|
||||
recipe = {
|
||||
{"","technic:hv_cable",""},
|
||||
{"technic:hv_cable","digtron:digtron_core","technic:hv_cable"},
|
||||
{"","technic:hv_cable",""}
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
|
BIN
textures/digtron_power_connector_side.png
Normal file
BIN
textures/digtron_power_connector_side.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 390 B |
BIN
textures/digtron_power_connector_top.png
Normal file
BIN
textures/digtron_power_connector_top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 387 B |
@ -107,7 +107,7 @@ digtron.execute_dig_cycle = function(pos, clicker)
|
||||
local facing = minetest.get_node(pos).param2
|
||||
local dir = minetest.facedir_to_dir(facing)
|
||||
local fuel_burning = meta:get_float("fuel_burning") -- get amount of burned fuel left over from last cycle
|
||||
local status_text = S("Heat remaining in controller furnace: @1", math.max(0, fuel_burning))
|
||||
local status_text = S("Heat remaining in controller furnace: @1", math.floor(math.max(0, fuel_burning)))
|
||||
local exhaust = meta:get_int("on_coal")
|
||||
|
||||
local layout = DigtronLayout.create(pos, clicker)
|
||||
@ -346,7 +346,7 @@ digtron.execute_dig_cycle = function(pos, clicker)
|
||||
|
||||
meta:set_float("fuel_burning", fuel_burning)
|
||||
meta:set_int("on_coal", exhaust)
|
||||
status_text = status_text .. S("Heat remaining in controller furnace: @1", math.max(0, fuel_burning))
|
||||
status_text = status_text .. S("Heat remaining in controller furnace: @1", math.floor(math.max(0, fuel_burning)))
|
||||
|
||||
-- Eyecandy
|
||||
for _, particles in pairs(particle_systems) do
|
||||
@ -423,7 +423,7 @@ digtron.execute_downward_dig_cycle = function(pos, clicker)
|
||||
local facing = minetest.get_node(pos).param2
|
||||
local dir = digtron.facedir_to_down_dir(facing)
|
||||
local fuel_burning = meta:get_float("fuel_burning") -- get amount of burned fuel left over from last cycle
|
||||
local status_text = S("Heat remaining in controller furnace: @1", math.max(0, fuel_burning))
|
||||
local status_text = S("Heat remaining in controller furnace: @1", math.floor(math.max(0, fuel_burning)))
|
||||
local exhaust = meta:get_int("on_coal")
|
||||
|
||||
local layout = DigtronLayout.create(pos, clicker)
|
||||
@ -542,7 +542,7 @@ digtron.execute_downward_dig_cycle = function(pos, clicker)
|
||||
|
||||
meta:set_float("fuel_burning", fuel_burning)
|
||||
meta:set_int("on_coal", exhaust)
|
||||
status_text = status_text .. S("Heat remaining in controller furnace: @1", math.max(0, fuel_burning))
|
||||
status_text = status_text .. S("Heat remaining in controller furnace: @1", math.floor(math.max(0, fuel_burning)))
|
||||
|
||||
-- Eyecandy
|
||||
for _, particles in pairs(particle_systems) do
|
||||
|
Loading…
Reference in New Issue
Block a user