Updated Wells.

master
NathanSalapat 2015-04-26 12:44:26 -05:00
parent 950f812028
commit 4ef8edcd3f
8 changed files with 130 additions and 19 deletions

View File

@ -1,3 +1,6 @@
4-25-15:
Wells added, they require a hole in the ground three nodes deep to be placed on top. Just click on the inside of the hole, in the top node. They need to be placed in dirt. Right click on a well top and put in a bucket or canteen to get some water. The bucket will act exactly as any other bucket with water, the canteen with water can be cooked to purify and then be drank. Drinking dirty water can result in a loss of health.
4-11-15:
Spigots are working!!! They can only be placed on tree trunks, and need a bucket to collect sap. Right now you just have the infotexts to give you statuses. Placing a bucket in the spigot will trigger a timer that will replace the empty bucket with a sap filled bucket. Cook the sap filled bucket to get sugar. Collection and cooking times will probably be tweaked yet. I want to add a graphic to the spigot that shows whether the bucket is placed and is empty or full, but I don't know if I can do that without creating three nodes. Updated the spigot model and texture.
Crafting recipe is

View File

@ -6,4 +6,5 @@ minetest.register_craftitem('survival:shell', {
minetest.register_craftitem('survival:bucket_sap', {
description = 'bucket with sap',
inventory_image = 'survival_bucket_sap.png',
stack_max = 1,
})

View File

@ -10,9 +10,9 @@ minetest.register_craftitem('survival:canteen_empty', {
on_use = function(itemstack, user, pointed_thing)
if string.find(minetest.get_node(pointed_thing.under).name, 'default:water_source')
then
local giving_back = 'survival:canteen_water_dirty',
else -- Do nothing
end,
local giving_back = 'survival:canteen_water_dirty'
end
end
})
--minetest.register_craft({
@ -26,13 +26,17 @@ minetest.register_craftitem('survival:canteen_water_clean', {
description = 'clean drinking water',
inventory_image = 'survival_canteen_water_clean.png',
stack_max = 1,
on_use = minetest.item_eat(1, 'default:wood'),
on_use = minetest.item_eat(1, 'survival:canteen_empty'),
})
minetest.register_craftitem('survival:canteen_water_dirty', {
description = 'dirty water',
inventory_image = 'survival_canteen_water_dirty.png',
stack_max = 1,
on_use = minetest.item_eat((math.random(-2, 1)), 'default:wood'),
on_use = function(pos, player, itemstack)
local hp_gain = math.random(-5,1)
local hp = player:get_hp()
player:set_hp(hp + hp_gain)
return 'survival:canteen_empty'
end
})

View File

@ -7,7 +7,11 @@ minetest.register_craftitem('survival:energy_bar', {
minetest.register_craftitem('survival:slug_raw', {
description = 'slug',
inventory_image = 'survival_slug_raw.png',
on_use = minetest.item_eat(-4)
on_use = function(pos, player)
local hp_gain = math.random(-4,1)
local hp = player:get_hp()
player:set_hp(hp + hp_gain)
end
})
minetest.register_craftitem('survival:slug_cooked', {
@ -91,5 +95,5 @@ minetest.register_craftitem('survival:mussel_cooked', {
minetest.register_craftitem('survival:sugar', {
description = 'sugar',
inventory_image = 'survival_sugar.png',
on_use = minetest.item_eat(.75)
on_use = minetest.item_eat(.1)
})

View File

@ -2,7 +2,7 @@
dofile(minetest.get_modpath('survival')..'/crafting.lua')
dofile(minetest.get_modpath('survival')..'/nodes.lua')
dofile(minetest.get_modpath('survival')..'/tools.lua')
--dofile(minetest.get_modpath('survival')..'/drinking.lua')-- working on this yet.
dofile(minetest.get_modpath('survival')..'/drinking.lua')
dofile(minetest.get_modpath('survival')..'/foods.lua')
dofile(minetest.get_modpath('survival')..'/abms.lua')
dofile(minetest.get_modpath('survival')..'/craftitem.lua')

107
nodes.lua
View File

@ -92,7 +92,6 @@ minetest.register_node('survival:spigot', {
fixed = {-.35, -.2, 0, .35, .5, .5}, -- Right, Bottom, Back, Left, Top, Front
},
on_construct = function(pos)
local timer = minetest.get_node_timer(pos)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
@ -133,6 +132,8 @@ minetest.register_node('survival:spigot', {
if listname == 'sap' then
if stack:get_name() == ('bucket:bucket_empty') then
return 1
else
return 0
end
end
end,
@ -292,6 +293,35 @@ minetest.register_node('survival:well_bottom', {
type = 'fixed',
fixed = {-0.6, -0.5, -0.6, 0.6, .3, .6}, -- Right, Bottom, Back, Left, Top, Front
},
after_place_node = function(pos, placer, itemstack)
local n = minetest.get_node(pos)
if not n or not n.param2 then
minetest.remove_node(pos)
return true
end
local dir = minetest.facedir_to_dir(n.param2)
local b1 = {x=pos.x, y=pos.y-1, z=pos.z}
local b2 = {x=pos.x, y=pos.y-2, z=pos.z}
local b3 = {x=pos.x-dir.x, y=pos.y, z=pos.z-dir.z}
local n1 = minetest.get_node_or_nil(b1)
local n2 = minetest.get_node_or_nil(b2)
local n3 = minetest.get_node_or_nil(b3)
local def = minetest.registered_items[n2.name] or nil
print (n1.name, n2.name)
if not n1 and n2 or not def.buildable_to then --not really sure if this is the best code, but it works.
minetest.remove_node(pos)
return true
end
if n3.name ~= 'default:dirt_with_grass' then
if n3.name ~= 'default:dirt' then
minetest.remove_node(pos)
return true
end
end
minetest.set_node(pos,{name = 'air'})
minetest.set_node({x=pos.x, y=pos.y+1, z=pos.z},{name = 'survival:well_bottom', param2=n.param2})
end,
})
minetest.register_node('survival:well_top', {
@ -312,12 +342,81 @@ minetest.register_node('survival:well_top', {
minetest.remove_node(pos)
return true
end
local dir = minetest.facedir_to_dir(n.param2)
local p = {x=pos.x, y=pos.y-1, z=pos.z}
local p2 = {x=pos.x, y=pos.y-2, z=pos.z}
local n2 = minetest.get_node_or_nil(p)
if n2.name ~= 'survival:well_bottom' then
local n3 = minetest.get_node_or_nil(p2)
print (n2.name)
print (n3.name)
if n3.name ~= 'air' or n2.name ~= 'survival:well_bottom' then
minetest.remove_node(pos)
return true
end
end,
})
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
inv:set_size('pail', 1)
meta:set_string("formspec",
"size[8,6]"..
"label[2,.5;You need something to gather water in.]" ..
"list[current_name;pail;1,.5;1,1]"..
"list[current_player;main;0,2;8,4;]")
meta:set_string("infotext", "Well")
end,
on_timer = function(pos, elapsed)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local timer = minetest.get_node_timer(pos)
if inv:contains_item('pail', 'bucket:bucket_empty') then --make sure the bucket is still there
inv:set_stack('pail', 1,'bucket:bucket_water')
timer:stop()
return
elseif inv:contains_item('pail', 'survival:canteen_empty') then --make sure the canteen is still there
inv:set_stack('pail', 1,'survival:canteen_water_dirty')
timer:stop()
return
end
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local timer = minetest.get_node_timer(pos)
if inv:contains_item('pail', 'bucket:bucket_empty') then
timer:start(7)
elseif inv:contains_item('pail', 'survival:canteen_empty') then
timer:start(6)
end
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
local chance = math.random(1,2)
if chance == 2 then
-- Let's change the formspec'
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
inv:set_size('pail', 0)
meta:set_string("formspec",
"size[8,6]"..
"label[2,.5;This well has dried up!]" ..
"list[current_player;main;0,2;8,4;]")
meta:set_string("infotext", "Dead Well")
-- Now let's fill the well with dirt, so it has to be dug again.
minetest.set_node({x=pos.x, y=pos.y-2, z=pos.z},{name = 'default:dirt'})
minetest.set_node({x=pos.x, y=pos.y-3, z=pos.z},{name = 'default:dirt'})
minetest.set_node({x=pos.x, y=pos.y-4, z=pos.z},{name = 'default:dirt'})
end
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname == 'pail' then
if stack:get_name() == ('bucket:bucket_empty') then
return 1
elseif stack:get_name() == ('survival:canteen_empty') then
return 1
else
return 0
end
end
end,
})

View File

@ -1,13 +1,13 @@
Hi, thanks for reading this.
This mod aims to add several survival type aspects.
This mod aims to add several survival type aspects, from new foods, to tools, and new mechanics.
Planned items include:
Machete X
Water Bottle
Thirst bar
Water Bottle x
Thirst bar ? there is another mod that has this, I may just build off that mod and support it.
Bugs/food X
sleeping bags
leafy beds
sleeping bags X
leafy beds X
barrels, like chests but barrel shapes X

View File

@ -8,7 +8,7 @@ minetest.register_tool('survival:machete_wood', {
groupcaps= { --how many times the tool can 'attack' nodes of a type.
crumbly = {times = {[1]=3.00, [2]=1.60, [3]=0.60}, uses=10, maxlevel=1}, --dirt like
choppy = {times = {[2]=3.00, [3]=1.60}, uses=10, maxlevel=1}, --woody
snappy = {times = {[2]=1.6, [3]=0.40}, uses=10, maxlevel=1}, --fleshy?
snappy = {times = {[2]=1.6, [3]=0.40}, uses=10, maxlevel=1},
},
damage_groups = {fleshy=2}, --damage delt to mobs and other players?
},