Compare commits

...

3 Commits

6 changed files with 91 additions and 86 deletions

View File

@ -5,7 +5,7 @@ local MODFILES = minetest.get_dir_list(PATH, false)
spacenum = 20 - string.len(NAME)
minetest.debug("" .. NAME .. string.rep(" ",spacenum) .. "init")
-- This assumes that the lua/ subdir contain lua code only.
-- This assumes that the lua/ subdir contains lua code only.
for i=1,table.getn(MODFILES),1
do

View File

@ -1,2 +0,0 @@
sparktech = {}
-- api starts with an a, should load first, if you split out any of the files in this dir into other stuff remember to declare this

View File

@ -1,7 +1,7 @@
local DEFAULT_BG_COLOR = "fc05e344"
local DEFAULT_FG_COLOR = "fc059dd0"
local DEFAULT_HL_COLOR = "fc059db0"
if not sparktech then sparktech = {} end
function sparktech.makebar(texture, posx, posy, sizex, sizey, value, maxvalue, direction)
-- direction = where to cut the texture either from thr right(0), below(1) left(2) or above (3)
-- default is right(0)
@ -38,7 +38,12 @@ function sparktech.add_inventory(size_x, size_y, formspec) -- pass an unfinished
local bg_color = verify_hexcolor_or_nil(minetest.settings:get("spark_gui_background")) or DEFAULT_BG_COLOR
local fg_color = verify_hexcolor_or_nil(minetest.settings:get("spark_gui_foreground")) or DEFAULT_FG_COLOR
local fg_highlight = verify_hexcolor_or_nil(minetest.settings:get("spark_gui_highlight")) or DEFAULT_HL_COLOR
local gui_immersive
if minetest.settings:get("spark_gui_full") then
gui_immersive = "true"
else
gui_immersive = "false"
end
if not size_x or size_x < 13.9 then size_x = 13.9 end
if not size_y or size_y < 0 then size_y = 0 end
local l_formspec = "size[" .. tostring(size_x) .. "," .. (size_y + 4.8) .. "]" ..
@ -48,7 +53,7 @@ function sparktech.add_inventory(size_x, size_y, formspec) -- pass an unfinished
"list[current_player;craft;10.4," .. size_y .. ";3,3]" ..
"list[current_player;craftpreview;10.4," .. (size_y + 3.8) .. ";1,1]" ..
"listcolors[#" .. fg_color .. ";#" .. fg_highlight .. "]" ..
"bgcolor[#" .. bg_color .. ";false]"
"bgcolor[#" .. bg_color .. ";" .. gui_immersive .. "]"
if not formspec then formspec = "" end
l_formspec = l_formspec .. formspec
return l_formspec

View File

@ -1,3 +1,4 @@
if not sparktech then sparktech = {} end
function sparktech.register_wrench(name, dictionary)
local dig_stlye_alt = minetest.settings:get_bool("spark_dig_stlye_alt")
local on_use = nil

View File

@ -1,3 +1,4 @@
spark_gui_background (GUI background color <RGBA>) string fc05e344
spark_gui_foreground (GUI foreground color <RGBA>) string fc059dd0
spark_gui_highlight (GUI highlight color <RGBA>) string fc059db0
spark_gui_full (GUI Full background <BOOL>) bool false

View File

@ -3,92 +3,92 @@ local NAME = minetest.get_current_modname()
local CAPACITY = 500
minetest.register_tool(NAME .. ":handdrill", {
description = "Electric Handdrill",
inventory_image = "electrichanddrill.png",
range = 6.0,
stack_max = 1,
groups = {
sparktech_chargable = CAPACITY
},
tool_capabilities = {
full_punch_interval = 0.5,
max_drop_level = 3,
groupcaps = {
cracky = {
times = {
[1] = 2.6,
[2] = 1.4,
[3] = 0.5
},
maxlevel = 3
},
crumbly = {
times = {
[1] = 2.00,
[2] = 1.00,
[3] = 0.5
},
maxlevel = 3
},
},
damage_groups = {fleshy = 1}
},
after_use = function (itemstack, user, node, digparams)
local meta = itemstack:get_meta()
local c = meta:get_int("energy") or 0
description = "Electric Handdrill",
inventory_image = "electrichanddrill.png",
range = 6.0,
stack_max = 1,
groups = {
sparktech_chargable = CAPACITY
},
tool_capabilities = {
full_punch_interval = 0.5,
max_drop_level = 3,
groupcaps = {
cracky = {
times = {
[1] = 2.6,
[2] = 1.4,
[3] = 0.5
},
maxlevel = 3
},
crumbly = {
times = {
[1] = 2.00,
[2] = 1.00,
[3] = 0.5
},
maxlevel = 3
},
},
damage_groups = {fleshy = 1}
},
after_use = function (itemstack, user, node, digparams)
local meta = itemstack:get_meta()
local c = meta:get_int("energy") or 0
c = c - 1
if c <= 0 then
c = 0
end
c = c - 1
if c <= 0 then
c = 0
end
meta:set_int("energy", c)
meta:set_int("energy", c)
return itemstack:get_definition()._sparktech_update_energy(itemstack)
end,
_sparktech_update_energy = function (itemstack)
local meta = itemstack:get_meta()
local c = meta:get_int("energy") or 0
return itemstack:get_definition()._sparktech_update_energy(itemstack)
end,
_sparktech_update_energy = function (itemstack)
local meta = itemstack:get_meta()
local c = meta:get_int("energy") or 0
if c <= 0 then
itemstack:set_wear(65535)
meta:set_tool_capabilities({
full_punch_interval = 3.0,
max_drop_level = 1,
groupcaps = {
cracky = {
times = {
[1] = 30.0,
[2] = 20.0,
[3] = 10.0
},
maxlevel = 1
},
crumbly = {
times = {
[1] = 30.0,
[2] = 20.0,
[3] = 10.0
},
maxlevel = 1
},
},
damage_groups = {fleshy = 1}
})
return itemstack
end
if c <= 0 then
itemstack:set_wear(65535)
meta:set_tool_capabilities({
full_punch_interval = 3.0,
max_drop_level = 1,
groupcaps = {
cracky = {
times = {
[1] = 30.0,
[2] = 20.0,
[3] = 10.0
},
maxlevel = 1
},
crumbly = {
times = {
[1] = 30.0,
[2] = 20.0,
[3] = 10.0
},
maxlevel = 1
},
},
damage_groups = {fleshy = 1}
})
return itemstack
end
itemstack:set_wear(65535 - math.ceil(c / CAPACITY * 65535))
meta:set_tool_capabilities(nil)
return itemstack
end
itemstack:set_wear(65535 - math.ceil(c / CAPACITY * 65535))
meta:set_tool_capabilities(nil)
return itemstack
end
})
minetest.register_craft({
output = NAME .. ":handdrill",
recipe = {
{ "", "group:steel_plate", "" },
{ "group:steel_plate", "default:tin_ingot", "group:steel_plate" },
{ "", "default:copper_ingot", "" },
}
output = NAME .. ":handdrill",
recipe = {
{ "", "group:steel_plate", "" },
{ "group:steel_plate", "default:tin_ingot", "group:steel_plate" },
{ "", "default:copper_ingot", "" },
}
})