updated item_drop, only current player is given

master
cornernote 2012-07-31 13:45:16 +09:30
parent 4c89b3d82c
commit 626f902a64
24 changed files with 463 additions and 165 deletions

View File

@ -1,23 +1,11 @@
function item_drop(pos, oldnode, digger, anzahl)
if anzahl == nil then
anzahl = 1
end
for i=1,anzahl do
if digger:get_inventory():room_for_item("main", ItemStack(oldnode.name)) then
digger:get_inventory():remove_item("main", ItemStack(oldnode.name))
end
local item = minetest.env:add_item(pos, oldnode)
local x = math.random(1, 5)
if math.random(1,2) == 1 then
x = -x
end
local z = math.random(1, 5)
if math.random(1,2) == 1 then
z = -z
end
item:setvelocity({x=1/x, y=item:getvelocity().y, z=1/z})
end
end
-- INSTALL INSTRUCTIONS
-- OPEN:
-- builtin/item.lua
-- FIND:
-- digger:get_inventory():add_item("main", dropped_item)
-- REPLACE WITH:
-- local item = minetest.env:add_item(pos,dropped_item);
-- item:get_luaentity().dug_by = digger:get_player_name()
local players = {}
@ -36,29 +24,34 @@ minetest.register_globalstep(function(dtime)
local items = minetest.env:get_objects_inside_radius(pos,1)
for j,item in ipairs(items) do
if not item:is_player() and item:get_luaentity().itemstring ~= nil then
if item:get_luaentity().itemstring ~= "" and player:get_inventory():room_for_item("main", ItemStack(item:get_luaentity().itemstring)) then
minetest.debug("[item_drop] Item given: "..item:get_luaentity().itemstring)
player:get_inventory():add_item("main", ItemStack(item:get_luaentity().itemstring))
minetest.sound_play("item_drop_pickup", {
to_player = player,
})
item:remove()
item:get_luaentity().itemstring = ""
if item:get_luaentity().dug_by == player:get_player_name() then
if item:get_luaentity().itemstring ~= "" and player:get_inventory():room_for_item("main", ItemStack(item:get_luaentity().itemstring)) then
minetest.debug("[item_drop] Item given: "..item:get_luaentity().itemstring)
player:get_inventory():add_item("main", ItemStack(item:get_luaentity().itemstring))
minetest.sound_play("item_drop_pickup", {
to_player = player,
})
item:remove()
item:get_luaentity().itemstring = ""
end
end
end
end
items = minetest.env:get_objects_inside_radius(pos,3)
for j,item in ipairs(items) do
if not item:is_player() and item:get_luaentity().itemstring ~= nil then
if item:get_luaentity().dug_by == player:get_player_name() then
if player:get_inventory():room_for_item("main", ItemStack(item:get_luaentity().itemstring)) then
local p = player:getpos()
p.y = p.y+0.5
local i = item:getpos()
local move = {x=(p.x-i.x)*15, y=(p.y-i.y)*15, z=(p.z-i.z)*15}
item:setacceleration(move)
end
end
end
end
items = minetest.env:get_objects_inside_radius(pos,4)
for j,item in ipairs(items) do
if not item:is_player() and item:get_luaentity().itemstring ~= nil then
if player:get_inventory():room_for_item("main", ItemStack(item:get_luaentity().itemstring)) then
local p = player:getpos()
p.y = p.y+1
local i = item:getpos()
local move = {x=(p.x-i.x)*15, y=(p.y-i.y)*15, z=(p.z-i.z)*15}
item:setacceleration(move)
end
end
end
end
end)

View File

@ -1,16 +0,0 @@
[Mod] Minecraft-Like Node drop
Forum Page: http://minetest.net/forum/viewtopic.php?pid=34817
Contributors:
LorenzoVulcan
INSTALL:
open item.lua, inside minetest.node_dig(),
replace:
digger:get_inventory():add_item("main", dropped_item)
with:
minetest.env:add_item(pos,dropped_item);

View File

@ -1,14 +1,15 @@
timber_nodenames={"default:jungletree", "default:papyrus", "default:cactus", "default:tree", "conifers:trunk"}
leaf_nodenames = {"default:leaves", "default:apple", "conifers:leaves"}
minetest.register_on_dignode(function(pos, node)
minetest.register_on_dignode(function(pos, node, player)
local i=1
while timber_nodenames[i]~=nil do
if node.name==timber_nodenames[i] then
np={x=pos.x, y=pos.y+1, z=pos.z}
while minetest.env:get_node(np).name==timber_nodenames[i] do
minetest.env:remove_node(np)
minetest.env:add_item(np, timber_nodenames[i])
local timber_item = minetest.env:add_item(np, timber_nodenames[i])
timber_item:get_luaentity().dug_by = player:get_player_name()
np={x=np.x, y=np.y+1, z=np.z}
local leafpos = minetest.env:find_node_near(np,3,leaf_nodenames)
@ -19,7 +20,8 @@ minetest.register_on_dignode(function(pos, node)
itemstacks = minetest.get_node_drops(name)
for _, itemname in ipairs(itemstacks) do
minetest.env:remove_node(leafpos)
minetest.env:add_item(leafpos, itemname)
local leaf_item = minetest.env:add_item(leafpos, itemname)
leaf_item:get_luaentity().dug_by = player:get_player_name()
end
leafpos = minetest.env:find_node_near(np,3,leaf_nodenames)

View File

@ -1,22 +0,0 @@
[Mod] Workers [0.0] [workers]
Forum Page: http://minetest.net/forum/viewtopic.php?id=2576
License: WTFPL for code & textures
Contributors:
LocaL_ALchemisT
Description:
Nodes which move on its own, and ready to serve you
Workers available:
1. Harvey The Harvester
Right click and enter node name (you can also enter alias)
Left click to activate
Left click again to take Harvey back, along with what he harvest

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 458 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 357 KiB

33
mods/workers/craft.lua Normal file
View File

@ -0,0 +1,33 @@
--[[
Workers Mod
By LocaL_ALchemisT (prof_awang@yahoo.com)
License: WTFPL
Version: 1.0
--]]
minetest.register_craft({
output = "workers:harvester",
recipe = {
{"default:dirt","default:chest","default:dirt"},
{"default:dirt","default:mese","default:dirt"},
{"default:dirt","default:dirt","default:dirt"}
}
})
minetest.register_craft({
output = "workers:gardener",
recipe = {
{"default:dirt","default:shovel_steel","default:dirt"},
{"default:dirt","default:mese","default:dirt"},
{"default:dirt","default:dirt","default:dirt"}
}
})
minetest.register_craft({
output = "workers:miner",
recipe = {
{"default:dirt","default:pick_steel","default:dirt"},
{"default:dirt","default:mese","default:dirt"},
{"default:dirt","default:dirt","default:dirt"}
}
})

85
mods/workers/fungsi.lua Normal file
View File

@ -0,0 +1,85 @@
--[[
Workers Mod
By LocaL_ALchemisT (prof_awang@yahoo.com)
License: WTFPL
Version: 1.0
--]]
worker_images = function(name)
return {name.."_body.png", name.."_body.png", name.."_left.png",name.."_right.png", name.."_back.png", name.."_front.png"}
end
dir = {
[0] = function(p) return {x=p.x,y=p.y,z=p.z-1} end, --back
[1] = function(p) return {x=p.x-1,y=p.y,z=p.z} end, --left
[2] = function(p) return {x=p.x,y=p.y,z=p.z+1} end, --front
[3] = function(p) return {x=p.x+1,y=p.y,z=p.z} end, --right
}
peek = function(p,name)
if minetest.env:get_node(p).name == name then return true end
end
faceTo = function(p,n,lim)
if peek(dir[n](p),"air") then return {pos = dir[n](p),face = n} end
n = n+1
lim = lim+1
if n > 3 then n = 0 end
if lim < 4 then return faceTo(p,n,lim)
else return nil end
end
anticlockwise = function(p,n)
local n2 = n-1
if n2 < 0 then n2 = 3 end
if peek(dir[n2](p),"air") then return {pos = dir[n2](p),face = n2}
else
if peek(dir[n](p),"air") then return {pos = dir[n](p),face = n2}
else return nil end
end
end
clockwise = function(p,n)
local n2 = n+1
if n2 > 3 then n2 = 0 end
if peek(dir[n2](p),"air") then return {pos = dir[n2](p),face = n2}
else
if peek(dir[n](p),"air") then return {pos = dir[n](p),face = n2}
else return nil end
end
end
shouldFall = function(p)
local np = {x=p.x,y=p.y-1,z=p.z}
if peek(np,"air") or peek(np,"default:water_source") or peek(np,"default:water_flowing") then return shouldFall(np)
else return p end
end
shouldFall_miner = function(p)
local np = {x=p.x,y=p.y-1,z=p.z}
if peek(np,"air") then
local np2 = {x=np.x-1,y=np.y,z=np.z}
if peek(np2,"air") then minetest.env:add_node(np2,{name="default:ladder",param2=3}) end
return shouldFall_miner(np)
elseif peek(np,"default:water_source") or peek(np,"default:water_flowing") then return shouldFall(np)
else return p end
end
get_ore = function(node)
local drops = minetest.get_node_drops(node,"default:pick_mese")
local _, dropped_item
for _, dropped_item in ipairs(drops) do
return dropped_item
end
end
defend = function(player,master,worker)
minetest.chat_send_player(player:get_player_name(), worker..": You are not "..master.."!")
player:set_hp(player:get_hp()-6)
minetest.chat_send_player(master, worker..": Master, "..player:get_player_name().." punched me!")
end
speak = function(player,text)
minetest.chat_send_player(player,text)
print(text)
end

View File

@ -2,15 +2,18 @@
Workers Mod
By LocaL_ALchemisT (prof_awang@yahoo.com)
License: WTFPL
Version: 0.0
Version: 1.0
--]]
-- NODES
dofile(minetest.get_modpath("workers").."/fungsi.lua")
dofile(minetest.get_modpath("workers").."/craft.lua")
local STAT_LIM = 5
-- HARVEY THE HARVESTER
minetest.register_node("workers:harvester", {
description = "Harvey The Harvester",
tile_images = {"harvey_body.png", "harvey_body.png", "harvey_left.png",
"harvey_right.png", "harvey_back.png", "harvey_front.png"},
tile_images = worker_images("harvey"),
paramtype2 = "facedir",
groups = {oddly_breakable_by_hand=2,flammable=1},
legacy_facedir_simple = true,
@ -30,7 +33,12 @@ minetest.register_node("workers:harvester", {
end,
on_receive_fields = function(pos, formname, fields, player)
local meta = minetest.env:get_meta(pos)
local master = meta:get_string("master")
local name = player:get_player_name()
if name ~= master then
defend(player,master,"Harvey")
return
end
fields.text = fields.text or ""
local itemstack = ItemStack(fields.text)
print(itemstack:to_string())
@ -48,76 +56,29 @@ minetest.register_node("workers:harvester", {
on_punch = function(pos, node, player)
local meta = minetest.env:get_meta(pos)
local master = meta:get_string("master")
if player:get_player_name() ~= master then
defend(player,master,"Harvey")
return
end
if meta:get_int("status") == 0 then return end
if meta:get_int("start_work") == 0 then --if the harvester hasn't moved yet
if player:get_player_name() == master then
meta:set_int("start_work",1)
minetest.chat_send_player(master, "Harvey: I will go now, Master.")
else
minetest.chat_send_player(player:get_player_name(), "Harvey: You are not "..master.."!")
player:set_hp(player:get_hp()-4)
minetest.chat_send_player(master, "Harvey: Master, "..player:get_player_name().." punched me!")
end
elseif meta:get_int("start_work") == 1 then --if the harvester has moved
if player:get_player_name() == master then
player:get_inventory():add_item("main", "workers:harvester")
print(meta:get_string("material")..": "..meta:get_int("quantity"))
if meta:get_int("quantity") > 0 then
player:get_inventory():add_item("main", "\""..meta:get_string("material").."\" "..meta:get_int("quantity"))
minetest.chat_send_player(master, "Harvey: I have collected "..meta:get_int("quantity").." "..meta:get_string("material")..", Master.")
end
minetest.chat_send_player(master, "Harvey: Pleasure to work for you, Master.")
minetest.env:remove_node(pos)
else
minetest.chat_send_player(player:get_player_name(), "Harvey: You are not "..master.."!")
player:set_hp(player:get_hp()-6)
minetest.chat_send_player(master, "Harvey: Master, "..player:get_player_name().." punched me!")
if meta:get_int("start_work") == 0 then --if Harvey hasn't moved yet
meta:set_int("start_work",1)
minetest.chat_send_player(master, "Harvey: I will go now, Master.")
else --if Harvey has moved
player:get_inventory():add_item("main", "workers:harvester")
print(meta:get_string("material")..": "..meta:get_int("quantity"))
if meta:get_int("quantity") > 0 then
player:get_inventory():add_item("main", "\""..meta:get_string("material").."\" "..meta:get_int("quantity"))
minetest.chat_send_player(master, "Harvey: I have collected "..meta:get_int("quantity").." "..meta:get_string("material")..", Master.")
end
minetest.chat_send_player(master, "Harvey: Pleasure to work for you, Master.")
minetest.env:remove_node(pos)
end
print (meta:get_int("start_work"))
end,
})
-- ACTIONS
local dir = {
[0] = function(p) return {x=p.x,y=p.y,z=p.z-1} end, --back
[1] = function(p) return {x=p.x-1,y=p.y,z=p.z} end, --left
[2] = function(p) return {x=p.x,y=p.y,z=p.z+1} end, --front
[3] = function(p) return {x=p.x+1,y=p.y,z=p.z} end, --right
}
local peek = function(p,name)
if minetest.env:get_node(p).name == name then return true end
end
faceTo = function(p,n,lim)
if peek(dir[n](p),"air") then return {pos = dir[n](p),face = n} end
n = n+1
lim = lim+1
if n > 3 then n = 0 end
if lim < 4 then return faceTo(p,n,lim)
else return nil end
end
shouldFall = function(p)
local np = {x=p.x,y=p.y-1,z=p.z}
if peek(np,"air") or peek(np,"default:water_source") or peek(np,"default:water_flowing") then return shouldFall(np)
else return p end
end
local meta_copy = function(m0,m1)
m1:set_string("infotext",m0:get_string("infotext"))
m1:set_string("text",m0:get_string("text"))
m1:set_string("master",m0:get_string("master"))
m1:set_string("material",m0:get_string("material"))
m1:set_int("quantity",m0:get_int("quantity"))
m1:set_int("status",m0:get_int("status"))
m1:set_int("start_work",m0:get_int("start_work"))
m1:set_int("previousdir",m0:get_int("previousdir"))
end
minetest.register_abm({
nodenames = {"workers:harvester"},
interval = 2,
@ -135,7 +96,7 @@ minetest.register_abm({
meta:set_int("quantity",meta:get_int("quantity")+1)
if hasMaterial == false then hasMaterial = true end
if meta:get_int("status") == 1 then
minetest.chat_send_player(meta:get_string("master"), "Harvey: I am at "..minetest.pos_to_string(p)..", Master")
speak(meta:get_string("master"), "Harvey: I am at "..minetest.pos_to_string(p)..", Master")
meta:set_int("status",2)
end
end
@ -150,38 +111,300 @@ minetest.register_abm({
meta:set_int("previousdir",where.face)
minetest.env:add_node(np,{name="workers:harvester",param2=where.face})
local meta2 = minetest.env:get_meta(np)
meta_copy(meta,meta2)
meta2:from_table(meta:to_table())
minetest.env:remove_node(p)
if meta2:get_int("status") == 1 then
minetest.chat_send_player(meta:get_string("master"), "Harvey: I am at "..minetest.pos_to_string(p)..", Master")
if meta2:get_int("status") == STAT_LIM then
speak(meta:get_string("master"), "Harvey: I am at "..minetest.pos_to_string(p)..", Master")
end
else
if meta:get_int("status") == 1 then
minetest.chat_send_player(meta:get_string("master"), "Harvey: Sorry Master, I cannot move. I am at "..minetest.pos_to_string(p))
if meta:get_int("status") == STAT_LIM then
speak(meta:get_string("master"), "Harvey: Sorry Master, I cannot move. I am at "..minetest.pos_to_string(p))
end
end
if meta:get_int("status") == 1 then meta:set_int("status",2) end
else print(meta:get_int("quantity").." "..meta:get_string("material").." gathered.") end
if meta:get_int("status") == 5 then meta:set_int("status",1)
if meta:get_int("status") == STAT_LIM then meta:set_int("status",1)
else meta:set_int("status",meta:get_int("status")+1) end
end
end,
})
-- RECIPES
-- MORDEC THE MINER
minetest.register_craft({
output = "workers:harvester",
recipe = {
{"default:dirt","default:chest","default:dirt"},
{"default:dirt","default:mese","default:dirt"},
{"default:dirt","default:dirt","default:dirt"}
}
minetest.register_node("workers:miner", {
description = "Mordec The Miner",
tile_images = worker_images("mordec"),
paramtype = "light",
light_source = 13,
paramtype2 = "facedir",
groups = {oddly_breakable_by_hand=2,flammable=1},
legacy_facedir_simple = true,
after_place_node = function(pos,player)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
"invsize[8,7;]"..
"list[current_player;main;0,3;8,4;]"..
"list[current_name;wood;0,0;1,1;]"..
"image[0,1;1,1;default_wood.png]"..
"list[current_name;ores;2,0;6,2;]")
local inv = meta:get_inventory()
inv:set_size("wood", 1)
inv:set_size("ores", 12)
meta:set_string("infotext", "Give me wood and i'll start digging, Master")
meta:set_string("master",player:get_player_name() or "my Master")
meta:set_int("status",0)
meta:set_int("start_work",0)
minetest.chat_send_player(player:get_player_name(), "Mordec: *bzzt* Hello, Master.")
end,
on_punch = function(pos, node, player)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local master = meta:get_string("master")
if player:get_player_name() ~= master then
defend(player,master,"Mordec")
return
end
if inv:get_stack("wood",1):to_table() == nil then return
elseif inv:get_stack("wood",1):to_table().name ~= "default:wood" then return end
if meta:get_int("start_work") == 0 then --if Mordec hasn't moved yet
meta:set_int("start_work",1)
minetest.chat_send_player(master, "Mordec: I will go now, Master.")
else --if Mordec has moved
meta:set_int("status",0)
meta:set_int("start_work",0)
end
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos)
local master = meta:get_string("master")
local inv = meta:get_inventory()
if not (inv:is_empty("wood") and inv:is_empty("ores")) then
minetest.chat_send_player(master, "Mordec: *error* I cannot leave yet, Master. There are items in my inventory.")
return false
end
minetest.chat_send_player(master, "Mordec: Pleasure to work for you, Master. *shutdown*")
return true
end,
})
minetest.register_abm({
nodenames = {"workers:miner"},
interval = 2,
chance = 1,
action = function(p, node, _, _)
local meta = minetest.env:get_meta(p)
local inv = meta:get_inventory()
if meta:get_int("start_work") == 0 then return end
if inv:get_stack("wood",1):to_table() == nil then
meta:set_int("status",0)
meta:set_int("start_work",0)
speak(meta:get_string("master"), "Mordec: I am at "..minetest.pos_to_string(p)..", Master. I am out of wood.")
return
end
local isFull = true
for i = 1,12 do
local orestack = inv:get_stack("ores",i)
if orestack:get_free_space() > 0 then isFull = false end
end
if isFull == true then
meta:set_int("start_work",0)
speak(meta:get_string("master"), "Mordec: I am at "..minetest.pos_to_string(p)..", Master. My inventory is full.")
return
end
local orelist = inv:get_list("ores")
for x = -1,1 do
for y = -1,0 do
for z = -1,1 do
local pp = {x=p.x+x,y=p.y+y,z=p.z+z}
if minetest.env:get_node(pp).name ~= "workers:miner"
and minetest.env:get_node(pp).name ~= "default:ladder"
and minetest.env:get_node(pp).name ~= "air"
and minetest.env:get_node(pp).name ~= "default:water_source"
and minetest.env:get_node(pp).name ~= "default:water_flowing"
and minetest.env:get_node(pp).name ~= "default:lava_source"
and minetest.env:get_node(pp).name ~= "default:lava_flowing" then
local ore = get_ore(minetest.env:get_node(pp).name)
if ore ~= nil and ore ~= "air" then inv:add_item("ores",ore) end
minetest.env:remove_node(pp)
end
end
end
end
local np = shouldFall_miner(p)
minetest.env:add_node(np,{name="workers:miner",param2=minetest.env:get_node(p).param2})
local meta2 = minetest.env:get_meta(np)
meta2:from_table(meta:to_table())
meta2:get_inventory():remove_item("wood",'"default:wood" 1')
minetest.env:remove_node(p)
if meta2:get_int("status") == 0 then minetest.env:add_node(p,{name="default:torch"}) end
if meta2:get_int("status") == STAT_LIM then
speak(meta2:get_string("master"), "Mordec: I am at "..minetest.pos_to_string(p)..", Master")
end
if meta2:get_int("status") == STAT_LIM then meta2:set_int("status",0)
else meta2:set_int("status",meta2:get_int("status")+1) end
end,
})
-- GARREN THE GARDENER
minetest.register_node("workers:gardener", {
description = "Garren The Gardener",
tile_images = worker_images("garren"),
paramtype2 = "facedir",
groups = {oddly_breakable_by_hand=2,flammable=1},
legacy_facedir_simple = true,
after_place_node = function(pos,player)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
"invsize[8,6;]"..
"list[current_player;main;0,2;8,4;]"..
"list[current_name;plant;2,0;1,1;]"..
"list[current_name;sapling;5,0;1,1;]"..
"image[6,0;1,1;default_sapling.png]")
local inv = meta:get_inventory()
inv:set_size("plant", 1)
inv:set_size("sapling", 1)
meta:set_string("infotext", "Can I have a plant sample and some saplings, Master?")
meta:set_string("master",player:get_player_name() or "my Master")
meta:set_int("status",0)
meta:set_int("start_work",0)
if minetest.env:get_node(pos).param2 < 2 then meta:set_int("previousdir",(minetest.env:get_node(pos).param2+2))
else meta:set_int("previousdir",(minetest.env:get_node(pos).param2-2)) end
meta:set_int("clockwise",0)
minetest.chat_send_player(player:get_player_name(), "Garren: Hello, Master.")
end,
on_punch = function(pos, node, player)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local master = meta:get_string("master")
if player:get_player_name() ~= master then
defend(player,master,"Garren")
return
end
if inv:get_stack("sapling",1):to_table() == nil then return
elseif inv:get_stack("sapling",1):to_table().name ~= "default:sapling" then return end
if meta:get_int("start_work") == 0 then --if Garren hasn't moved yet
meta:set_int("start_work",1)
minetest.chat_send_player(master, "Garren: I will go now, Master.")
else --if Garren has moved
meta:set_int("status",0)
meta:set_int("start_work",0)
end
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos)
local master = meta:get_string("master")
local inv = meta:get_inventory()
if not (inv:is_empty("plant") and inv:is_empty("sapling")) then
minetest.chat_send_player(master, "Garren: I cannot leave yet, Master. There are items in my inventory.")
return false
end
minetest.chat_send_player(master, "Garren: Pleasure to work for you, Master.")
return true
end,
})
minetest.register_abm({
nodenames = {"workers:gardener"},
interval = 2,
chance = 1,
action = function(p, node, _, _)
local meta = minetest.env:get_meta(p)
local inv = meta:get_inventory()
local plant = inv:get_stack("plant",1):to_table()
local sapling = inv:get_stack("sapling",1):to_table()
if meta:get_int("start_work") == 0 then return end
if sapling == nil then
meta:set_int("status",0)
meta:set_int("start_work",0)
speak(meta:get_string("master"), "Garren: I am at "..minetest.pos_to_string(p)..", Master. I am out of sapling.")
return
end
local where = nil
if meta:get_int("clockwise") == 0 then
where = anticlockwise(p,meta:get_int("previousdir"))
if where == nil then
where = clockwise(p,meta:get_int("previousdir"))
meta:set_int("clockwise",1)
end
elseif meta:get_int("clockwise") == 1 then
where = clockwise(p,meta:get_int("previousdir"))
if where == nil then
where = clockwise(p,meta:get_int("previousdir"))
meta:set_int("clockwise",0)
end
end
if where == nil then where = faceTo(p,meta:get_int("previousdir"),0) end
if where ~= nil then
local np = shouldFall(where.pos)
meta:set_int("previousdir",where.face)
minetest.env:add_node(np,{name="workers:gardener",param2=where.face})
local meta2 = minetest.env:get_meta(np)
meta2:from_table(meta:to_table())
minetest.env:remove_node(p)
local inv2 = meta2:get_inventory()
if plant.name == "default:jungletree" and sapling.count >= 9 then
for h = 0,3 do minetest.env:add_node({x = p.x,y = p.y+h,z = p.z},{name=plant.name}) end
for x = -1,1 do
for y = 2,4 do
for z = -1,1 do
if minetest.env:get_node({x = p.x+x,y = p.y+y,z = p.z+z}).name == "air" then
minetest.env:add_node({x = p.x+x,y = p.y+y,z = p.z+z},{name="default:leaves"})
end
end
end
end
inv2:remove_item("sapling",'"default:sapling" 9')
elseif (plant.name == "default:cactus" or plant.name == "default:papyrus") and sapling.count >= 3 then
for h = 0,2 do minetest.env:add_node({x = p.x,y = p.y+h,z = p.z},{name=plant.name}) end
inv2:remove_item("sapling",'"default:sapling" 3')
elseif (plant.name == "default:junglegrass" or plant.name == "default:dry_shrub") then
minetest.env:add_node(p,{name=plant.name})
inv2:remove_item("sapling","default:sapling")
else
minetest.env:add_node(p,{name="default:sapling"})
inv2:remove_item("sapling","default:sapling")
end
if meta2:get_int("status") == STAT_LIM then
speak(meta:get_string("master"), "Garren: I am at "..minetest.pos_to_string(p)..", Master")
end
else
if meta:get_int("status") == STAT_LIM then
speak(meta:get_string("master"), "Garren: Sorry Master, I cannot move. I am at "..minetest.pos_to_string(p))
end
end
if meta:get_int("status") == STAT_LIM then meta:set_int("status",0)
else meta:set_int("status",meta:get_int("status")+1) end
end,
})
-- ALIASES
minetest.register_alias("harvey","workers:harvester")
minetest.register_alias("harvester","workers:harvester")
minetest.register_alias("harvester","workers:harvester")
minetest.register_alias("garren","workers:gardener")
minetest.register_alias("gardener","workers:gardener")
minetest.register_alias("mordec","workers:miner")
minetest.register_alias("miner","workers:miner")

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B