Add farming and buckets

and crops
This commit is contained in:
oilboi 2020-02-22 15:09:02 -05:00
parent af85ddccca
commit 210e3cdc10
30 changed files with 373 additions and 10 deletions

285
mods/farming/init.lua Normal file
View File

@ -0,0 +1,285 @@
--Quick definition of hoes
local material = {"wood","stone","iron","gold","diamond"}
local function till_soil(pos)
local is_dirt = minetest.get_node_group(minetest.get_node(pos).name, "dirt") > 0
local is_farmland = minetest.get_node_group(minetest.get_node(pos).name, "farmland") > 0
if is_dirt and not is_farmland then
minetest.sound_play("dirt",{pos=pos})
minetest.set_node(pos,{name="farming:farmland_dry"})
return(true)
end
end
for level,material in pairs(material) do
local wear = 5000-(950*level)
print(wear)
minetest.register_tool("farming:"..material.."hoe", {
description = material:gsub("^%l", string.upper).." Hoe",
inventory_image = material.."hoe.png",
tool_capabilities = {
--full_punch_interval = 1.2,
--max_drop_level=0,
groupcaps={dirt = {times={[4]=4-level/4,[3]=3.5-level/4,[2]=3.0-level/4,[1]=2.8-level/4}, uses=(level/2)*3, maxlevel=level},},
damage_groups = {fleshy=1},
},
sound = {breaks = {name="tool_break",gain=0.4}}, -- change this
groups = {flammable = 2, tool=1 },
on_place = function(itemstack, placer, pointed_thing)
local tilled = till_soil(pointed_thing.under)
if tilled == true then itemstack:add_wear(wear) end
local damage = itemstack:get_wear()
if damage <= 0 then
minetest.sound_play("tool_break",{object=placer})
end
return(itemstack)
end,
})
minetest.register_craft({
output = "farming:"..material.."hoe",
recipe = {
{"","main:"..material, "main:"..material},
{"","main:stick", ""},
{"", "main:stick", ""}
}
})
minetest.register_craft({
output = "farming:"..material.."hoe",
recipe = {
{"main:"..material,"main:"..material, ""},
{"","main:stick", ""},
{"", "main:stick", ""}
}
})
end
local farmland = {"wet","dry"}
for level,dryness in pairs(farmland) do
local coloring = 160/level
minetest.register_node("farming:farmland_"..dryness,{
description = "Farmland",
paramtype = "light",
drawtype = "nodebox",
sounds = main.dirtSound(),
--paramtype2 = "wallmounted",
node_box = {
type = "fixed",
--{xmin, ymin, zmin, xmax, ymax, zmax}
fixed = {-0.5, -0.5, -0.5, 0.5, 6/16, 0.5},
},
wetness = math.abs(level-2),
collision_box = {
type = "fixed",
--{xmin, ymin, zmin, xmax, ymax, zmax}
fixed = {-0.5, -0.5, -0.5, 0.5, 6/16, 0.5},
},
tiles = {"dirt.png^farmland.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring},
groups = {dirt = 1, soft = 1, shovel = 1, hand = 1, soil=1,farmland=1},
drop="main:dirt",
})
end
--drying and wetting abm for farmland
minetest.register_abm({
label = "Farmland Wet",
nodenames = {"farming:farmland_dry"},
neighbors = {"air","group:crop"},
interval = 3,
chance = 150,
action = function(pos)
local found = minetest.find_node_near(pos, 3, {"main:water","main:waterflow"})
if found then
minetest.set_node(pos,{name="farming:farmland_wet"})
else
minetest.set_node(pos,{name="main:dirt"})
end
end,
})
minetest.register_abm({
label = "Farmland dry",
nodenames = {"farming:farmland_wet"},
neighbors = {"air"},
interval = 5,
chance = 500,
action = function(pos)
local found = minetest.find_node_near(pos, 3, {"main:water","main:waterflow"})
if not found then
minetest.set_node(pos,{name="farming:farmland_dry"})
end
end,
})
minetest.register_node("farming:grass", {
description = "Tall Grass",
drawtype = "plantlike",
waving = 1,
walkable = false,
climbable = false,
paramtype = "light",
is_ground_content = false,
tiles = {"tallgrass.png"},
paramtype2 = "degrotate",
buildable_to = true,
groups = {leaves = 1, plant = 1, axe = 1, hand = 0,dig_immediate=1,attached_node=1},
sounds = main.grassSound(),
selection_box = {
type = "fixed",
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 4 / 16, 4 / 16}
},
drop = {
max_items = 1,
items= {
{
-- Only drop if using a tool whose name is identical to one
-- of these.
rarity = 10,
items = {"farming:seeds"},
-- Whether all items in the dropped item list inherit the
-- hardware coloring palette color from the dug node.
-- Default is 'false'.
--inherit_color = true,
},
},
},
})
--wheat definitions
local wheat_max = 7
minetest.register_abm({
label = "crops grow",
nodenames = {"group:crops"},
neighbors = {"group:farmland"},
interval = 3,
chance = 150,
action = function(pos)
local node_under = minetest.get_node(vector.new(pos.x,pos.y-1,pos.z)).name
local wetness = minetest.registered_nodes[node_under].wetness
if wetness == 0 or not wetness then
return
end
local node = minetest.get_node(pos).name
local stage = minetest.registered_nodes[node].grow_stage
if stage < wheat_max then
minetest.set_node(pos,{name="farming:wheat_"..stage+1})
end
end,
})
for i = 0,wheat_max do
local drop = ""
if i == wheat_max then drop = "farming:wheat" end
minetest.register_node("farming:wheat_"..i, {
description = "Wheat Stage "..i,
drawtype = "plantlike",
waving = 1,
walkable = false,
climbable = false,
paramtype = "light",
is_ground_content = false,
tiles = {"wheat_stage_"..i..".png"},
paramtype2 = "degrotate",
buildable_to = true,
grow_stage = i,
groups = {leaves = 1, plant = 1, axe = 1, hand = 0,dig_immediate=1,attached_node=1,crops=1},
sounds = main.grassSound(),
selection_box = {
type = "fixed",
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 4 / 16, 4 / 16}
},
drop = drop,
})
end
minetest.register_craftitem("farming:seeds", {
description = "Seeds",
inventory_image = "seeds.png",
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
local pb = pointed_thing.above
if minetest.get_node_group(minetest.get_node(vector.new(pb.x,pb.y-1,pb.z)).name, "farmland") == 0 or minetest.get_node(pointed_thing.above).name ~= "air" then
return itemstack
end
local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
local fakestack = itemstack
local retval = false
retval = fakestack:set_name("farming:wheat_0")
if not retval then
return itemstack
end
itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
itemstack:set_name("farming:seeds")
if retval then
minetest.sound_play("leaves", {pos=pointed_thing.above, gain = 1.0})
end
return itemstack
end
})
minetest.register_decoration({
deco_type = "simple",
place_on = "main:grass",
sidelen = 16,
fill_ratio = 0.5,
--biomes = {"grassland"},
decoration = "farming:grass",
height = 1,
})
minetest.register_craftitem("farming:wheat", {
description = "Wheat",
inventory_image = "wheat_harvested.png",
})
minetest.register_craftitem("farming:bread", {
description = "Bread",
inventory_image = "bread.png",
health = 3,
})
minetest.register_craftitem("farming:toast", {
description = "Toast",
inventory_image = "bread.png^[colorize:black:100",
health = 5,
})
minetest.register_craft({
output = "farming:bread",
recipe = {
{"farming:wheat", "farming:wheat", "farming:wheat"}
}
})
minetest.register_craft({
type = "cooking",
output = "farming:toast",
recipe = "farming:bread",
cooktime = 3,
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

View File

@ -15,6 +15,7 @@ minetest.register_item(":", {
wood = {times={[4]=11.5,[3]=8.5,[2]=6.70,[1]=5.5}, uses=0, maxlevel=1},
leaves = {times={[4]=4.5,[3]=3.2,[2]=2.20,[1]=1.2}, uses=0, maxlevel=0},
instant = {times={[1]=0.1,},uses=0,maxlevel=1},
dig_immediate = {times={[1]=0,},uses=0,maxlevel=1},
},
damage_groups = {fleshy=1},
}

31
mods/main/bucket.lua Normal file
View File

@ -0,0 +1,31 @@
-- Item definitions
minetest.register_craftitem("main:bucket", {
description = "Bucket",
inventory_image = "bucket.png",
--wield_image = "bucket.png",
liquids_pointable = true,
on_place = function(itemstack, placer, pointed_thing)
--set it to water
if minetest.get_node(pointed_thing.under).name == "main:water" then
itemstack:replace(ItemStack("main:bucket_water"))
minetest.remove_node(pointed_thing.under)
return(itemstack)
end
end
})
minetest.register_craftitem("main:bucket_water", {
description = "Bucket with Water",
inventory_image = "bucket_water.png",
--wield_image = "bucket.png",
liquids_pointable = true,
on_place = function(itemstack, placer, pointed_thing)
--set it to water
if minetest.get_node(pointed_thing.above).name == "air" then
itemstack:replace(ItemStack("main:bucket"))
minetest.set_node(pointed_thing.above,{name="main:water"})
return(itemstack)
end
end
})

View File

@ -4,7 +4,7 @@ minetest.register_abm({
nodenames = {"main:dirt"},
neighbors = {"main:grass"},
interval = 10,
chance = 2600,
chance = 2000,
action = function(pos)
local light = minetest.get_node_light(pos, nil)
--print(light)

View File

@ -16,4 +16,5 @@ dofile(path.."/tools.lua")
dofile(path.."/settings.lua")
dofile(path.."/craft_recipes.lua")
dofile(path.."/falling.lua")
dofile(path.."/bucket.lua")

View File

@ -49,7 +49,7 @@ minetest.register_node("main:grass", {
minetest.register_node("main:sand", {
description = "Sand",
tiles = {"sand.png"},
groups = {dirt = 1, sand = 1, soft = 1, shovel = 1, hand = 1, falling_node = 1},
groups = {sand = 1, soft = 1, shovel = 1, hand = 1, falling_node = 1},
sounds = main.sandSound(),
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

View File

@ -9,7 +9,10 @@ for level,material in pairs(material) do
--print(id,tool,level,material)
local groupcaps
if group[id] == "dirt" then
groupcaps2={dirt = {times={[4]=4-level/2,[3]=3.5-level/2,[2]=3.0-level/2,[1]=2.8-level/2}, uses=(level/2)*5, maxlevel=level},}
groupcaps2={
dirt = {times={[4]=4-level/2,[3]=3.5-level/2,[2]=3.0-level/2,[1]=2.8-level/2}, uses=(level/2)*5, maxlevel=level},
sand = {times={[4]=4-level/2,[3]=3.5-level/2,[2]=3.0-level/2,[1]=2.8-level/2}, uses=(level/2)*5, maxlevel=level},
}
end
if group[id] == "wood" then
groupcaps2={wood = {times={[4]=4-level/2,[3]=3.5-level/2,[2]=3.0-level/2,[1]=2.8-level/2}, uses=(level/2)*5, maxlevel=level},}

View File

@ -394,6 +394,7 @@ minetest.register_entity("minecart:minecart", {
vel = vector.multiply(vel,distance)
local acceleration = vector.new(vel.x-currentvel.x,0,vel.z-currentvel.z)
--note : set a maximum velocity that can be added to the cart to limit extreme glitches
if self.axis == "x" then
self.object:add_velocity(vector.new(acceleration.x,0,0))
@ -403,8 +404,8 @@ minetest.register_entity("minecart:minecart", {
self.object:add_velocity(acceleration)
end
acceleration = vector.multiply(acceleration, -0.5)
object:add_player_velocity(acceleration)
--acceleration = vector.multiply(acceleration, -0.5)
--object:add_player_velocity(acceleration)
end
end
end

View File

@ -188,6 +188,21 @@ minetest.register_node("tnt:tnt", {
end,
})
minetest.register_node("tnt:uranium_tnt", {
description = "Cobblestone",
tiles = {"tnt_top.png^[colorize:green:100", "tnt_bottom.png^[colorize:green:100",
"tnt_side.png^[colorize:green:100", "tnt_side.png^[colorize:green:100",
"tnt_side.png^[colorize:green:100", "tnt_side.png^[colorize:green:100"},
groups = {stone = 2, hard = 1, pickaxe = 2, hand = 4},
sounds = main.stoneSound(),
on_punch = function(pos, node, puncher, pointed_thing)
local obj = minetest.add_entity(pos,"tnt:tnt")
local range = 145
obj:get_luaentity().range = range
minetest.remove_node(pos)
end,
})
minetest.register_node("tnt:uh_oh", {
description = "Cobblestone",
tiles = {"tnt_top.png", "tnt_bottom.png",

View File

@ -31,10 +31,29 @@ ALPHA STATE CHANGELOG
--rewrite the item collection better
(not finished) redstone - make nodes drop multiple items individually
--make item collection move with the player's speed
--made saplings
--make grass spread
buckets
saplings
make entities push against players
crafting bench
make torches abm that checks if player in area
make furnace abm that checks if player in area
farming -
- tall grass spawns on regular grass
- drops seeds
- add hoe
- add fertilizer (pig drops bone randomly)
- fertilizer is made out of bone -
- fertilizer can make tall grass grow on regular grass
- bread - 3 bread in a row
- make sandwich with bread and cooked porkchop
- fertilizer used on saplings randomly make tree grow (make sapling growth a function)
fishing
bows
fix full inventory collection deletion bug
@ -50,10 +69,17 @@ add a function to set a velocity goal to entities and then implement it with all
^make a value if below then stop?
colored chat messages
check if everyone is in bed before going to next night
also lock player in bed until they get out or daytime
create a function to check if a node or group is below
- also lock player in bed until they get out or daytime
- create a function to check if a node or group is below
minecart car train? - off rail use
- automatic step height for off rail use
- make cars follow each other
- oil which spawns underground in pools
- powered minecart car (engine car)
- chest minecart car
- player controls engine car
make entities push against players
open bugs: