New workbench

master
MoNTE48 2019-05-17 23:04:12 +02:00
parent b40cd3c590
commit b0346ad88a
37 changed files with 1006 additions and 742 deletions

View File

@ -67,7 +67,7 @@ end
local function get_formspec(self)
local formspec = ""
local name = self.tablist[self.last_tab_index].name
local tabname = name == "local" and name or nil
local tabname = name == "local" and name or name == "online" and name or nil
if not self.hidden and (self.parent == nil or not self.parent.hidden) then
if self.parent == nil then

View File

@ -34,9 +34,9 @@ local function get_formspec(tabview, name, tabdata)
local retval =
-- Search
"field[0.2,0.1;5.71,1;te_search;;" .. core.formspec_escape(tabdata.search_for) .. "]" ..
"image_button[5.52,-0.125;0.85,0.85;" .. core.formspec_escape(defaulttexturedir .. "search.png")
"image_button[5.52,-0.13;0.83,0.83;" .. core.formspec_escape(defaulttexturedir .. "search.png")
.. ";btn_mp_search;" .. "]" ..
"image_button[6.26,-0.125;0.85,0.85;" .. core.formspec_escape(defaulttexturedir .. "refresh.png")
"image_button[6.26,-0.13;0.83,0.83;" .. core.formspec_escape(defaulttexturedir .. "refresh.png")
.. ";btn_mp_refresh;" .. "]" ..
-- Address / Port
@ -58,12 +58,12 @@ local function get_formspec(tabview, name, tabdata)
"box[7.1,2.1;4.8,2.65;#999999]"..
-- Connect
"button[9.4,5;2.7,0.5;btn_mp_connect;" .. fgettext("Connect") .. "]"
"button[9.4,5.045;2.7,0.505;btn_mp_connect;" .. fgettext("Connect") .. "]"
if tabdata.fav_selected and fav_selected then
if gamedata.fav then
retval = retval .. "button[7.1,5;2.3,0.5;btn_delete_favorite;" ..
fgettext("Del. Favorite") .. "]"
retval = retval .. "image_button[7.1,4.91;0.83,0.83;" .. core.formspec_escape(defaulttexturedir .. "trash.png")
.. ";btn_delete_favorite;" .. "]"
end
if fav_selected.description then
retval = retval .. "textarea[7.5,2.3;4.8,2.9;;" ..

View File

@ -173,13 +173,13 @@ local function get_creative_formspec(player_name, start_i, pagenum, page, pagema
local slider_pos = 4 / pagemax * (pagenum - 1) + 2.17
local formspec = ""
local main_list = "list[detached:creative_" .. player_name ..
";main;0,1.69;9,5;"..tostring(start_i).."]"
";main;0.02,1.69;9,5;"..tostring(start_i).."]"
local name = "all"
if page ~= nil then name = page end
if name == "inv" then
main_list = "image[-0.2,1.6;11.35,2.33;creative_bg.png]"..
"image[-0.3,0.15;3,4.3;inventory_armor.png]"..
"list[current_player;main;0,3.68;9,3;9]"..
"list[current_player;main;0.02,3.69;9,3;9]"..
"list[detached:"..player_name.."_armor;armor;0.02,1.7;1,1;]"..
"list[detached:"..player_name.."_armor;armor;0.02,2.7;1,1;1]"..
"list[detached:"..player_name.."_armor;armor;0.98,1.7;1,1;2]"..
@ -196,7 +196,7 @@ local function get_creative_formspec(player_name, start_i, pagenum, page, pagema
"image_button[2.96,-0.15;1,1;"..bg["rail"]..";rail;;;false]".. --transportation
"image_button[4,-0.15;1,1;"..bg["misc"]..";misc;;;false]".. --miscellaneous
"image[0,0.95;5,0.75;fnt_"..name..".png]"..
"list[current_player;main;0,6.955;9,1;]"..main_list..
"list[current_player;main;0.02,6.96;9,1;]"..main_list..
"image_button[9.13,1.69;0.8,0.6;creative_up.png;creative_prev;]"..
"image_button[9.13,6.11;0.8,0.6;creative_down.png;creative_next;]"..
"image_button[5.05,-0.15;1,1;"..bg["food"]..";food;;;false]".. --foodstuff

View File

@ -75,7 +75,8 @@ minetest.register_alias("default:gold_nugget", "default:gold_ingot")
minetest.register_alias("default:sandstonecarved", "default:sandstonesmooth")
-- Workbench
minetest.register_alias("crafting:workbench", "default:workbench")
minetest.register_alias("crafting:workbench", "workbench:workbench")
minetest.register_alias("default:workbench", "workbench:workbench")
-- String
minetest.register_alias("default:string", "farming:string")

View File

@ -21,7 +21,6 @@ dofile(default_path.."/craftitems.lua")
dofile(default_path.."/crafting.lua")
dofile(default_path.."/mapgen.lua")
dofile(default_path.."/aliases.lua")
dofile(default_path.."/workbench.lua")
dofile(default_path.."/torch.lua")
if not minetest.setting_getbool("creative_mode") then

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -1,55 +0,0 @@
--
-- Workbench
--
local function set_workbench(player)
local split_form = ""
local workbench = "size[9,8.75]" ..
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
"background[-0.2,-0.26;9.41,9.49;formspec_workbench.png]" ..
"bgcolor[#08080880;true]" ..
"listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]" ..
"list[detached:split;main;8,3.14;1,1;]"..
"list[current_player;main;0,4.5;9,3;9]" ..
"list[current_player;main;0,7.74;9,1;]" ..
"list[current_player;craft;2,0.5;3,3;]" ..
"list[current_player;craftpreview;6.05,1.5;1,1;]" ..
split_form
minetest.show_formspec(player:get_player_name(), "main", workbench)
end
minetest.register_node("default:workbench", {
description = "Workbench",
tiles = {"workbench_top.png", "workbench_top.png", "workbench_side.png",
"workbench_side.png", "workbench_front.png", "workbench_front.png"},
paramtype2 = "facedir",
paramtype = "light",
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
on_rightclick = function (pos, node, clicker, itemstack)
set_workbench(clicker)
end
})
minetest.register_craft({
output = 'default:workbench',
recipe = {
{'group:wood', 'group:wood'},
{'group:wood', 'group:wood'}
}
})
local split_inv = minetest.create_detached_inventory("split", {
allow_move = function(_, _, _, _, _, count, _)
return count
end,
allow_put = function(_, _, _, stack, _)
return stack:get_count() / 2
end,
allow_take = function(_, _, _, stack, _)
return stack:get_count()
end,
})
split_inv:set_size("main", 1)

View File

@ -1,4 +1,5 @@
Stairs Redo 0.1 based on Minetest 0.4 mod: stairs
MultiCraft Game mod: stairs
Stairs Redo based on Minetest 0.4 mod: stairs
License of source code:
-----------------------
@ -23,4 +24,4 @@ Everything not listed in here:
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
Note: This mod has been changed by TenPlus1 to include other blocks from different mods as well as corner stairs...
Note: This mod has been changed by TenPlus1 to include other blocks from different mods as well as corner stairs and slopes... Holding sneak when placing will copy the rotation of the block pointed at to the newly placed stair.

View File

@ -1,4 +1 @@
default
mobs
mobs_animal
wool

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,71 @@
# Blender v2.76 (sub 0) OBJ File: ''
# www.blender.org
mtllib simplyslope_slope.mtl
o stairs_top
v -0.5 0.5 0.5
v 0.5 0.5 0.5
o stairs_right
v -0.5 -0.5 -0.5
v -0.5 -0.5 0.5
v -0.5 0.5 0.5
v -0.5 0.0 0.0
vt 0.0 0.0
vt 1.0 0.0
vt 1.0 1.0
vn -1.0 0.0 0.0
usemtl None
s 1
f 3/1/1 4/2/1 5/3/1
o front
v -0.5 -0.5 -0.5
v -0.5 0.5 0.5
v 0.5 0.5 0.5
v 0.5 -0.5 -0.5
vt 1.0 0.0
vt 1.0 0.999938
vt 0.0 0.999938
vt 0.0 0.0
vn 0.0 0.707100 -0.707100
usemtl None
s 1
f 7/4/2 8/5/2 9/6/2 10/7/2
o left
v 0.5 -0.5 -0.5
v 0.5 0.5 0.5
v 0.5 -0.5 0.5
v 0.5 0.0 0.0
vt 1.0 0.0
vt 0.0 1.0
vt 0.0 0.0
vn 1.0 0.0 0.0
usemtl None
s 1
f 11/8/3 12/9/3 13/10/3
l 14 11
l 14 12
o bottom
v -0.5 -0.5 0.5
v -0.5 -0.5 -0.5
v 0.5 -0.5 -0.5
v 0.5 -0.5 0.5
vt 1.0 0.0
vt 1.0 1.0
vt 0.0 1.0
vt 0.0 0.0
vn 0.0 -1.0 -0.0
usemtl None
s 1
f 15/11/4 16/12/4 17/13/4 18/14/4
o back
v 0.5 -0.5 0.5
v 0.5 0.5 0.5
v -0.5 0.5 0.5
v -0.5 -0.5 0.5
vt 1.0 0.0
vt 1.0 1.0
vt 0.0 1.0
vt 0.0 0.0
vn 0.0 -0.0 1.0
usemtl None
s 1
f 19/15/5 20/16/5 21/17/5 22/18/5

View File

@ -1,113 +0,0 @@
# Blender v2.72 (sub 0) OBJ File: ''
# www.blender.org
mtllib stairs.mtl
o stairs_top
v -0.500000 0.000000 -0.500000
v -0.500000 0.000000 0.000000
v 0.500000 0.000000 0.000000
v 0.500000 0.000000 -0.500000
v -0.500000 0.500000 0.000000
v 0.500000 0.500000 0.000000
v -0.500000 0.500000 0.500000
v 0.500000 0.500000 0.500000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 0.500000
vt 0.000000 0.500000
vt 1.000000 1.000000
vt 0.000000 1.000000
vn 0.000000 1.000000 0.000000
g stairs_top
usemtl None
s off
f 4/1/1 1/2/1 2/3/1 3/4/1
f 7/5/1 8/6/1 6/4/1 5/3/1
o stairs_bottom
v -0.500000 -0.500000 -0.500000
v 0.500000 -0.500000 -0.500000
v -0.500000 -0.500000 0.500000
v 0.500000 -0.500000 0.500000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vn 0.000000 -1.000000 -0.000000
g stairs_bottom
usemtl None
s off
f 11/7/2 9/8/2 10/9/2 12/10/2
o stairs_right
v -0.500000 0.000000 -0.500000
v -0.500000 -0.500000 -0.500000
v -0.500000 0.000000 0.000000
v -0.500000 -0.500000 0.500000
v -0.500000 0.500000 0.000000
v -0.500000 0.500000 0.500000
vt 0.000000 0.500000
vt 0.000000 0.000000
vt 0.500000 0.500000
vt 1.000000 1.000000
vt 0.500000 1.000000
vt 1.000000 0.000000
vn -1.000000 0.000000 0.000000
g stairs_right
usemtl None
s off
f 13/11/3 14/12/3 15/13/3
f 15/13/3 18/14/3 17/15/3
f 14/12/3 16/16/3 18/14/3
o stairs_left
v 0.500000 0.000000 0.000000
v 0.500000 -0.500000 -0.500000
v 0.500000 0.000000 -0.500000
v 0.500000 -0.500000 0.500000
v 0.500000 0.500000 0.000000
v 0.500000 0.500000 0.500000
vt 0.500000 0.500000
vt 1.000000 0.000000
vt 1.000000 0.500000
vt 0.500000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vn 1.000000 0.000000 0.000000
g stairs_left
usemtl None
s off
f 19/17/4 20/18/4 21/19/4
f 19/17/4 23/20/4 24/21/4
f 20/18/4 24/21/4 22/22/4
o stairs_back
v -0.500000 -0.500000 0.500000
v 0.500000 -0.500000 0.500000
v -0.500000 0.500000 0.500000
v 0.500000 0.500000 0.500000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vn 0.000000 -0.000000 1.000000
g stairs_back
usemtl None
s off
f 26/23/5 28/24/5 27/25/5 25/26/5
o stairs_front
v -0.500000 0.000000 -0.500000
v -0.500000 -0.500000 -0.500000
v -0.500000 0.000000 0.000000
v 0.500000 0.000000 0.000000
v 0.500000 -0.500000 -0.500000
v 0.500000 0.000000 -0.500000
v -0.500000 0.500000 0.000000
v 0.500000 0.500000 0.000000
vt 1.000000 0.000000
vt 1.000000 0.500000
vt 0.000000 0.500000
vt 0.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vn 0.000000 0.000000 -1.000000
g stairs_front
usemtl None
s off
f 30/27/6 29/28/6 34/29/6 33/30/6
f 31/28/6 35/31/6 36/32/6 32/29/6

View File

@ -0,0 +1,64 @@
+----------------------------------------------------------------------+
| Copyright (c) 2015-2017 kilbith <jeanpatrick.guerrero@gmail.com> |
| |
| Code: LGPL version 3.0 |
| Textures: WTFPL (credits: Gambit) |
+----------------------------------------------------------------------+
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.

View File

@ -0,0 +1,9 @@
## Work Bench ##
##### A mod adding a Work Bench to Minetest. #####
##### The Work Bench can cut up to 12 shapes, repair your tools, craft items and store. #####
##### This mod is originating from [X-Decor](https://github.com/kilbith/xdecor). #####
![Preview](http://i.imgur.com/Pqg3G92.png)
![Preview2](http://i.imgur.com/cCR4FJc.png)

View File

@ -0,0 +1,3 @@
default
stairs
xdecor?

View File

@ -0,0 +1,372 @@
local workbench = {}
WB = {}
local min, ceil = math.min, math.ceil
-- 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
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
not def.after_place_node and
not def.on_rightclick and
not def.on_blast and
not def.allow_metadata_inventory_take and
not (def.groups.not_in_creative_inventory == 1) and
not (def.groups.not_cuttable == 1) and
not def.groups.wool and
(def.tiles and type(def.tiles[1]) == "string" and not
def.tiles[1]:find("default_mineral")) and
not def.mesecons and
def.description and
def.description ~= "" and
def.light_source == 0
then
nodes[#nodes+1] = node
end
end
-- Optionally, you can register custom cuttable nodes in the workbench
WB.custom_nodes_register = {
-- "default:leaves",
}
setmetatable(nodes, {
__concat = function(t1, t2)
for i=1, #t2 do
t1[#t1+1] = t2[i]
end
return t1
end
})
nodes = nodes..WB.custom_nodes_register
-- Nodeboxes definitions
workbench.defs = {
-- Name Yield X Y Z W H L
{"nanoslab", 8, { 0, 0, 0, 8, 1, 8 }},
{"micropanel", 8, { 0, 0, 0, 16, 1, 8 }},
{"microslab", 4, { 0, 0, 0, 16, 1, 16 }},
{"thinstair", 4, { 0, 7, 0, 16, 1, 8 },
{ 0, 15, 8, 16, 1, 8 }},
{"cube", 4, { 0, 0, 0, 8, 8, 8 }},
{"panel", 4, { 0, 0, 0, 16, 8, 8 }},
{"slab", 2, nil },
{"doublepanel", 2, { 0, 0, 0, 16, 8, 8 },
{ 0, 8, 8, 16, 8, 8 }},
{"halfstair", 2, { 0, 0, 0, 8, 8, 16 },
{ 0, 8, 8, 8, 8, 8 }},
{"outerstair", 1, { 0, 0, 0, 16, 8, 16 },
{ 0, 8, 8, 8, 8, 8 }},
{"stair", 1, nil },
{"innerstair", 1, { 0, 0, 0, 16, 8, 16 },
{ 0, 8, 8, 16, 8, 8 },
{ 0, 8, 0, 8, 8, 8 }}
}
-- Tools allowed to be repaired
function workbench:repairable(stack)
local tools = {"pick", "axe", "shovel", "sword", "hoe", "armor", "shield"}
for _, t in pairs(tools) do
if stack:find(t) then return true end
end
return false
end
function workbench:get_output(inv, input, name)
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
output[#output+1] = item.." "..count
end
inv:set_list("forms", output)
end
-- Thanks to kaeza for this function
function workbench:pixelbox(size, boxes)
local fixed = {}
for _, box in pairs(boxes) do
-- `unpack` has been changed to `table.unpack` in newest Lua versions
local x, y, z, w, h, l = unpack(box)
fixed[#fixed+1] = {
(x / size) - 0.5,
(y / size) - 0.5,
(z / size) - 0.5,
((x + w) / size) - 0.5,
((y + h) / size) - 0.5,
((z + l) / size) - 0.5
}
end
return {type="fixed", fixed=fixed}
end
local formspecs = {
-- Workbench formspec
[[ background[-0.2,-0.26;9.41,9.49;formspec_workbench_crafting.png]
button[0,0;2,1;creating;Creating]
button[0,1;2,1;anvil;Repairing]
list[current_player;craft;2,0.5;3,3;]
list[current_player;craftpreview;6.055,1.505;1,1;] ]],
-- Creating formspec
[[ background[-0.2,-0.26;9.41,9.49;formspec_workbench_creating.png]
button[0,0;1.5,1;back;< Back]
image[0,1.52;1,1;workbench_saw.png]
list[context;input;1.195,1.505;1,1;]
list[context;forms;4.01,0.51;4,3;] ]],
-- Repair formspec
[[ background[-0.2,-0.26;9.41,9.49;formspec_workbench_anvil.png]
button[0,0;1.5,1;back;< Back]
image[0,1.52;1,1;workbench_anvil.png]
list[context;tool;1.195,1.505;1,1;]
image[4.04,1.55;1,1;hammer_layout.png]
list[context;hammer;4.065,1.505;1,1;] ]],
}
local split_inv = minetest.create_detached_inventory("split", {
allow_move = function(_, _, _, _, _, count, _)
return count
end,
allow_put = function(_, _, _, stack, _)
return stack:get_count() / 2
end,
allow_take = function(_, _, _, stack, _)
return stack:get_count()
end,
})
split_inv:set_size("main", 1)
local function item_drop(itemstack, dropper, pos)
if dropper:is_player() then
local v = dropper:get_look_dir()
local p = {x=pos.x, y=pos.y+1.2, z=pos.z}
p.x = p.x+(math.random(1,3)*0.2)
p.z = p.z+(math.random(1,3)*0.2)
local obj = minetest.add_item(p, itemstack)
if obj then
v.x = v.x*4
v.y = v.y*4 + 2
v.z = v.z*4
obj:setvelocity(v)
end
else
minetest.add_item(pos, itemstack)
end
return itemstack
end
local function drop_fields(player, name)
local inv = player:get_inventory()
for i,stack in ipairs(inv:get_list(name)) do
item_drop(stack, player, player:get_pos())
stack:clear()
inv:set_stack(name, i, stack)
end
end
function workbench:set_formspec(meta, id)
meta:set_string("formspec", "size[9,8.75;]"..
"bgcolor[#08080880;true]" ..
"background[-0.2,-0.26;9.41,9.49;formspec_workbench.png]" ..
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]" ..
"listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]" ..
"list[detached:split;main;8,3.14;1,1;]"..
"list[current_player;main;0.01,4.51;9,3;9]"..
"list[current_player;main;0.01,7.75;9,1;]"..
formspecs[id])
end
function workbench.construct(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
inv:set_size("tool", 1)
inv:set_size("input", 1)
inv:set_size("hammer", 1)
inv:set_size("forms", 4*3)
inv:set_size("storage", 9*3)
meta:set_string("infotext", "Workbench")
workbench:set_formspec(meta, 1)
end
function workbench.fields(pos, _, fields)
local meta = minetest.get_meta(pos)
if fields.back then workbench:set_formspec(meta, 1)
elseif fields.creating then workbench:set_formspec(meta, 2)
elseif fields.anvil then workbench:set_formspec(meta, 3) end
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")
end
function workbench.timer(pos)
local timer = minetest.get_node_timer(pos)
local inv = minetest.get_meta(pos):get_inventory()
local tool = inv:get_stack("tool", 1)
local hammer = inv:get_stack("hammer", 1)
if tool:is_empty() or hammer:is_empty() or tool:get_wear() == 0 then
timer:stop()
return
end
-- Tool's wearing range: 0-65535 | 0 = new condition
tool:add_wear(-500)
hammer:add_wear(700)
inv:set_stack("tool", 1, tool)
inv:set_stack("hammer", 1, hammer)
return true
end
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 == "workbench:hammer") or
listname == "storage" then
return stack:get_count()
end
return 0
end
function workbench.move(_, from_list, _, to_list, _, count)
return (to_list == "storage" and from_list ~= "forms") and count or 0
end
function workbench.on_put(pos, listname, _, stack)
local inv = minetest.get_meta(pos):get_inventory()
if listname == "input" then
local input = inv:get_stack("input", 1)
workbench:get_output(inv, input, stack:get_name())
elseif listname == "tool" or listname == "hammer" then
local timer = minetest.get_node_timer(pos)
timer:start(0.5)
end
end
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 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, inputname)
end
end
minetest.register_node("workbench:workbench", {
description = "Workbench",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 2, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
tiles = {"workbench_top.png", "workbench_top.png",
"workbench_sides.png", "workbench_sides.png",
"workbench_front.png", "workbench_front.png"},
can_dig = workbench.dig,
on_timer = workbench.timer,
on_construct = workbench.construct,
on_receive_fields = workbench.fields,
on_metadata_inventory_put = workbench.on_put,
on_metadata_inventory_take = workbench.on_take,
allow_metadata_inventory_put = workbench.put,
allow_metadata_inventory_move = workbench.move
})
minetest.register_tool("workbench:hammer", {
description = "Hammer",
inventory_image = "workbench_hammer.png",
on_use = function() do return end end
})
minetest.register_craft({
output = "workbench:workbench",
recipe = {
{"group:wood", "group:wood"},
{"group:wood", "group:wood"}
}
})
minetest.register_craft({
output = "workbench:hammer",
recipe = {
{"default:steel_ingot", "group:stick", "default:steel_ingot"},
{"", "group:stick", ""}
}
})
for _, d in pairs(workbench.defs) do
for i=1, #nodes do
local node = nodes[i]
local def = minetest.registered_nodes[node]
if d[3] then
local groups = {}
local tiles
groups.not_in_creative_inventory = 1
for k, v in pairs(def.groups) do
if k ~= "wood" and k ~= "stone" and k ~= "level" then
groups[k] = v
end
end
if def.tiles then
if #def.tiles > 1 and not (def.drawtype:sub(1,5) == "glass") then
tiles = def.tiles
else
tiles = {def.tiles[1]}
end
else
tiles = {def.tile_images[1]}
end
if not minetest.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)
end
minetest.register_node(":"..node.."_"..d[1], {
description = def.description.." "..d[1]:gsub("^%l", string.upper),
paramtype = "light",
paramtype2 = "facedir",
drawtype = "nodebox",
sounds = def.sounds,
tiles = tiles,
groups = groups,
-- `unpack` has been changed to `table.unpack` in newest Lua versions.
node_box = workbench:pixelbox(16, {unpack(d, 3)}),
sunlight_propagates = true,
on_place = minetest.rotate_node
})
end
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 791 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

View File

Before

Width:  |  Height:  |  Size: 583 B

After

Width:  |  Height:  |  Size: 583 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

View File

Before

Width:  |  Height:  |  Size: 566 B

After

Width:  |  Height:  |  Size: 566 B

View File

Before

Width:  |  Height:  |  Size: 447 B

After

Width:  |  Height:  |  Size: 447 B

BIN
textures/base/bg_online.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 B

After

Width:  |  Height:  |  Size: 953 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 B

After

Width:  |  Height:  |  Size: 918 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 569 B

After

Width:  |  Height:  |  Size: 685 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 494 B

After

Width:  |  Height:  |  Size: 627 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 B

After

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 B

After

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 B

After

Width:  |  Height:  |  Size: 848 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 B

After

Width:  |  Height:  |  Size: 840 B

BIN
textures/base/trash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 945 B