Reformat code with IntelliJ auto-reformat function.

This commit is contained in:
Thomas--S
2017-03-28 21:04:28 +02:00
parent b7cecd7f3d
commit 73d8bdff4b
107 changed files with 3516 additions and 3297 deletions

View File

@ -1,22 +1,32 @@
technic.chests.groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
tubedevice=1, tubedevice_receiver=1}
technic.chests.groups_noinv = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
tubedevice=1, tubedevice_receiver=1, not_in_creative_inventory=1}
technic.chests.groups = {
snappy = 2,
choppy = 2,
oddly_breakable_by_hand = 2,
tubedevice = 1,
tubedevice_receiver = 1
}
technic.chests.groups_noinv = {
snappy = 2,
choppy = 2,
oddly_breakable_by_hand = 2,
tubedevice = 1,
tubedevice_receiver = 1,
not_in_creative_inventory = 1
}
technic.chests.tube = {
insert_object = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:add_item("main",stack)
return inv:add_item("main", stack)
end,
can_insert = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:room_for_item("main",stack)
return inv:room_for_item("main", stack)
end,
input_inventory = "main",
connect_sides = {left=1, right=1, front=1, back=1, top=1, bottom=1},
connect_sides = { left = 1, right = 1, front = 1, back = 1, top = 1, bottom = 1 },
}
technic.chests.can_dig = function(pos, player)
@ -35,17 +45,19 @@ end
function technic.chests.inv_move(pos, from_list, from_index, to_list, to_index, count, player)
return inv_change(pos, count, player)
end
function technic.chests.inv_put(pos, listname, index, stack, player)
return inv_change(pos, stack:get_count(), player)
end
function technic.chests.inv_take(pos, listname, index, stack, player)
return inv_change(pos, stack:get_count(), player)
end
function technic.chests.on_inv_move(pos, from_list, from_index, to_list, to_index, count, player)
minetest.log("action", player:get_player_name()..
" moves stuff in chest at "
..minetest.pos_to_string(pos))
minetest.log("action", player:get_player_name() ..
" moves stuff in chest at "
.. minetest.pos_to_string(pos))
end
function technic.chests.on_inv_put(pos, listname, index, stack, player)
@ -56,7 +68,7 @@ end
function technic.chests.on_inv_take(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() ..
" takes " .. stack:get_name() ..
" takes " .. stack:get_name() ..
" from chest at " .. minetest.pos_to_string(pos))
end

View File

@ -1,26 +1,26 @@
minetest.register_craft({
output = 'technic:copper_chest 1',
recipe = {
{'default:copper_ingot','default:copper_ingot','default:copper_ingot'},
{'default:copper_ingot','technic:iron_chest','default:copper_ingot'},
{'default:copper_ingot','default:copper_ingot','default:copper_ingot'},
{ 'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot' },
{ 'default:copper_ingot', 'technic:iron_chest', 'default:copper_ingot' },
{ 'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot' },
}
})
minetest.register_craft({
output = 'technic:copper_locked_chest 1',
recipe = {
{'default:copper_ingot','default:copper_ingot','default:copper_ingot'},
{'default:copper_ingot','technic:iron_locked_chest','default:copper_ingot'},
{'default:copper_ingot','default:copper_ingot','default:copper_ingot'},
{ 'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot' },
{ 'default:copper_ingot', 'technic:iron_locked_chest', 'default:copper_ingot' },
{ 'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot' },
}
})
minetest.register_craft({
output = 'technic:copper_locked_chest 1',
recipe = {
{'default:steel_ingot'},
{'technic:copper_chest'},
{ 'default:steel_ingot' },
{ 'technic:copper_chest' },
}
})

View File

@ -1,4 +1,3 @@
local material_list
if minetest.get_modpath("moreores") then
material_list = { 'silver' }
@ -11,18 +10,18 @@ for _, material in ipairs(material_list) do
minetest.register_craft({
output = 'technic:gold_chest',
recipe = {
{'default:gold_ingot','default:gold_ingot','default:gold_ingot'},
{'default:gold_ingot',"technic:"..material.."_chest",'default:gold_ingot'},
{'default:gold_ingot','default:gold_ingot','default:gold_ingot'},
{ 'default:gold_ingot', 'default:gold_ingot', 'default:gold_ingot' },
{ 'default:gold_ingot', "technic:" .. material .. "_chest", 'default:gold_ingot' },
{ 'default:gold_ingot', 'default:gold_ingot', 'default:gold_ingot' },
}
})
minetest.register_craft({
output = 'technic:gold_locked_chest',
recipe = {
{'default:gold_ingot','default:gold_ingot','default:gold_ingot'},
{'default:gold_ingot',"technic:"..material.."_locked_chest",'default:gold_ingot'},
{'default:gold_ingot','default:gold_ingot','default:gold_ingot'},
{ 'default:gold_ingot', 'default:gold_ingot', 'default:gold_ingot' },
{ 'default:gold_ingot', "technic:" .. material .. "_locked_chest", 'default:gold_ingot' },
{ 'default:gold_ingot', 'default:gold_ingot', 'default:gold_ingot' },
}
})
end
@ -30,8 +29,8 @@ end
minetest.register_craft({
output = 'technic:gold_locked_chest',
recipe = {
{'default:steel_ingot'},
{'technic:gold_chest'},
{ 'default:steel_ingot' },
{ 'technic:gold_chest' },
}
})

View File

@ -7,12 +7,12 @@ local modpath = minetest.get_modpath("technic_chests")
technic = rawget(_G, "technic") or {}
technic.chests = {}
dofile(modpath.."/common.lua")
dofile(modpath.."/register.lua")
dofile(modpath.."/wooden_chest.lua")
dofile(modpath.."/iron_chest.lua")
dofile(modpath.."/copper_chest.lua")
dofile(modpath.."/silver_chest.lua")
dofile(modpath.."/gold_chest.lua")
dofile(modpath.."/mithril_chest.lua")
dofile(modpath .. "/common.lua")
dofile(modpath .. "/register.lua")
dofile(modpath .. "/wooden_chest.lua")
dofile(modpath .. "/iron_chest.lua")
dofile(modpath .. "/copper_chest.lua")
dofile(modpath .. "/silver_chest.lua")
dofile(modpath .. "/gold_chest.lua")
dofile(modpath .. "/mithril_chest.lua")

View File

@ -8,26 +8,26 @@ end
minetest.register_craft({
output = 'technic:iron_chest 1',
recipe = {
{cast_iron_ingot,cast_iron_ingot,cast_iron_ingot},
{cast_iron_ingot,'default:chest',cast_iron_ingot},
{cast_iron_ingot,cast_iron_ingot,cast_iron_ingot},
{ cast_iron_ingot, cast_iron_ingot, cast_iron_ingot },
{ cast_iron_ingot, 'default:chest', cast_iron_ingot },
{ cast_iron_ingot, cast_iron_ingot, cast_iron_ingot },
}
})
minetest.register_craft({
output = 'technic:iron_locked_chest 1',
recipe = {
{cast_iron_ingot,cast_iron_ingot,cast_iron_ingot},
{cast_iron_ingot,'default:chest_locked',cast_iron_ingot},
{cast_iron_ingot,cast_iron_ingot,cast_iron_ingot},
{ cast_iron_ingot, cast_iron_ingot, cast_iron_ingot },
{ cast_iron_ingot, 'default:chest_locked', cast_iron_ingot },
{ cast_iron_ingot, cast_iron_ingot, cast_iron_ingot },
}
})
minetest.register_craft({
output = 'technic:iron_locked_chest 1',
recipe = {
{'default:steel_ingot'},
{'technic:iron_chest'},
{ 'default:steel_ingot' },
{ 'technic:iron_chest' },
}
})

View File

@ -2,18 +2,18 @@ if minetest.get_modpath("moreores") then
minetest.register_craft({
output = 'technic:mithril_chest 1',
recipe = {
{'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'},
{'moreores:mithril_ingot','technic:gold_chest','moreores:mithril_ingot'},
{'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'},
{ 'moreores:mithril_ingot', 'moreores:mithril_ingot', 'moreores:mithril_ingot' },
{ 'moreores:mithril_ingot', 'technic:gold_chest', 'moreores:mithril_ingot' },
{ 'moreores:mithril_ingot', 'moreores:mithril_ingot', 'moreores:mithril_ingot' },
}
})
minetest.register_craft({
output = 'technic:mithril_locked_chest 1',
recipe = {
{'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'},
{'moreores:mithril_ingot','technic:gold_locked_chest','moreores:mithril_ingot'},
{'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'},
{ 'moreores:mithril_ingot', 'moreores:mithril_ingot', 'moreores:mithril_ingot' },
{ 'moreores:mithril_ingot', 'technic:gold_locked_chest', 'moreores:mithril_ingot' },
{ 'moreores:mithril_ingot', 'moreores:mithril_ingot', 'moreores:mithril_ingot' },
}
})
end
@ -21,8 +21,8 @@ end
minetest.register_craft({
output = 'technic:mithril_locked_chest 1',
recipe = {
{'default:steel_ingot'},
{'technic:mithril_chest'},
{ 'default:steel_ingot' },
{ 'technic:mithril_chest' },
}
})

View File

@ -7,37 +7,37 @@ if not minetest.get_modpath("pipeworks") then
local pipeworks_meta = {}
setmetatable(pipeworks, pipeworks_meta)
local dummy = function()
end
end
pipeworks_meta.__index = function(table, key)
print("[technic_chests] WARNING: variable or method '"..key.."' not present in dummy pipeworks table - assuming it is a method...")
pipeworks[key] = dummy
return dummy
end
print("[technic_chests] WARNING: variable or method '" .. key .. "' not present in dummy pipeworks table - assuming it is a method...")
pipeworks[key] = dummy
return dummy
end
pipeworks.after_place = dummy
pipeworks.after_dig = dummy
end
local chest_mark_colors = {
{"black", S("Black")},
{"blue", S("Blue")},
{"brown", S("Brown")},
{"cyan", S("Cyan")},
{"dark_green", S("Dark Green")},
{"dark_grey", S("Dark Grey")},
{"green", S("Green")},
{"grey", S("Grey")},
{"magenta", S("Magenta")},
{"orange", S("Orange")},
{"pink", S("Pink")},
{"red", S("Red")},
{"violet", S("Violet")},
{"white", S("White")},
{"yellow", S("Yellow")},
{ "black", S("Black") },
{ "blue", S("Blue") },
{ "brown", S("Brown") },
{ "cyan", S("Cyan") },
{ "dark_green", S("Dark Green") },
{ "dark_grey", S("Dark Grey") },
{ "green", S("Green") },
{ "grey", S("Grey") },
{ "magenta", S("Magenta") },
{ "orange", S("Orange") },
{ "pink", S("Pink") },
{ "red", S("Red") },
{ "violet", S("Violet") },
{ "white", S("White") },
{ "yellow", S("Yellow") },
}
local function colorid_to_postfix(id)
return chest_mark_colors[id] and "_"..chest_mark_colors[id][1] or ""
return chest_mark_colors[id] and "_" .. chest_mark_colors[id][1] or ""
end
@ -45,11 +45,11 @@ local function get_color_buttons(coleft, lotop)
local buttons_string = ""
for y = 0, 3 do
for x = 0, 3 do
local file_name = "technic_colorbutton"..(y * 4 + x)..".png"
buttons_string = buttons_string.."image_button["
..(coleft + 0.1 + x * 0.7)..","..(lotop + 0.1 + y * 0.7)
..";0.8,0.8;"..file_name..";color_button"
..(y * 4 + x + 1)..";]"
local file_name = "technic_colorbutton" .. (y * 4 + x) .. ".png"
buttons_string = buttons_string .. "image_button["
.. (coleft + 0.1 + x * 0.7) .. "," .. (lotop + 0.1 + y * 0.7)
.. ";0.8,0.8;" .. file_name .. ";color_button"
.. (y * 4 + x + 1) .. ";]"
end
end
return buttons_string
@ -58,9 +58,9 @@ end
local function check_color_buttons(pos, meta, chest_name, fields)
for i = 1, 16 do
if fields["color_button"..i] then
if fields["color_button" .. i] then
local node = minetest.get_node(pos)
node.name = chest_name..colorid_to_postfix(i)
node.name = chest_name .. colorid_to_postfix(i)
minetest.swap_node(pos, node)
meta:set_string("color", i)
return
@ -74,20 +74,20 @@ local function set_formspec(pos, data, page)
local formspec = data.base_formspec
if data.autosort then
local status = meta:get_int("autosort")
formspec = formspec.."button["..(data.hileft+2)..","..(data.height+1.1)..";3,0.8;autosort_to_"..(1-status)..";"..S("Auto-sort is %s"):format(status == 1 and S("On") or S("Off")).."]"
formspec = formspec .. "button[" .. (data.hileft + 2) .. "," .. (data.height + 1.1) .. ";3,0.8;autosort_to_" .. (1 - status) .. ";" .. S("Auto-sort is %s"):format(status == 1 and S("On") or S("Off")) .. "]"
end
if data.infotext then
local formspec_infotext = minetest.formspec_escape(meta:get_string("infotext"))
if page == "main" then
formspec = formspec.."image_button["..(data.hileft+2.1)..",0.1;0.8,0.8;"
.."technic_pencil_icon.png;edit_infotext;]"
.."label["..(data.hileft+3)..",0;"..formspec_infotext.."]"
formspec = formspec .. "image_button[" .. (data.hileft + 2.1) .. ",0.1;0.8,0.8;"
.. "technic_pencil_icon.png;edit_infotext;]"
.. "label[" .. (data.hileft + 3) .. ",0;" .. formspec_infotext .. "]"
elseif page == "edit_infotext" then
formspec = formspec.."image_button["..(data.hileft+2.1)..",0.1;0.8,0.8;"
.."technic_checkmark_icon.png;save_infotext;]"
.."field["..(data.hileft+3.3)..",0.2;4.8,1;"
.."infotext_box;"..S("Edit chest description:")..";"
..formspec_infotext.."]"
formspec = formspec .. "image_button[" .. (data.hileft + 2.1) .. ",0.1;0.8,0.8;"
.. "technic_checkmark_icon.png;save_infotext;]"
.. "field[" .. (data.hileft + 3.3) .. ",0.2;4.8,1;"
.. "infotext_box;" .. S("Edit chest description:") .. ";"
.. formspec_infotext .. "]"
end
end
if data.color then
@ -98,7 +98,7 @@ local function set_formspec(pos, data, page)
else
colorName = S("None")
end
formspec = formspec.."label["..(data.coleft+0.2)..","..(data.lotop+3)..";"..S("Color Filter: %s"):format(colorName).."]"
formspec = formspec .. "label[" .. (data.coleft + 0.2) .. "," .. (data.lotop + 3) .. ";" .. S("Color Filter: %s"):format(colorName) .. "]"
end
meta:set_string("formspec", formspec)
end
@ -166,7 +166,7 @@ local function get_receive_fields(name, data)
end
if data.color then
-- This sets the node
local nn = "technic:"..lname..(data.locked and "_locked" or "").."_chest"
local nn = "technic:" .. lname .. (data.locked and "_locked" or "") .. "_chest"
check_color_buttons(pos, meta, nn, fields)
end
meta:get_inventory():set_size("main", data.width * data.height)
@ -202,20 +202,20 @@ function technic.chests:definition(name, data)
data.ovheight = data.lotop + 4
local locked_after_place = nil
local front = {"technic_"..lname.."_chest_front.png"}
data.base_formspec = "size["..data.ovwidth..","..data.ovheight.."]"..
"label[0,0;"..S("%s Chest"):format(name).."]"..
"list[context;main;"..data.hileft..",1;"..data.width..","..data.height..";]"..
"list[current_player;main;"..data.loleft..","..data.lotop..";8,4;]"..
"background[-0.19,-0.25;"..(data.ovwidth+0.4)..","..(data.ovheight+0.75)..";technic_chest_form_bg.png]"..
"background["..data.hileft..",1;"..data.width..","..data.height..";technic_"..lname.."_chest_inventory.png]"..
"background["..data.loleft..","..data.lotop..";8,4;technic_main_inventory.png]"..
local front = { "technic_" .. lname .. "_chest_front.png" }
data.base_formspec = "size[" .. data.ovwidth .. "," .. data.ovheight .. "]" ..
"label[0,0;" .. S("%s Chest"):format(name) .. "]" ..
"list[context;main;" .. data.hileft .. ",1;" .. data.width .. "," .. data.height .. ";]" ..
"list[current_player;main;" .. data.loleft .. "," .. data.lotop .. ";8,4;]" ..
"background[-0.19,-0.25;" .. (data.ovwidth + 0.4) .. "," .. (data.ovheight + 0.75) .. ";technic_chest_form_bg.png]" ..
"background[" .. data.hileft .. ",1;" .. data.width .. "," .. data.height .. ";technic_" .. lname .. "_chest_inventory.png]" ..
"background[" .. data.loleft .. "," .. data.lotop .. ";8,4;technic_main_inventory.png]" ..
"listring[]"
if data.sort then
data.base_formspec = data.base_formspec.."button["..data.hileft..","..(data.height+1.1)..";1,0.8;sort;"..S("Sort").."]"
data.base_formspec = data.base_formspec .. "button[" .. data.hileft .. "," .. (data.height + 1.1) .. ";1,0.8;sort;" .. S("Sort") .. "]"
end
if data.color then
data.base_formspec = data.base_formspec..get_color_buttons(data.coleft, data.lotop)
data.base_formspec = data.base_formspec .. get_color_buttons(data.coleft, data.lotop)
end
if data.locked then
@ -223,11 +223,10 @@ function technic.chests:definition(name, data)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
meta:set_string("infotext",
S("%s Locked Chest (owned by %s)")
:format(name, meta:get_string("owner")))
S("%s Locked Chest (owned by %s)"):format(name, meta:get_string("owner")))
pipeworks.after_place(pos)
end
table.insert(front, "technic_"..lname.."_chest_lock_overlay.png")
table.insert(front, "technic_" .. lname .. "_chest_lock_overlay.png")
else
locked_after_place = pipeworks.after_place
end
@ -241,9 +240,11 @@ function technic.chests:definition(name, data)
local def = {
description = desc,
tiles = {"technic_"..lname.."_chest_top.png", "technic_"..lname.."_chest_top.png",
"technic_"..lname.."_chest_side.png", "technic_"..lname.."_chest_side.png",
"technic_"..lname.."_chest_side.png", table.concat(front, "^")},
tiles = {
"technic_" .. lname .. "_chest_top.png", "technic_" .. lname .. "_chest_top.png",
"technic_" .. lname .. "_chest_side.png", "technic_" .. lname .. "_chest_side.png",
"technic_" .. lname .. "_chest_side.png", table.concat(front, "^")
},
paramtype2 = "facedir",
groups = self.groups,
tube = self.tube,
@ -251,7 +252,6 @@ function technic.chests:definition(name, data)
sounds = default.node_sound_wood_defaults(),
after_place_node = locked_after_place,
after_dig_node = pipeworks.after_dig,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", S("%s Chest"):format(name))
@ -263,11 +263,11 @@ function technic.chests:definition(name, data)
on_receive_fields = get_receive_fields(name, data),
on_metadata_inventory_move = self.on_inv_move,
on_metadata_inventory_put = self.on_inv_put,
on_metadata_inventory_take = self.on_inv_take,
on_metadata_inventory_take = self.on_inv_take,
on_blast = function(pos)
local drops = {}
default.get_inventory_drops(pos, "main", drops)
drops[#drops+1] = "technic:"..name:lower()..(data.locked and "_locked" or "").."_chest"
drops[#drops + 1] = "technic:" .. name:lower() .. (data.locked and "_locked" or "") .. "_chest"
minetest.remove_node(pos)
return drops
end,
@ -277,7 +277,7 @@ function technic.chests:definition(name, data)
def.allow_metadata_inventory_put = self.inv_put
def.allow_metadata_inventory_take = self.inv_take
def.on_blast = function() end
def.can_dig = function(pos,player)
def.can_dig = function(pos, player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main") and default.can_interact_with_node(player, pos)
@ -309,15 +309,15 @@ end
function technic.chests:register(name, data)
local def = technic.chests:definition(name, data)
local nn = "technic:"..name:lower()..(data.locked and "_locked" or "").."_chest"
minetest.register_node(":"..nn, def)
local nn = "technic:" .. name:lower() .. (data.locked and "_locked" or "") .. "_chest"
minetest.register_node(":" .. nn, def)
if data.color then
local mk_front
if string.find(def.tiles[6], "%^") then
mk_front = function (overlay) return def.tiles[6]:gsub("%^", "^"..overlay.."^") end
mk_front = function(overlay) return def.tiles[6]:gsub("%^", "^" .. overlay .. "^") end
else
mk_front = function (overlay) return def.tiles[6].."^"..overlay end
mk_front = function(overlay) return def.tiles[6] .. "^" .. overlay end
end
for i = 1, 15 do
local postfix = colorid_to_postfix(i)
@ -327,10 +327,9 @@ function technic.chests:register(name, data)
end
colordef.drop = nn
colordef.groups = self.groups_noinv
colordef.tiles = { def.tiles[1], def.tiles[2], def.tiles[3], def.tiles[4], def.tiles[5], mk_front("technic_chest_overlay"..postfix..".png") }
minetest.register_node(":"..nn..postfix, colordef)
colordef.tiles = { def.tiles[1], def.tiles[2], def.tiles[3], def.tiles[4], def.tiles[5], mk_front("technic_chest_overlay" .. postfix .. ".png") }
minetest.register_node(":" .. nn .. postfix, colordef)
end
end
end

View File

@ -2,18 +2,18 @@ if minetest.get_modpath("moreores") then
minetest.register_craft({
output = 'technic:silver_chest',
recipe = {
{'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
{'moreores:silver_ingot','technic:copper_chest','moreores:silver_ingot'},
{'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
{ 'moreores:silver_ingot', 'moreores:silver_ingot', 'moreores:silver_ingot' },
{ 'moreores:silver_ingot', 'technic:copper_chest', 'moreores:silver_ingot' },
{ 'moreores:silver_ingot', 'moreores:silver_ingot', 'moreores:silver_ingot' },
}
})
minetest.register_craft({
output = 'technic:silver_locked_chest',
recipe = {
{'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
{'moreores:silver_ingot','technic:copper_locked_chest','moreores:silver_ingot'},
{'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
{ 'moreores:silver_ingot', 'moreores:silver_ingot', 'moreores:silver_ingot' },
{ 'moreores:silver_ingot', 'technic:copper_locked_chest', 'moreores:silver_ingot' },
{ 'moreores:silver_ingot', 'moreores:silver_ingot', 'moreores:silver_ingot' },
}
})
end
@ -21,8 +21,8 @@ end
minetest.register_craft({
output = 'technic:silver_locked_chest',
recipe = {
{'default:steel_ingot'},
{'technic:silver_chest'},
{ 'default:steel_ingot' },
{ 'technic:silver_chest' },
}
})