Skip to content
Snippets Groups Projects
Commit 45ce1a8e authored by Milan's avatar Milan
Browse files

resolve mergeconflicts

parents 832d002d 787ba258
No related branches found
No related tags found
No related merge requests found
......@@ -6,4 +6,5 @@ read_globals = {
"vector", "ItemStack",
"default",
"stairs", "doors", "xpanes",
"xdecor", "xbg",
}
+----------------------------------------------------------------------+
| Copyright (c) 2015-2016 kilbith <jeanpatrick.guerrero@gmail.com> |
| |
| Code: GPL version 3 |
| Textures: WTFPL (credits: Gambit, kilbith, Cisoun) |
| Sounds: |
| - xdecor_boiling_water.ogg - by Audionautics - CC BY-SA |
| freesound.org/people/Audionautics/sounds/133901/ |
| - xdecor_enchanting.ogg - by Timbre - CC BY-SA-NC |
| freesound.org/people/Timbre/sounds/221683/ |
| - xdecor_bouncy.ogg - by Blender Foundation - CC BY 3.0 |
| opengameart.org/content/funny-comic-cartoon-bounce-sound |
+----------------------------------------------------------------------+
┌──────────────────────────────────────────────────────────────────────┐
Copyright (c) 2015-2017 kilbith <jeanpatrick.guerrero@gmail.com>
Code: GPL version 3
Textures: WTFPL (credits: Gambit, kilbith, Cisoun)
Sounds:
- xdecor_boiling_water.ogg - by Audionautics - CC BY-SA
freesound.org/people/Audionautics/sounds/133901/
- xdecor_enchanting.ogg - by Timbre - CC BY-SA-NC
freesound.org/people/Timbre/sounds/221683/
- xdecor_bouncy.ogg - by Blender Foundation - CC BY 3.0
opengameart.org/content/funny-comic-cartoon-bounce-sound
└──────────────────────────────────────────────────────────────────────┘
GNU GENERAL PUBLIC LICENSE
......
......@@ -15,7 +15,7 @@ end
function realchess.init(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local formspec = [[ size[8,8.6;]
bgcolor[#080808BB;true]
background[0,0;8,8;chess_bg.png]
......@@ -101,7 +101,7 @@ function realchess.move(pos, from_list, from_index, to_list, to_index, _, player
if playerWhite ~= "" and playerWhite ~= playerName then
minetest.chat_send_player(playerName, "Someone else plays white pieces!")
return 0
end
end
if lastMove ~= "" and lastMove ~= "black" then
minetest.chat_send_player(playerName, "It's not your turn, wait for your opponent to play.")
return 0
......@@ -361,7 +361,7 @@ function realchess.move(pos, from_list, from_index, to_list, to_index, _, player
return 0
end
end
end
end
elseif from_x < to_x then
if from_y == to_y then
-- goes right
......@@ -387,7 +387,7 @@ function realchess.move(pos, from_list, from_index, to_list, to_index, _, player
return 0
end
end
end
end
else
if from_y == to_y then
-- goes left
......@@ -413,14 +413,14 @@ function realchess.move(pos, from_list, from_index, to_list, to_index, _, player
return 0
end
end
end
end
end
elseif pieceFrom:sub(11,14) == "king" then
local dx = from_x - to_x
local dy = from_y - to_y
local check = true
if thisMove == "white" then
if from_y == 7 and to_y == 7 then
if to_x == 1 then
......@@ -492,12 +492,12 @@ function realchess.move(pos, from_list, from_index, to_list, to_index, _, player
if dy < 0 then dy = -dy end
if dx > 1 or dy > 1 then return 0 end
end
if thisMove == "white" then
meta:set_int("castlingWhiteL", 0)
meta:set_int("castlingWhiteR", 0)
elseif thisMove == "black" then
meta:set_int("castlingBlackL", 0)
meta:set_int("castlingBlackL", 0)
meta:set_int("castlingBlackR", 0)
end
end
......
......@@ -88,7 +88,7 @@ end
function cauldron.boiling_timer(pos)
local node = minetest.get_node(pos)
local objs = minetest.get_objects_inside_radius(pos, 0.5)
if objs == {} then return true end
if not next(objs) then return true end
local ingredients = {}
for _, obj in pairs(objs) do
......
......@@ -11,16 +11,7 @@ minetest.register_craftitem("xdecor:bowl_soup", {
wield_image = "xdecor_bowl_soup.png",
groups = {not_in_creative_inventory=1},
stack_max = 1,
on_use = function(itemstack, gamer)
if rawget(_G, "hbhunger") then
minetest.item_eat(20)
else
gamer:set_hp(20)
end
gamer:get_inventory():add_item("main", "xdecor:bowl")
itemstack:take_item(1)
return itemstack
end
on_use = minetest.item_eat(30, "xdecor:bowl")
})
minetest.register_alias("xdecor:hammer", "cottages:hammer")
......
......@@ -42,19 +42,18 @@ function enchanting:get_tooltip(enchant, orig_caps, fleshy)
strong = {"#ff3d3d", ""},
speed = {"#fd5eff", ""}
}
return minetest.colorize and
minetest.colorize(specs[enchant][1],
"\n"..cap(enchant)..specs[enchant][2]) or
"\n"..cap(enchant)..specs[enchant][2]
return minetest.colorize and minetest.colorize(specs[enchant][1],
"\n"..cap(enchant)..specs[enchant][2]) or
"\n"..cap(enchant)..specs[enchant][2]
end
local enchant_buttons = {
[[ image_button[3.9,0.85;4,0.92;bg_btn.png;fast;Efficiency]
image_button[3.9,1.77;4,1.12;bg_btn.png;durable;Durability] ]],
"image_button[3.9,0.85;4,0.92;bg_btn.png;strong;Strength]",
"image_button[3.9,2.9;4,0.92;bg_btn.png;sharp;Sharpness]",
[[ image_button[3.9,0.85;4,0.92;bg_btn.png;strong;Strength]
image_button[3.9,1.77;4,1.12;bg_btn.png;speed;Speed] ]]
[[ image_button[3.9,0.85;4,0.92;bg_btn.png;fast;Efficiency]
image_button[3.9,1.77;4,1.12;bg_btn.png;durable;Durability] ]],
"image_button[3.9,0.85;4,0.92;bg_btn.png;strong;Strength]",
"image_button[3.9,2.9;4,0.92;bg_btn.png;sharp;Sharpness]",
[[ image_button[3.9,0.85;4,0.92;bg_btn.png;strong;Strength]
image_button[3.9,1.77;4,1.12;bg_btn.png;speed;Speed] ]]
}
function enchanting.formspec(pos, num)
......@@ -65,6 +64,10 @@ function enchanting.formspec(pos, num)
list[context;tool;0.9,2.9;1,1;]
list[context;mese;2,2.9;1,1;]
list[current_player;main;0.5,4.5;8,4;]
listring[current_player;main]
listring[context;tool]
listring[current_player;main]
listring[context;mese]
image[2,2.9;1,1;mese_layout.png]
tooltip[sharp;Your weapon inflicts more damages]
tooltip[durable;Your tool last longer]
......@@ -159,7 +162,8 @@ function enchanting.destruct(pos)
for _, obj in pairs(minetest.get_objects_inside_radius(pos, 0.9)) do
if obj and obj:get_luaentity() and
obj:get_luaentity().name == "xdecor:book_open" then
obj:remove() break
obj:remove()
break
end
end
end
......
......@@ -62,13 +62,13 @@ function mailbox:formspec(pos, owner, is_owner)
"listring[nodemeta:"..spos..";mailbox]"..
xbg..default.get_hotbar_bg(0.75,5.25)
end
return [[ size[8,5]
list[current_player;main;0,1.25;8,4;] ]]..
"label[0,0;Send your goods to\n"..
(minetest.colorize and
minetest.colorize("#FFFF00", owner) or owner).."]"..
"list[nodemeta:"..spos..";drop;3.5,0;1,1;]"..
xbg..default.get_hotbar_bg(0,1.25)
return [[ size[8,5]
list[current_player;main;0,1.25;8,4;] ]]..
"label[0,0;Send your goods to\n"..
(minetest.colorize and
minetest.colorize("#FFFF00", owner) or owner).."]"..
"list[nodemeta:"..spos..";drop;3.5,0;1,1;]"..
xbg..default.get_hotbar_bg(0,1.25)
end
function mailbox.dig(pos, player)
......@@ -133,6 +133,19 @@ function mailbox.on_put(pos, listname, _, stack, player)
end
end
function mailbox.allow_take(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
if player:get_player_name() ~= meta:get_string("owner") then
return 0
end
return stack:get_count()
end
function mailbox.allow_move(pos)
return 0
end
xdecor.register("mailbox", {
description = "Mailbox",
tiles = {"xdecor_mailbox_top.png", "xdecor_mailbox_bottom.png",
......@@ -142,6 +155,8 @@ xdecor.register("mailbox", {
on_rotate = screwdriver.rotate_simple,
can_dig = mailbox.dig,
on_rightclick = mailbox.rightclick,
allow_metadata_inventory_take = mailbox.allow_take,
allow_metadata_inventory_move = mailbox.allow_move,
on_metadata_inventory_put = mailbox.on_put,
allow_metadata_inventory_put = mailbox.put,
after_place_node = mailbox.after_place_node
......
--[[ Thanks to sofar for helping with that code.
Recommended setting in minetest.conf (requires 0.4.14 or newer) :
nodetimer_interval = 0.1
]]
-- Thanks to sofar for helping with that code.
minetest.setting_set("nodetimer_interval", 0.1)
local plate = {}
screwdriver = screwdriver or {}
......@@ -32,14 +31,14 @@ end
function plate.timer(pos)
local objs = minetest.get_objects_inside_radius(pos, 0.8)
if objs == {} or not doors.get then return true end
if not next(objs) or not doors.get then return true end
local minp = {x=pos.x-2, y=pos.y, z=pos.z-2}
local maxp = {x=pos.x+2, y=pos.y, z=pos.z+2}
local doors = minetest.find_nodes_in_area(minp, maxp, "group:door")
for _, player in pairs(objs) do
if player:is_player() then
for i = 1, #doors do
for i=1, #doors do
door_toggle(pos, doors[i], player)
end
break
......@@ -92,15 +91,13 @@ xdecor.register("lever_off", {
sounds = default.node_sound_stone_defaults(),
sunlight_propagates = true,
on_rotate = screwdriver.rotate_simple,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
if not doors.get then
return itemstack
end
on_rightclick = function(pos, node, clicker, itemstack)
if not doors.get then return itemstack end
local minp = {x=pos.x-2, y=pos.y-1, z=pos.z-2}
local maxp = {x=pos.x+2, y=pos.y+1, z=pos.z+2}
local doors = minetest.find_nodes_in_area(minp, maxp, "group:door")
for i = 1, #doors do
for i=1, #doors do
door_toggle(pos, doors[i], clicker)
end
return itemstack
......
screwdriver = screwdriver or {}
function xdecor.register_pane(name, desc, def)
local function register_pane(name, desc, def)
xpanes.register_pane(name, {
description = desc,
tiles = {"xdecor_"..name..".png"},
......@@ -15,21 +15,21 @@ function xdecor.register_pane(name, desc, def)
})
end
xdecor.register_pane("bamboo_frame", "Bamboo Frame", {
register_pane("bamboo_frame", "Bamboo Frame", {
groups = {choppy=3, oddly_breakable_by_hand=2, pane=1, flammable=2},
recipe = {{"default:papyrus", "default:papyrus", "default:papyrus"},
{"default:papyrus", "farming:cotton", "default:papyrus"},
{"default:papyrus", "default:papyrus", "default:papyrus"}}
})
xdecor.register_pane("chainlink", "Chainlink", {
register_pane("chainlink", "Chainlink", {
groups = {cracky=3, oddly_breakable_by_hand=2, pane=1},
recipe = {{"default:steel_ingot", "", "default:steel_ingot"},
{"", "default:steel_ingot", ""},
{"default:steel_ingot", "", "default:steel_ingot"}}
})
xdecor.register_pane("rusty_bar", "Rusty Iron Bars", {
register_pane("rusty_bar", "Rusty Iron Bars", {
sounds = default.node_sound_stone_defaults(),
groups = {cracky=2, pane=1},
recipe = {{"", "default:dirt", ""},
......@@ -37,7 +37,7 @@ xdecor.register_pane("rusty_bar", "Rusty Iron Bars", {
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}}
})
xdecor.register_pane("wood_frame", "Wood Frame", {
register_pane("wood_frame", "Wood Frame", {
sounds = default.node_sound_wood_defaults(),
groups = {choppy=2, pane=1, flammable=2},
recipe = {{"group:wood", "group:stick", "group:wood"},
......@@ -65,7 +65,7 @@ xdecor.register("barrel", {
sounds = default.node_sound_wood_defaults()
})
function xdecor.register_storage(name, desc, def)
local function register_storage(name, desc, def)
xdecor.register(name, {
description = desc,
inventory = {size=def.inv_size or 24},
......@@ -79,14 +79,14 @@ function xdecor.register_storage(name, desc, def)
})
end
xdecor.register_storage("cabinet", "Wooden Cabinet", {
register_storage("cabinet", "Wooden Cabinet", {
on_rotate = screwdriver.rotate_simple,
tiles = {"xdecor_cabinet_sides.png", "xdecor_cabinet_sides.png",
"xdecor_cabinet_sides.png", "xdecor_cabinet_sides.png",
"xdecor_cabinet_sides.png", "xdecor_cabinet_front.png"}
})
xdecor.register_storage("cabinet_half", "Half Wooden Cabinet", {
register_storage("cabinet_half", "Half Wooden Cabinet", {
inv_size = 8,
node_box = xdecor.nodebox.slab_y(0.5, 0.5),
on_rotate = screwdriver.rotate_simple,
......@@ -95,14 +95,16 @@ xdecor.register_storage("cabinet_half", "Half Wooden Cabinet", {
"xdecor_half_cabinet_sides.png", "xdecor_half_cabinet_front.png"}
})
xdecor.register_storage("empty_shelf", "Empty Shelf", {
register_storage("empty_shelf", "Empty Shelf", {
on_rotate = screwdriver.rotate_simple,
tiles = {"default_wood.png", "default_wood.png^xdecor_empty_shelf.png"}
tiles = {"default_wood.png", "default_wood.png", "default_wood.png",
"default_wood.png", "default_wood.png^xdecor_empty_shelf.png"}
})
xdecor.register_storage("multishelf", "Multi Shelf", {
register_storage("multishelf", "Multi Shelf", {
on_rotate = screwdriver.rotate_simple,
tiles = {"default_wood.png", "default_wood.png^xdecor_multishelf.png"},
tiles = {"default_wood.png", "default_wood.png", "default_wood.png",
"default_wood.png", "default_wood.png^xdecor_multishelf.png"},
})
xdecor.register("candle", {
......@@ -142,38 +144,40 @@ xdecor.register("chair", {
}),
can_dig = xdecor.sit_dig,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
pos.y = pos.y + 0 -- Sitting position.
pos.y = pos.y + 0 -- Sitting position
xdecor.sit(pos, node, clicker, pointed_thing)
return itemstack
end
})
for _, c in pairs({"red"}) do -- Add more curtains colors simply here.
for _, c in pairs({"red"}) do -- Add more curtains colors simply here
xdecor.register("curtain_"..c, {
description = c:gsub("^%l", string.upper).." Curtain",
walkable = false,
tiles = {"wool_white.png^[colorize:"..c..":170"},
inventory_image = "wool_white.png^[colorize:"..c..":170^xdecor_curtain_open_overlay.png^[makealpha:255,126,126",
inventory_image = "wool_white.png^[colorize:"..c..
":170^xdecor_curtain_open_overlay.png^[makealpha:255,126,126",
wield_image = "wool_white.png^[colorize:"..c..":170",
drawtype = "signlike",
paramtype2 = "wallmounted",
groups = {dig_immediate=3, flammable=3},
selection_box = {type="wallmounted"},
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
on_rightclick = function(pos, node, _, itemstack)
minetest.set_node(pos, {name="xdecor:curtain_open_"..c, param2=node.param2})
return itemstack
end
})
xdecor.register("curtain_open_"..c, {
tiles = {"wool_white.png^[colorize:"..c..":170^xdecor_curtain_open_overlay.png^[makealpha:255,126,126"},
tiles = {"wool_white.png^[colorize:"..c..
":170^xdecor_curtain_open_overlay.png^[makealpha:255,126,126"},
drawtype = "signlike",
paramtype2 = "wallmounted",
walkable = false,
groups = {dig_immediate=3, flammable=3, not_in_creative_inventory=1},
selection_box = {type="wallmounted"},
drop = "xdecor:curtain_"..c,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
on_rightclick = function(pos, node, _, itemstack)
minetest.set_node(pos, {name="xdecor:curtain_"..c, param2=node.param2})
return itemstack
end
......@@ -181,8 +185,8 @@ for _, c in pairs({"red"}) do -- Add more curtains colors simply here.
minetest.register_craft({
output = "xdecor:curtain_"..c.." 4",
recipe = { {"", "wool:"..c, ""},
{"", "wool:"..c, ""} }
recipe = {{"", "wool:"..c, ""},
{"", "wool:"..c, ""}}
})
end
......@@ -194,7 +198,7 @@ xdecor.register("cushion", {
node_box = xdecor.nodebox.slab_y(0.5),
can_dig = xdecor.sit_dig,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
pos.y = pos.y + 0 -- Sitting position.
pos.y = pos.y + 0 -- Sitting position
xdecor.sit(pos, node, clicker, pointed_thing)
return itemstack
end
......@@ -206,7 +210,10 @@ xdecor.register("cushion_block", {
groups = {snappy=3, flammable=3, fall_damage_add_percent=-75, not_in_creative_inventory=1}
})
local function door_access(name) return name:find("prison") end
local function door_access(name)
return name:find("prison")
end
local xdecor_doors = {
japanese = {
{"group:wood", "default:paper"},
......@@ -299,7 +306,7 @@ xdecor.register("lantern", {
paramtype2 = "wallmounted",
walkable = false,
groups = {snappy=3, attached_node=1},
tiles = {{name = "xdecor_lantern.png", animation = {type="vertical_frames", length=1.5}}},
tiles = {{name="xdecor_lantern.png", animation={type="vertical_frames", length=1.5}}},
selection_box = xdecor.pixelbox(16, {{4, 0, 4, 8, 16, 8}})
})
......@@ -328,8 +335,8 @@ for _, f in pairs({"dandelion_white", "dandelion_yellow", "geranium",
minetest.register_craft({
output = "xdecor:potted_"..f,
recipe = { {"default:clay_brick", "flowers:"..f, "default:clay_brick"},
{"", "default:clay_brick", ""} }
recipe = {{"default:clay_brick", "flowers:"..f,
"default:clay_brick"}, {"", "default:clay_brick", ""}}
})
end
......@@ -353,8 +360,10 @@ xdecor.register("painting_1", {
node_placement_prediction = "",
on_place = function(itemstack, placer, pointed_thing)
local num = math.random(4)
local leftover = minetest.item_place_node(ItemStack("xdecor:painting_"..num), placer, pointed_thing)
if leftover:get_count() == 0 and not minetest.setting_getbool("creative_mode") then
local leftover = minetest.item_place_node(
ItemStack("xdecor:painting_"..num), placer, pointed_thing)
if leftover:get_count() == 0 and
not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return itemstack
......@@ -367,7 +376,8 @@ for i = 2, 4 do
paramtype2 = "wallmounted",
drop = "xdecor:painting_1",
sunlight_propagates = true,
groups = {choppy=3, oddly_breakable_by_hand=2, flammable=2, attached_node=1, not_in_creative_inventory=1},
groups = {choppy=3, oddly_breakable_by_hand=2, flammable=2,
attached_node=1, not_in_creative_inventory=1},
sounds = default.node_sound_wood_defaults(),
node_box = painting_box
})
......@@ -387,7 +397,8 @@ xdecor.register("stonepath", {
selection_box = xdecor.nodebox.slab_y(0.05)
})
function xdecor.register_hard_node(name, desc, def)
local function register_hard_node(name, desc, def)
def = def or {}
xdecor.register(name, {
description = desc,
tiles = {"xdecor_"..name..".png"},
......@@ -396,18 +407,18 @@ function xdecor.register_hard_node(name, desc, def)
})
end
xdecor.register_hard_node("cactusbrick", "Cactus Brick", {})
xdecor.register_hard_node("coalstone_tile", "Coal Stone Tile", {})
xdecor.register_hard_node("desertstone_tile", "Desert Stone Tile", {})
xdecor.register_hard_node("hard_clay", "Hardened Clay", {})
xdecor.register_hard_node("moonbrick", "Moon Brick", {})
xdecor.register_hard_node("stone_tile", "Stone Tile", {})
xdecor.register_hard_node("stone_rune", "Runestone", {})
xdecor.register_hard_node("packed_ice", "Packed Ice", {
register_hard_node("cactusbrick", "Cactus Brick")
register_hard_node("coalstone_tile", "Coal Stone Tile")
register_hard_node("desertstone_tile", "Desert Stone Tile")
register_hard_node("hard_clay", "Hardened Clay")
register_hard_node("moonbrick", "Moon Brick")
register_hard_node("stone_tile", "Stone Tile")
register_hard_node("stone_rune", "Runestone")
register_hard_node("packed_ice", "Packed Ice", {
groups = {cracky=1, puts_out_fire=1},
sounds = default.node_sound_glass_defaults()
})
xdecor.register_hard_node("wood_tile", "Wooden Tile", {
register_hard_node("wood_tile", "Wooden Tile", {
groups = {choppy=1, wood=1, flammable=2},
sounds = default.node_sound_wood_defaults()
})
......@@ -460,5 +471,3 @@ xdecor.register("woodframed_glass", {
groups = {cracky=2, oddly_breakable_by_hand=1},
sounds = default.node_sound_glass_defaults()
})
minetest.register_alias("xdecor:worktable", "xdecor:workbench")
local workbench = {}
WB = {}
screwdriver = screwdriver or {}
local min, ceil = math.min, math.ceil
local registered_nodes = minetest.registered_nodes
-- Nodes allowed to be cut.
-- Only the regular, solid blocks without metas or explosivity can be cut.
-- Nodes allowed to be cut
-- Only the regular, solid blocks without metas or explosivity can be cut
local nodes = {}
for node, def in pairs(minetest.registered_nodes) do
for node, def in pairs(registered_nodes) do
if (def.drawtype == "normal" or def.drawtype:sub(1,5) == "glass") and
(def.groups.cracky or def.groups.choppy) and
not def.on_construct and
......@@ -27,8 +29,8 @@ for node, def in pairs(minetest.registered_nodes) do
end
end
-- Optionally, you can register custom cuttable nodes in the workbench.
workbench.custom_nodes_register = {
-- Optionally, you can register custom cuttable nodes in the workbench
WB.custom_nodes_register = {
-- "default:leaves",
}
......@@ -41,9 +43,9 @@ setmetatable(nodes, {
end
})
nodes = nodes..workbench.custom_nodes_register
nodes = nodes..WB.custom_nodes_register
-- Nodeboxes definitions.
-- Nodeboxes definitions
workbench.defs = {
-- Name Yield X Y Z W H L
{"nanoslab", 16, { 0, 0, 0, 8, 1, 8 }},
......@@ -66,7 +68,7 @@ workbench.defs = {
{ 0, 8, 0, 8, 8, 8 }}
}
-- Tools allowed to be repaired.
-- Tools allowed to be repaired
function workbench:repairable(stack)
local tools = {"pick", "axe", "shovel", "sword", "hoe", "armor", "shield"}
for _, t in pairs(tools) do
......@@ -76,22 +78,19 @@ function workbench:repairable(stack)
end
function workbench:get_output(inv, input, name)
if inv:is_empty("input") then
inv:set_list("forms", {}) return
end
local output = {}
for _, n in pairs(self.defs) do
local count = min(n[2] * input:get_count(), input:get_stack_max())
local item = name.."_"..n[1]
if not n[3] then item = "stairs:"..n[1].."_"..name:match(":(.*)") end
for i=1, #self.defs do
local nbox = self.defs[i]
local count = min(nbox[2] * input:get_count(), input:get_stack_max())
local item = name.."_"..nbox[1]
item = nbox[3] and item or "stairs:"..nbox[1].."_"..name:match(":(.*)")
output[#output+1] = item.." "..count
end
inv:set_list("forms", output)
end
local formspecs = {
-- Main formspec.
-- Main formspec
[[ label[0.9,1.23;Cut]
label[0.9,2.23;Repair]
box[-0.05,1;2.05,0.9;#555555]
......@@ -105,15 +104,23 @@ local formspecs = {
list[context;input;2,1;1,1;]
list[context;tool;2,2;1,1;]
list[context;hammer;3,2;1,1;]
list[context;forms;4,0;4,3;] ]],
-- Crafting formspec.
list[context;forms;4,0;4,3;]
listring[current_player;main]
listring[context;tool]
listring[current_player;main]
listring[context;hammer]
listring[current_player;main]
listring[context;forms]
listring[current_player;main]
listring[context;input] ]],
-- Crafting formspec
[[ image[5,1;1,1;gui_furnace_arrow_bg.png^[transformR270]
button[0,0;1.5,1;back;< Back]
list[current_player;craft;2,0;3,3;]
list[current_player;craftpreview;6,1;1,1;]
listring[current_player;main]
listring[current_player;craft] ]],
-- Storage formspec.
-- Storage formspec
[[ list[context;storage;0,1;8,2;]
button[0,0;1.5,1;back;< Back]
listring[context;storage]
......@@ -121,7 +128,8 @@ local formspecs = {
}
function workbench:set_formspec(meta, id)
meta:set_string("formspec", "size[8,7;]list[current_player;main;0,3.25;8,4;]"..
meta:set_string("formspec",
"size[8,7;]list[current_player;main;0,3.25;8,4;]"..
formspecs[id]..xbg..default.get_hotbar_bg(0,3.25))
end
......@@ -140,16 +148,17 @@ function workbench.construct(pos)
end
function workbench.fields(pos, _, fields)
if fields.quit then return end
local meta = minetest.get_meta(pos)
if fields.back then workbench:set_formspec(meta, 1)
elseif fields.craft then workbench:set_formspec(meta, 2)
elseif fields.storage then workbench:set_formspec(meta, 3) end
workbench:set_formspec(meta, fields.back and 1 or
fields.craft and 2 or
fields.storage and 3)
end
function workbench.dig(pos)
local inv = minetest.get_meta(pos):get_inventory()
return inv:is_empty("input") and inv:is_empty("hammer") and
inv:is_empty("tool") and inv:is_empty("storage")
inv:is_empty("tool") and inv:is_empty("storage")
end
function workbench.timer(pos)
......@@ -159,10 +168,11 @@ function workbench.timer(pos)
local hammer = inv:get_stack("hammer", 1)
if tool:is_empty() or hammer:is_empty() or tool:get_wear() == 0 then
timer:stop() return
timer:stop()
return
end
-- Tool's wearing range: 0-65535 | 0 = new condition.
-- Tool's wearing range: 0-65535 | 0 = new condition
tool:add_wear(-500)
hammer:add_wear(700)
......@@ -175,26 +185,16 @@ function workbench.put(_, listname, _, stack)
local stackname = stack:get_name()
if (listname == "tool" and stack:get_wear() > 0 and
workbench:repairable(stackname)) or
(listname == "input" and minetest.registered_nodes[stackname.."_cube"]) or
(listname == "hammer" and stackname == "cottages:hammer") or
(listname == "input" and registered_nodes[stackname.."_cube"]) or
(listname == "hammer" and stackname == "xdecor:hammer") or
listname == "storage" then
return stack:get_count()
end
return 0
end
function workbench.take(_, listname, _, stack, player)
if listname == "forms" then
local inv = player:get_inventory()
if inv:room_for_item("main", stack:get_name()) then return -1 end
return 0
end
return stack:get_count()
end
function workbench.move(_, from_list, _, to_list, _, count)
if to_list == "storage" and from_list ~= "forms" then return count end
return 0
return (to_list == "storage" and from_list ~= "forms") and count or 0
end
function workbench.on_put(pos, listname, _, stack)
......@@ -208,20 +208,30 @@ function workbench.on_put(pos, listname, _, stack)
end
end
function workbench.on_take(pos, listname, index, stack)
function workbench.on_take(pos, listname, index, stack, player)
local inv = minetest.get_meta(pos):get_inventory()
local input = inv:get_stack("input", 1)
local inputname = input:get_name()
local stackname = stack:get_name()
if listname == "input" then
if stack:get_name() == input:get_name() then
workbench:get_output(inv, input, stack:get_name())
if stackname == inputname then
workbench:get_output(inv, input, stackname)
else
inv:set_list("forms", {})
end
elseif listname == "forms" then
local fromstack = inv:get_stack(listname, index)
if not fromstack:is_empty() and fromstack:get_name() ~= stackname then
local player_inv = player:get_inventory()
if player_inv:room_for_item("main", fromstack) then
player_inv:add_item("main", fromstack)
end
end
input:take_item(ceil(stack:get_count() / workbench.defs[index][2]))
inv:set_stack("input", 1, input)
workbench:get_output(inv, input, input:get_name())
workbench:get_output(inv, input, inputname)
end
end
......@@ -240,14 +250,13 @@ xdecor.register("workbench", {
on_metadata_inventory_put = workbench.on_put,
on_metadata_inventory_take = workbench.on_take,
allow_metadata_inventory_put = workbench.put,
allow_metadata_inventory_take = workbench.take,
allow_metadata_inventory_move = workbench.move
})
for _, d in pairs(workbench.defs) do
for i=1, #nodes do
local node = nodes[i]
local def = minetest.registered_nodes[node]
local def = registered_nodes[node]
if d[3] then
local groups = {}
......@@ -261,7 +270,7 @@ for i=1, #nodes do
end
if def.tiles then
if #def.tiles > 1 and not (def.drawtype:sub(1,5) == "glass") then
if #def.tiles > 1 and (def.drawtype:sub(1,5) ~= "glass") then
tiles = def.tiles
else
tiles = {def.tiles[1]}
......@@ -270,7 +279,7 @@ for i=1, #nodes do
tiles = {def.tile_images[1]}
end
if not minetest.registered_nodes["stairs:slab_"..node:match(":(.*)")] then
if not registered_nodes["stairs:slab_"..node:match(":(.*)")] then
stairs.register_stair_and_slab(node:match(":(.*)"), node,
groups, tiles, def.description.." Stair",
def.description.." Slab", def.sounds)
......@@ -284,7 +293,7 @@ for i=1, #nodes do
sounds = def.sounds,
tiles = tiles,
groups = groups,
-- `unpack` has been changed to `table.unpack` in newest Lua versions.
-- `unpack` has been changed to `table.unpack` in newest Lua versions
node_box = xdecor.pixelbox(16, {unpack(d, 3)}),
sunlight_propagates = true,
on_place = minetest.rotate_node
......@@ -292,4 +301,3 @@ for i=1, #nodes do
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment