update to latest 4.13
@ -1,8 +1,8 @@
|
||||
Minetest mod "Beds"
|
||||
===================
|
||||
by BlockMen (c) 2014
|
||||
Minetest Game mod: beds
|
||||
=======================
|
||||
by BlockMen (c) 2014-2015
|
||||
|
||||
Version: 1.1
|
||||
Version: 1.1.1
|
||||
|
||||
About
|
||||
~~~~~
|
||||
@ -12,30 +12,15 @@ players are in bed too. If all players are sleeping the night gets skipped aswel
|
||||
if more than 50% of the players are lying in bed and use this option.
|
||||
|
||||
Another feature is a controled respawning. If you have slept in bed (not just lying in it) your respawn point
|
||||
is set to the beds location. If dying you will respawn there.
|
||||
|
||||
|
||||
|
||||
You can craft two types of beds:
|
||||
|
||||
|
||||
Simple shaped bed:
|
||||
|
||||
wool wool wool
|
||||
wood wood wood
|
||||
|
||||
Fancy shaped bed:
|
||||
|
||||
wool wool stick
|
||||
wood wood wood
|
||||
|
||||
Notice: You can use any color of wood or wool, mixing different is also possible.
|
||||
is set to the beds location and you will respawn there after death.
|
||||
You can disable the respawn at beds by setting "enable_bed_respawn = false" in minetest.conf
|
||||
You can also disable the night skip feature by setting "enable_bed_night_skip = false" in minetest.conf or by using
|
||||
the /set command ingame.
|
||||
|
||||
|
||||
License of source code, textures: WTFPL
|
||||
---------------------------------------
|
||||
(c) Copyright BlockMen (2014)
|
||||
|
||||
(c) Copyright BlockMen (2014-2015)
|
||||
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
|
110
mods/beds/api.lua
Normal file
@ -0,0 +1,110 @@
|
||||
function beds.register_bed(name, def)
|
||||
minetest.register_node(name .. "_bottom", {
|
||||
description = def.description,
|
||||
inventory_image = def.inventory_image,
|
||||
wield_image = def.wield_image,
|
||||
drawtype = "nodebox",
|
||||
tiles = def.tiles.bottom,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
stack_max = 1,
|
||||
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = def.nodebox.bottom,
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = def.selectionbox,
|
||||
},
|
||||
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
local n = minetest.get_node_or_nil(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 p = vector.add(pos, dir)
|
||||
local n2 = minetest.get_node_or_nil(p)
|
||||
local def = n2 and minetest.registered_items[n2.name]
|
||||
if not def or not def.buildable_to then
|
||||
minetest.remove_node(pos)
|
||||
return true
|
||||
end
|
||||
minetest.set_node(p, {name = n.name:gsub("%_bottom", "_top"), param2 = n.param2})
|
||||
return false
|
||||
end,
|
||||
|
||||
on_destruct = function(pos)
|
||||
local n = minetest.get_node_or_nil(pos)
|
||||
if not n then return end
|
||||
local dir = minetest.facedir_to_dir(n.param2)
|
||||
local p = vector.add(pos, dir)
|
||||
local n2 = minetest.get_node(p)
|
||||
if minetest.get_item_group(n2.name, "bed") == 2 and n.param2 == n2.param2 then
|
||||
minetest.remove_node(p)
|
||||
end
|
||||
end,
|
||||
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
beds.on_rightclick(pos, clicker)
|
||||
end,
|
||||
|
||||
on_rotate = function(pos, node, user, mode, new_param2)
|
||||
local dir = minetest.facedir_to_dir(node.param2)
|
||||
local p = vector.add(pos, dir)
|
||||
local node2 = minetest.get_node_or_nil(p)
|
||||
if not node2 or not minetest.get_item_group(node2.name, "bed") == 2 or
|
||||
not node.param2 == node2.param2 then
|
||||
return false
|
||||
end
|
||||
if minetest.is_protected(p, user:get_player_name()) then
|
||||
minetest.record_protection_violation(p, user:get_player_name())
|
||||
return false
|
||||
end
|
||||
if mode ~= screwdriver.ROTATE_FACE then
|
||||
return false
|
||||
end
|
||||
local newp = vector.add(pos, minetest.facedir_to_dir(new_param2))
|
||||
local node3 = minetest.get_node_or_nil(newp)
|
||||
local def = node3 and minetest.registered_nodes[node3.name]
|
||||
if not def or not def.buildable_to then
|
||||
return false
|
||||
end
|
||||
if minetest.is_protected(newp, user:get_player_name()) then
|
||||
minetest.record_protection_violation(newp, user:get_player_name())
|
||||
return false
|
||||
end
|
||||
node.param2 = new_param2
|
||||
minetest.swap_node(pos, node)
|
||||
minetest.remove_node(p)
|
||||
minetest.set_node(newp, {name = node.name:gsub("%_bottom", "_top"), param2 = new_param2})
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node(name .. "_top", {
|
||||
drawtype = "nodebox",
|
||||
tiles = def.tiles.top,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
pointable = false,
|
||||
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = def.nodebox.top,
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_alias(name, name .. "_bottom")
|
||||
|
||||
minetest.register_craft({
|
||||
output = name,
|
||||
recipe = def.recipe
|
||||
})
|
||||
end
|
90
mods/beds/beds.lua
Normal file
@ -0,0 +1,90 @@
|
||||
-- Fancy shaped bed
|
||||
|
||||
beds.register_bed("beds:fancy_bed", {
|
||||
description = "Fancy Bed",
|
||||
inventory_image = "beds_bed_fancy.png",
|
||||
wield_image = "beds_bed_fancy.png",
|
||||
tiles = {
|
||||
bottom = {
|
||||
"beds_bed_top1.png",
|
||||
"default_wood.png",
|
||||
"beds_bed_side1.png",
|
||||
"beds_bed_side1.png^[transformFX",
|
||||
"default_wood.png",
|
||||
"beds_bed_foot.png",
|
||||
},
|
||||
top = {
|
||||
"beds_bed_top2.png",
|
||||
"default_wood.png",
|
||||
"beds_bed_side2.png",
|
||||
"beds_bed_side2.png^[transformFX",
|
||||
"beds_bed_head.png",
|
||||
"default_wood.png",
|
||||
}
|
||||
},
|
||||
nodebox = {
|
||||
bottom = {
|
||||
{-0.5, -0.5, -0.5, -0.375, -0.065, -0.4375},
|
||||
{0.375, -0.5, -0.5, 0.5, -0.065, -0.4375},
|
||||
{-0.5, -0.375, -0.5, 0.5, -0.125, -0.4375},
|
||||
{-0.5, -0.375, -0.5, -0.4375, -0.125, 0.5},
|
||||
{0.4375, -0.375, -0.5, 0.5, -0.125, 0.5},
|
||||
{-0.4375, -0.3125, -0.4375, 0.4375, -0.0625, 0.5},
|
||||
},
|
||||
top = {
|
||||
{-0.5, -0.5, 0.4375, -0.375, 0.1875, 0.5},
|
||||
{0.375, -0.5, 0.4375, 0.5, 0.1875, 0.5},
|
||||
{-0.5, 0, 0.4375, 0.5, 0.125, 0.5},
|
||||
{-0.5, -0.375, 0.4375, 0.5, -0.125, 0.5},
|
||||
{-0.5, -0.375, -0.5, -0.4375, -0.125, 0.5},
|
||||
{0.4375, -0.375, -0.5, 0.5, -0.125, 0.5},
|
||||
{-0.4375, -0.3125, -0.5, 0.4375, -0.0625, 0.4375},
|
||||
}
|
||||
},
|
||||
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
|
||||
recipe = {
|
||||
{"", "", "group:stick"},
|
||||
{"wool:red", "wool:red", "wool:white"},
|
||||
{"group:wood", "group:wood", "group:wood"},
|
||||
},
|
||||
})
|
||||
|
||||
-- Simple shaped bed
|
||||
|
||||
beds.register_bed("beds:bed", {
|
||||
description = "Simple Bed",
|
||||
inventory_image = "beds_bed.png",
|
||||
wield_image = "beds_bed.png",
|
||||
tiles = {
|
||||
bottom = {
|
||||
"beds_bed_top_bottom.png^[transformR90",
|
||||
"default_wood.png",
|
||||
"beds_bed_side_bottom_r.png",
|
||||
"beds_bed_side_bottom_r.png^[transformfx",
|
||||
"beds_transparent.png",
|
||||
"beds_bed_side_bottom.png"
|
||||
},
|
||||
top = {
|
||||
"beds_bed_top_top.png^[transformR90",
|
||||
"default_wood.png",
|
||||
"beds_bed_side_top_r.png",
|
||||
"beds_bed_side_top_r.png^[transformfx",
|
||||
"beds_bed_side_top.png",
|
||||
"beds_transparent.png",
|
||||
}
|
||||
},
|
||||
nodebox = {
|
||||
bottom = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5},
|
||||
top = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5},
|
||||
},
|
||||
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
|
||||
recipe = {
|
||||
{"wool:red", "wool:red", "wool:white"},
|
||||
{"group:wood", "group:wood", "group:wood"}
|
||||
},
|
||||
})
|
||||
|
||||
-- Aliases for PilzAdam's beds mod
|
||||
|
||||
minetest.register_alias("beds:bed_bottom_red", "beds:bed_bottom")
|
||||
minetest.register_alias("beds:bed_top_red", "beds:bed_top")
|
@ -1,2 +1,2 @@
|
||||
default
|
||||
wool
|
||||
wool
|
||||
|
225
mods/beds/functions.lua
Normal file
@ -0,0 +1,225 @@
|
||||
local pi = math.pi
|
||||
local player_in_bed = 0
|
||||
local is_sp = minetest.is_singleplayer()
|
||||
local enable_respawn = minetest.setting_getbool("enable_bed_respawn")
|
||||
if enable_respawn == nil then
|
||||
enable_respawn = true
|
||||
end
|
||||
|
||||
-- Helper functions
|
||||
|
||||
local function get_look_yaw(pos)
|
||||
local n = minetest.get_node(pos)
|
||||
if n.param2 == 1 then
|
||||
return pi / 2, n.param2
|
||||
elseif n.param2 == 3 then
|
||||
return -pi / 2, n.param2
|
||||
elseif n.param2 == 0 then
|
||||
return pi, n.param2
|
||||
else
|
||||
return 0, n.param2
|
||||
end
|
||||
end
|
||||
|
||||
local function is_night_skip_enabled()
|
||||
local enable_night_skip = minetest.setting_getbool("enable_bed_night_skip")
|
||||
if enable_night_skip == nil then
|
||||
enable_night_skip = true
|
||||
end
|
||||
return enable_night_skip
|
||||
end
|
||||
|
||||
local function check_in_beds(players)
|
||||
local in_bed = beds.player
|
||||
if not players then
|
||||
players = minetest.get_connected_players()
|
||||
end
|
||||
|
||||
for n, player in ipairs(players) do
|
||||
local name = player:get_player_name()
|
||||
if not in_bed[name] then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
return #players > 0
|
||||
end
|
||||
|
||||
local function lay_down(player, pos, bed_pos, state, skip)
|
||||
local name = player:get_player_name()
|
||||
local hud_flags = player:hud_get_flags()
|
||||
|
||||
if not player or not name then
|
||||
return
|
||||
end
|
||||
|
||||
-- stand up
|
||||
if state ~= nil and not state then
|
||||
local p = beds.pos[name] or nil
|
||||
if beds.player[name] ~= nil then
|
||||
beds.player[name] = nil
|
||||
player_in_bed = player_in_bed - 1
|
||||
end
|
||||
-- skip here to prevent sending player specific changes (used for leaving players)
|
||||
if skip then
|
||||
return
|
||||
end
|
||||
if p then
|
||||
player:setpos(p)
|
||||
end
|
||||
|
||||
-- physics, eye_offset, etc
|
||||
player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
||||
player:set_look_yaw(math.random(1, 180) / 100)
|
||||
default.player_attached[name] = false
|
||||
player:set_physics_override(1, 1, 1)
|
||||
hud_flags.wielditem = true
|
||||
default.player_set_animation(player, "stand" , 30)
|
||||
|
||||
-- lay down
|
||||
else
|
||||
beds.player[name] = 1
|
||||
beds.pos[name] = pos
|
||||
player_in_bed = player_in_bed + 1
|
||||
|
||||
-- physics, eye_offset, etc
|
||||
player:set_eye_offset({x = 0, y = -13, z = 0}, {x = 0, y = 0, z = 0})
|
||||
local yaw, param2 = get_look_yaw(bed_pos)
|
||||
player:set_look_yaw(yaw)
|
||||
local dir = minetest.facedir_to_dir(param2)
|
||||
local p = {x = bed_pos.x + dir.x / 2, y = bed_pos.y, z = bed_pos.z + dir.z / 2}
|
||||
player:set_physics_override(0, 0, 0)
|
||||
player:setpos(p)
|
||||
default.player_attached[name] = true
|
||||
hud_flags.wielditem = false
|
||||
default.player_set_animation(player, "lay" , 0)
|
||||
end
|
||||
|
||||
player:hud_set_flags(hud_flags)
|
||||
end
|
||||
|
||||
local function update_formspecs(finished)
|
||||
local ges = #minetest.get_connected_players()
|
||||
local form_n = ""
|
||||
local is_majority = (ges / 2) < player_in_bed
|
||||
|
||||
if finished then
|
||||
form_n = beds.formspec .. "label[2.7,11; Good morning.]"
|
||||
else
|
||||
form_n = beds.formspec .. "label[2.2,11;" .. tostring(player_in_bed) ..
|
||||
" of " .. tostring(ges) .. " players are in bed]"
|
||||
if is_majority and is_night_skip_enabled() then
|
||||
form_n = form_n .. "button_exit[2,8;4,0.75;force;Force night skip]"
|
||||
end
|
||||
end
|
||||
|
||||
for name,_ in pairs(beds.player) do
|
||||
minetest.show_formspec(name, "beds_form", form_n)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Public functions
|
||||
|
||||
function beds.kick_players()
|
||||
for name, _ in pairs(beds.player) do
|
||||
local player = minetest.get_player_by_name(name)
|
||||
lay_down(player, nil, nil, false)
|
||||
end
|
||||
end
|
||||
|
||||
function beds.skip_night()
|
||||
minetest.set_timeofday(0.23)
|
||||
beds.set_spawns()
|
||||
end
|
||||
|
||||
function beds.on_rightclick(pos, player)
|
||||
local name = player:get_player_name()
|
||||
local ppos = player:getpos()
|
||||
local tod = minetest.get_timeofday()
|
||||
|
||||
if tod > 0.2 and tod < 0.805 then
|
||||
if beds.player[name] then
|
||||
lay_down(player, nil, nil, false)
|
||||
end
|
||||
minetest.chat_send_player(name, "You can only sleep at night.")
|
||||
return
|
||||
end
|
||||
|
||||
-- move to bed
|
||||
if not beds.player[name] then
|
||||
lay_down(player, ppos, pos)
|
||||
else
|
||||
lay_down(player, nil, nil, false)
|
||||
end
|
||||
|
||||
if not is_sp then
|
||||
update_formspecs(false)
|
||||
end
|
||||
|
||||
-- skip the night and let all players stand up
|
||||
if check_in_beds() then
|
||||
minetest.after(2, function()
|
||||
if not is_sp then
|
||||
update_formspecs(is_night_skip_enabled())
|
||||
end
|
||||
if is_night_skip_enabled() then
|
||||
beds.skip_night()
|
||||
beds.kick_players()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Callbacks
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
beds.read_spawns()
|
||||
end)
|
||||
|
||||
-- respawn player at bed if enabled and valid position is found
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
if not enable_respawn then
|
||||
return false
|
||||
end
|
||||
local name = player:get_player_name()
|
||||
local pos = beds.spawn[name] or nil
|
||||
if pos then
|
||||
player:setpos(pos)
|
||||
return true
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
lay_down(player, nil, nil, false, true)
|
||||
beds.player[name] = nil
|
||||
if check_in_beds() then
|
||||
minetest.after(2, function()
|
||||
update_formspecs(is_night_skip_enabled())
|
||||
if is_night_skip_enabled() then
|
||||
beds.skip_night()
|
||||
beds.kick_players()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= "beds_form" then
|
||||
return
|
||||
end
|
||||
if fields.quit or fields.leave then
|
||||
lay_down(player, nil, nil, false)
|
||||
update_formspecs(false)
|
||||
end
|
||||
|
||||
if fields.force then
|
||||
update_formspecs(is_night_skip_enabled())
|
||||
if is_night_skip_enabled() then
|
||||
beds.skip_night()
|
||||
beds.kick_players()
|
||||
end
|
||||
end
|
||||
end)
|
@ -1,229 +1,17 @@
|
||||
beds = {}
|
||||
--beds.player = {}
|
||||
--beds.pos = {}
|
||||
--beds.spawn = {}
|
||||
beds.player = {}
|
||||
beds.pos = {}
|
||||
beds.spawn = {}
|
||||
|
||||
beds.player_spawns = {} --allowed to save to file
|
||||
beds.player_pos = {} --primary used
|
||||
beds.formspec = "size[8,15;true]" ..
|
||||
"bgcolor[#080808BB; true]" ..
|
||||
"button_exit[2,12;4,0.75;leave;Leave Bed]"
|
||||
|
||||
beds.player_sleeping = {}
|
||||
beds.player_sleeping_count = 0
|
||||
local modpath = minetest.get_modpath("beds")
|
||||
|
||||
local is_sp = minetest.is_singleplayer() or false
|
||||
local form = "size[8,15;true]"..
|
||||
"bgcolor[#080808BB; true]"..
|
||||
"button_exit[2,12;4,0.75;leave;Leave Bed]"
|
||||
-- Load files
|
||||
|
||||
|
||||
-- help functions
|
||||
|
||||
local function get_look_yaw(pos)
|
||||
local n = minetest.get_node(pos)
|
||||
if n.param2 == 1 then
|
||||
return 7.9, n.param2
|
||||
elseif n.param2 == 3 then
|
||||
return 4.75, n.param2
|
||||
elseif n.param2 == 0 then
|
||||
return 3.15, n.param2
|
||||
else
|
||||
return 6.28, n.param2
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function check_in_beds()
|
||||
|
||||
local players_count = #minetest.get_connected_players()
|
||||
if beds.player_sleeping_count > (players_count/2) then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function beds.stand_up(name)
|
||||
if beds.player_sleeping[name] ~= nil then
|
||||
beds.player_sleeping[name] = nil
|
||||
beds.player_sleeping_count = beds.player_sleeping_count - 1
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player and player:is_player() then
|
||||
-- physics, eye_offset, etc
|
||||
player:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0})
|
||||
player:set_look_yaw(math.random(1, 180)/100)
|
||||
default.player_attached[name] = false
|
||||
player:set_physics_override(1, 1, 1)
|
||||
local hud_flags = player:hud_get_flags()
|
||||
hud_flags.wielditem = true
|
||||
player:hud_set_flags(hud_flags)
|
||||
default.player_set_animation(player, "stand" , 30)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function beds.lay_down(name, pos)
|
||||
if beds.player_sleeping[name] == nil then
|
||||
beds.player_sleeping[name] = pos
|
||||
beds.player_sleeping_count = beds.player_sleeping_count + 1
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player and player:is_player() then
|
||||
-- physics, eye_offset, etc
|
||||
player:set_eye_offset({x=0,y=-13,z=0}, {x=0,y=0,z=0})
|
||||
local yaw, param2 = get_look_yaw(pos)
|
||||
player:set_look_yaw(yaw)
|
||||
local dir = minetest.facedir_to_dir(param2)
|
||||
local p = {x=pos.x+dir.x/2,y=pos.y,z=pos.z+dir.z/2}
|
||||
player:setpos(p)
|
||||
player:set_physics_override(0, 0, 0)
|
||||
default.player_attached[name] = true
|
||||
local hud_flags = player:hud_get_flags()
|
||||
hud_flags.wielditem = false
|
||||
player:hud_set_flags(hud_flags)
|
||||
default.player_set_animation(player, "lay" , 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function update_formspecs(finished)
|
||||
local ges = #minetest.get_connected_players()
|
||||
local form_n = ""
|
||||
local is_majority = (ges/2) < beds.player_sleeping_count
|
||||
|
||||
if finished then
|
||||
form_n = form ..
|
||||
"label[2.7,11; Good morning.]"
|
||||
else
|
||||
form_n = form ..
|
||||
"label[2.2,11;"..tostring(beds.player_sleeping_count).." of "..tostring(ges).." players are in bed]"
|
||||
if is_majority then
|
||||
form_n = form_n ..
|
||||
"button_exit[2,8;4,0.75;force;Force night skip]"
|
||||
end
|
||||
end
|
||||
|
||||
for name,_ in pairs(beds.player_sleeping) do
|
||||
minetest.show_formspec(name, "beds_form", form_n)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- public functions
|
||||
|
||||
function beds.kick_players()
|
||||
for name,pos in pairs(beds.player_sleeping) do
|
||||
beds.stand_up(name)
|
||||
end
|
||||
end
|
||||
|
||||
function beds.on_rightclick(pos, player)
|
||||
local name = player:get_player_name()
|
||||
local tod = minetest.get_timeofday()
|
||||
local meta = minetest.get_meta(pos)
|
||||
local owner = meta:get_string("owner")
|
||||
|
||||
--return always string??!
|
||||
if owner == "" then
|
||||
owner = nil
|
||||
end
|
||||
|
||||
if owner and owner~=name then
|
||||
beds.stand_up(name)
|
||||
minetest.chat_send_player(name, "This bed is not yours.")
|
||||
return
|
||||
end
|
||||
|
||||
if tod > 0.2 and tod < 0.805 then
|
||||
beds.stand_up(name)
|
||||
minetest.chat_send_player(name, "You can only sleep at night.")
|
||||
return
|
||||
end
|
||||
|
||||
--temporaryly set this bed as spawn for player
|
||||
beds.player_pos[name] = pos
|
||||
|
||||
--make bed private
|
||||
if not owner then
|
||||
meta:set_string("owner", name or nil)
|
||||
meta:set_string("infotext", name.."'s bed")
|
||||
end
|
||||
|
||||
-- move to bed
|
||||
beds.lay_down(name, pos)
|
||||
|
||||
update_formspecs(false)
|
||||
|
||||
-- skip the night and let all stand up
|
||||
if check_in_beds() then
|
||||
minetest.after(0, function()
|
||||
beds.set_spawns()
|
||||
beds.kick_players()
|
||||
update_formspecs(true)
|
||||
minetest.set_timeofday(0.23)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- callbacks
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
beds.stand_up(name)
|
||||
if check_in_beds() then
|
||||
minetest.after(0, function()
|
||||
beds.set_spawns()
|
||||
beds.kick_players()
|
||||
update_formspecs(true)
|
||||
minetest.set_timeofday(0.23)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= "beds_form" then
|
||||
return
|
||||
end
|
||||
local name = player:get_player_name()
|
||||
if fields.quit or fields.leave then
|
||||
beds.stand_up(name)
|
||||
update_formspecs(false)
|
||||
elseif fields.force then
|
||||
beds.set_spawns()
|
||||
beds.kick_players()
|
||||
update_formspecs(true)
|
||||
minetest.set_timeofday(0.23)
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
local pos = beds.player_pos[name] or nil
|
||||
if pos then
|
||||
local player_pos = player:getpos()
|
||||
if math.abs(pos.x - player_pos.x) < 10 and math.abs(pos.z - player_pos.z) < 10 and math.abs(pos.y - player_pos.y) < 300 then
|
||||
--bed dont work if too close. Moustly needed for servers, where bone farming needs to be prevented
|
||||
else
|
||||
player:setpos(pos)
|
||||
--remove spawn, if bed was removed there
|
||||
minetest.after(4, function(name)
|
||||
local pos = beds.player_pos[name] or nil
|
||||
if pos then
|
||||
local bed = minetest.get_node(pos)
|
||||
if bed.name~="ignore" then
|
||||
if not ( bed.name=="beds:fancy_bed_bottom" or bed.name=="beds:fancy_bed_top" or
|
||||
bed.name=="beds:bed_bottom" or bed.name=="beds:bed_top") then
|
||||
beds.player_pos[name]=nil
|
||||
beds.player_spawns[name]=nil
|
||||
minetest.chat_send_player(name, "Your bed is lost.")
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
name)
|
||||
return true
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
-- nodes and respawn function
|
||||
dofile(minetest.get_modpath("beds").."/nodes.lua")
|
||||
dofile(minetest.get_modpath("beds").."/spawns.lua")
|
||||
dofile(modpath .. "/functions.lua")
|
||||
dofile(modpath .. "/api.lua")
|
||||
dofile(modpath .. "/beds.lua")
|
||||
dofile(modpath .. "/spawns.lua")
|
||||
|
@ -1,56 +1,58 @@
|
||||
beds.world_path = minetest.get_worldpath()
|
||||
beds.beds_file = beds.world_path .. "/beds_spawns.json"
|
||||
beds.writing_file = false
|
||||
local world_path = minetest.get_worldpath()
|
||||
local org_file = world_path .. "/beds_spawns"
|
||||
local file = world_path .. "/beds_spawns"
|
||||
local bkwd = false
|
||||
|
||||
-- check for PA's beds mod spawns
|
||||
local cf = io.open(world_path .. "/beds_player_spawns", "r")
|
||||
if cf ~= nil then
|
||||
io.close(cf)
|
||||
file = world_path .. "/beds_player_spawns"
|
||||
bkwd = true
|
||||
end
|
||||
|
||||
function beds.read_spawns()
|
||||
if beds.writing_file then
|
||||
-- wait until spawns are safed
|
||||
|
||||
return
|
||||
local spawns = beds.spawn
|
||||
local input = io.open(file, "r")
|
||||
if input and not bkwd then
|
||||
repeat
|
||||
local x = input:read("*n")
|
||||
if x == nil then
|
||||
break
|
||||
end
|
||||
local y = input:read("*n")
|
||||
local z = input:read("*n")
|
||||
local name = input:read("*l")
|
||||
spawns[name:sub(2)] = {x = x, y = y, z = z}
|
||||
until input:read(0) == nil
|
||||
io.close(input)
|
||||
elseif input and bkwd then
|
||||
beds.spawn = minetest.deserialize(input:read("*all"))
|
||||
input:close()
|
||||
beds.save_spawns()
|
||||
os.rename(file, file .. ".backup")
|
||||
file = org_file
|
||||
else
|
||||
spawns = {}
|
||||
end
|
||||
|
||||
local file, err = io.open(beds.beds_file, "r")
|
||||
if err then
|
||||
beds.player_spawns = {}
|
||||
return
|
||||
end
|
||||
beds.player_spawns = minetest.deserialize(file:read("*all"))
|
||||
if type(beds.player_spawns) ~= "table" then
|
||||
beds.player_spawns = {}
|
||||
end
|
||||
file:close()
|
||||
end
|
||||
|
||||
function beds.save_spawns()
|
||||
local datastring = minetest.serialize(beds.player_spawns)
|
||||
|
||||
if not datastring then
|
||||
return
|
||||
end
|
||||
beds.writing_file = true
|
||||
local file, err = io.open(beds.beds_file, "w")
|
||||
if err then
|
||||
return
|
||||
end
|
||||
file:write(datastring)
|
||||
file:close()
|
||||
beds.writing_file = false
|
||||
if not beds.spawn then
|
||||
return
|
||||
end
|
||||
local output = io.open(org_file, "w")
|
||||
for i, v in pairs(beds.spawn) do
|
||||
output:write(v.x .. " " .. v.y .. " " .. v.z .. " " .. i .. "\n")
|
||||
end
|
||||
io.close(output)
|
||||
end
|
||||
|
||||
function beds.set_spawns()
|
||||
for name, pos in pairs(beds.player_sleeping) do
|
||||
local spawn = minetest.pos_to_string(pos)
|
||||
beds.player_spawns[name] = spawn
|
||||
for name,_ in pairs(beds.player) do
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local p = player:getpos()
|
||||
beds.spawn[name] = p
|
||||
end
|
||||
beds.save_spawns()
|
||||
end
|
||||
|
||||
function beds.get_spawns()
|
||||
beds.read_spawns()
|
||||
for name, spawn in pairs(beds.player_spawns) do
|
||||
local pos = minetest.string_to_pos(spawn)
|
||||
beds.player_pos[name] = pos
|
||||
end
|
||||
end
|
||||
|
||||
beds.get_spawns()
|
@ -1,6 +1,6 @@
|
||||
Minetest 0.4 mod: boats
|
||||
=======================
|
||||
by PilzAdam, slightly modified for NeXt
|
||||
Minetest Game mod: boats
|
||||
========================
|
||||
by PilzAdam
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
|
@ -36,7 +36,7 @@ local boat = {
|
||||
physical = true,
|
||||
collisionbox = {-0.5, -0.35, -0.5, 0.5, 0.3, 0.5},
|
||||
visual = "mesh",
|
||||
mesh = "boat.obj",
|
||||
mesh = "boats_boat.obj",
|
||||
textures = {"default_wood.png"},
|
||||
|
||||
driver = nil,
|
||||
@ -62,6 +62,14 @@ function boat.on_rightclick(self, clicker)
|
||||
clicker:setpos(pos)
|
||||
end)
|
||||
elseif not self.driver then
|
||||
local attach = clicker:get_attach()
|
||||
if attach and attach:get_luaentity() then
|
||||
local luaentity = attach:get_luaentity()
|
||||
if luaentity.driver then
|
||||
luaentity.driver = nil
|
||||
end
|
||||
clicker:set_detach()
|
||||
end
|
||||
self.driver = clicker
|
||||
clicker:set_attach(self.object, "",
|
||||
{x = 0, y = 11, z = -3}, {x = 0, y = 0, z = 0})
|
||||
@ -88,8 +96,7 @@ function boat.get_staticdata(self)
|
||||
end
|
||||
|
||||
|
||||
function boat.on_punch(self, puncher, time_from_last_punch,
|
||||
tool_capabilities, direction)
|
||||
function boat.on_punch(self, puncher)
|
||||
if not puncher or not puncher:is_player() or self.removed then
|
||||
return
|
||||
end
|
||||
@ -105,7 +112,12 @@ function boat.on_punch(self, puncher, time_from_last_punch,
|
||||
self.object:remove()
|
||||
end)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
puncher:get_inventory():add_item("main", "boats:boat")
|
||||
local inv = puncher:get_inventory()
|
||||
if inv:room_for_item("main", "boats:boat") then
|
||||
inv:add_item("main", "boats:boat")
|
||||
else
|
||||
minetest.add_item(self.object:getpos(), "boats:boat")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -203,8 +215,8 @@ minetest.register_entity("boats:boat", boat)
|
||||
|
||||
minetest.register_craftitem("boats:boat", {
|
||||
description = "Boat",
|
||||
inventory_image = "boat_inventory.png",
|
||||
wield_image = "boat_wield.png",
|
||||
inventory_image = "boats_inventory.png",
|
||||
wield_image = "boats_wield.png",
|
||||
wield_scale = {x = 2, y = 2, z = 1},
|
||||
liquids_pointable = true,
|
||||
|
||||
|
3111
mods/boats/models/boats_boat.obj
Normal file
BIN
mods/boats/textures/boats_inventory.png
Normal file
After Width: | Height: | Size: 851 B |
BIN
mods/boats/textures/boats_wield.png
Normal file
After Width: | Height: | Size: 546 B |
@ -1,11 +1,16 @@
|
||||
Minetest 0.4 mod: doors
|
||||
=======================
|
||||
version: 1.3
|
||||
Minetest Game mod: doors
|
||||
========================
|
||||
version: 2.0
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
Copyright (C) 2012 PilzAdam
|
||||
modified by BlockMen (added sounds, glassdoors[glass, obsidian glass], trapdoor)
|
||||
Steel trapdoor added by sofar.
|
||||
Copyright (C) 2016 sofar@foo-projects.org
|
||||
Re-implemented most of the door algorithms, added meshes, UV wrapped texture
|
||||
Added doors API to facilitate coding mods accessing and operating doors.
|
||||
Added Fence Gate model, code, and sounds
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
@ -27,16 +32,37 @@ following Textures created by BlockMen (WTFPL):
|
||||
door_obsidian_glass_side.png
|
||||
|
||||
following textures created by celeron55 (CC BY-SA 3.0):
|
||||
door_trapdoor_side.png
|
||||
door_glass_a.png
|
||||
door_glass_b.png
|
||||
|
||||
|
||||
following Textures created by PenguinDad (CC BY-SA 4.0):
|
||||
door_glass.png
|
||||
door_obsidian_glass.png
|
||||
|
||||
following textures created by sofar (CC-BY-SA-3.0)
|
||||
doors_trapdoor_steel.png
|
||||
doors_trapdoor_steel_side.png
|
||||
door_trapdoor_side.png
|
||||
|
||||
|
||||
Obsidian door textures by red-001 based on textures by Pilzadam and BlockMen: WTFPL
|
||||
door_obsidian_glass.png
|
||||
|
||||
Glass door textures by red-001 based on textures by celeron55: CC BY-SA 3.0
|
||||
door_glass.png
|
||||
All other textures (created by PilzAdam): WTFPL
|
||||
|
||||
Door textures were converted to the new texture map by sofar, paramat and
|
||||
red-001, under the same license as the originals.
|
||||
|
||||
Models:
|
||||
--------------------------------------
|
||||
Door 3d models by sofar (CC-BY-SA-3.0)
|
||||
- door_a.obj
|
||||
- door_b.obj
|
||||
Fence gate models by sofar (CC-BY-SA-3.0)
|
||||
- fencegate_open.obj
|
||||
- fencegate_closed.obj
|
||||
|
||||
License of sounds
|
||||
--------------------------------------
|
||||
@ -44,3 +70,9 @@ Opening-Sound created by CGEffex (CC BY 3.0), modified by BlockMen
|
||||
door_open.ogg
|
||||
Closing-Sound created by bennstir (CC BY 3.0)
|
||||
door_close.ogg
|
||||
fencegate_open.ogg:
|
||||
http://www.freesound.org/people/mhtaylor67/sounds/126041/ - CC0
|
||||
fencegate_close.ogg:
|
||||
http://www.freesound.org/people/BarkersPinhead/sounds/274807/ - CC-BY-3.0
|
||||
http://www.freesound.org/people/rivernile7/sounds/249573/ - CC-BY-3.0
|
||||
|
||||
|
1000
mods/doors/init.lua
40
mods/doors/models/door_a.obj
Normal file
@ -0,0 +1,40 @@
|
||||
# Blender v2.76 (sub 0) OBJ File: 'door_a.blend'
|
||||
# www.blender.org
|
||||
mtllib door_a.mtl
|
||||
o Cube_Cube.001
|
||||
v 0.499000 -0.499000 -0.499000
|
||||
v 0.499000 1.499000 -0.499000
|
||||
v 0.499000 -0.499000 -0.375000
|
||||
v 0.499000 1.499000 -0.375000
|
||||
v -0.499000 -0.499000 -0.499000
|
||||
v -0.499000 1.499000 -0.499000
|
||||
v -0.499000 -0.499000 -0.375000
|
||||
v -0.499000 1.499000 -0.375000
|
||||
vt 0.842105 1.000000
|
||||
vt 0.894737 1.000000
|
||||
vt 0.894737 0.000000
|
||||
vt 0.842105 0.000000
|
||||
vt 0.421053 1.000000
|
||||
vt 0.421053 0.000000
|
||||
vt 0.947368 1.000000
|
||||
vt 0.947368 0.000000
|
||||
vt 0.000000 1.000000
|
||||
vt 0.000000 0.000000
|
||||
vt 1.000000 0.500000
|
||||
vt 0.947368 0.500000
|
||||
vt 1.000000 1.000000
|
||||
vt 1.000000 0.000000
|
||||
vn 1.000000 0.000000 0.000000
|
||||
vn 0.000000 0.000000 1.000000
|
||||
vn -1.000000 0.000000 0.000000
|
||||
vn 0.000000 0.000000 -1.000000
|
||||
vn 0.000000 -1.000000 0.000000
|
||||
vn 0.000000 1.000000 0.000000
|
||||
usemtl None
|
||||
s off
|
||||
f 2/1/1 4/2/1 3/3/1 1/4/1
|
||||
f 4/5/2 8/1/2 7/4/2 3/6/2
|
||||
f 8/2/3 6/7/3 5/8/3 7/3/3
|
||||
f 6/9/4 2/5/4 1/6/4 5/10/4
|
||||
f 1/11/5 3/12/5 7/7/5 5/13/5
|
||||
f 6/14/6 8/8/6 4/12/6 2/11/6
|
40
mods/doors/models/door_b.obj
Normal file
@ -0,0 +1,40 @@
|
||||
# Blender v2.76 (sub 0) OBJ File: 'door_b.blend'
|
||||
# www.blender.org
|
||||
mtllib door_b.mtl
|
||||
o Cube_Cube.001
|
||||
v -0.499000 -0.499000 -0.499000
|
||||
v -0.499000 1.499000 -0.499000
|
||||
v -0.499000 -0.499000 -0.375000
|
||||
v -0.499000 1.499000 -0.375000
|
||||
v 0.499000 -0.499000 -0.499000
|
||||
v 0.499000 1.499000 -0.499000
|
||||
v 0.499000 -0.499000 -0.375000
|
||||
v 0.499000 1.499000 -0.375000
|
||||
vt 0.842105 1.000000
|
||||
vt 0.842105 0.000000
|
||||
vt 0.894737 0.000000
|
||||
vt 0.894737 1.000000
|
||||
vt 0.421053 1.000000
|
||||
vt 0.421053 0.000000
|
||||
vt 0.947368 0.000000
|
||||
vt 0.947368 1.000000
|
||||
vt 0.000000 1.000000
|
||||
vt 0.000000 0.000000
|
||||
vt 1.000000 0.000000
|
||||
vt 1.000000 0.500000
|
||||
vt 0.947368 0.500000
|
||||
vt 1.000000 1.000000
|
||||
vn -1.000000 0.000000 0.000000
|
||||
vn 0.000000 0.000000 1.000000
|
||||
vn 1.000000 0.000000 0.000000
|
||||
vn 0.000000 0.000000 -1.000000
|
||||
vn 0.000000 -1.000000 0.000000
|
||||
vn 0.000000 1.000000 0.000000
|
||||
usemtl None
|
||||
s off
|
||||
f 2/1/1 1/2/1 3/3/1 4/4/1
|
||||
f 4/5/2 3/6/2 7/2/2 8/1/2
|
||||
f 8/4/3 7/3/3 5/7/3 6/8/3
|
||||
f 6/9/4 5/10/4 1/6/4 2/5/4
|
||||
f 1/11/5 5/12/5 7/13/5 3/7/5
|
||||
f 6/8/6 2/13/6 4/12/6 8/14/6
|
106
mods/doors/models/doors_fencegate_closed.obj
Normal file
@ -0,0 +1,106 @@
|
||||
# Blender v2.76 (sub 0) OBJ File: 'gate_closed.blend'
|
||||
# www.blender.org
|
||||
mtllib gate_closed.mtl
|
||||
o Cube_Cube.001
|
||||
v -0.625000 -0.500000 0.125000
|
||||
v -0.625000 0.500100 0.125000
|
||||
v -0.625000 -0.500000 -0.125000
|
||||
v -0.625000 0.500100 -0.125000
|
||||
v -0.375000 -0.500000 0.125000
|
||||
v -0.375000 0.500100 0.125000
|
||||
v -0.375000 -0.500000 -0.125000
|
||||
v -0.375000 0.500100 -0.125000
|
||||
v 0.375000 -0.500000 0.125000
|
||||
v 0.375000 0.500100 0.125000
|
||||
v 0.375000 -0.500000 -0.125000
|
||||
v 0.375000 0.500100 -0.125000
|
||||
v 0.625000 -0.500000 0.125000
|
||||
v 0.625000 0.500100 0.125000
|
||||
v 0.625000 -0.500000 -0.125000
|
||||
v 0.625000 0.500100 -0.125000
|
||||
v -0.375000 0.187500 0.062500
|
||||
v -0.375000 0.312500 0.062500
|
||||
v -0.375000 0.187500 -0.062500
|
||||
v -0.375000 0.312500 -0.062500
|
||||
v 0.375000 0.187500 0.062500
|
||||
v 0.375000 0.312500 0.062500
|
||||
v 0.375000 0.187500 -0.062500
|
||||
v 0.375000 0.312500 -0.062500
|
||||
v -0.374831 0.187348 0.062500
|
||||
v -0.156342 0.187363 0.062500
|
||||
v -0.374831 0.187348 -0.062500
|
||||
v -0.156342 0.187363 -0.062500
|
||||
v 0.374981 -0.343683 0.062500
|
||||
v 0.375065 -0.187304 0.062500
|
||||
v 0.374981 -0.343683 -0.062500
|
||||
v 0.375065 -0.187304 -0.062500
|
||||
vt 0.000000 0.750000
|
||||
vt 0.000000 0.500000
|
||||
vt 1.000000 0.500000
|
||||
vt 1.000000 0.750000
|
||||
vt 1.000000 1.000000
|
||||
vt -0.000000 1.000000
|
||||
vt 1.000000 -0.000000
|
||||
vt 1.000000 0.250000
|
||||
vt 0.000000 0.250000
|
||||
vt -0.000000 0.000000
|
||||
vt 0.250000 0.000000
|
||||
vt 0.250000 0.250000
|
||||
vt 0.250000 0.750000
|
||||
vt 0.250000 1.000000
|
||||
vt 0.500000 -0.000000
|
||||
vt 0.500000 0.250000
|
||||
vt 0.500000 0.750000
|
||||
vt 0.500000 1.000000
|
||||
vt 1.000000 0.625000
|
||||
vt 0.000000 0.625000
|
||||
vt 1.000000 0.875000
|
||||
vt 0.000000 0.875000
|
||||
vt -0.000000 0.687500
|
||||
vt 0.000000 0.562500
|
||||
vt 1.000000 0.562500
|
||||
vt 1.000000 0.687500
|
||||
vt 0.813740 0.249033
|
||||
vt 0.201557 0.249293
|
||||
vt 0.120995 0.125498
|
||||
vt 0.987404 0.125469
|
||||
vt 0.125000 0.375000
|
||||
vt 0.812500 0.375000
|
||||
vt 0.937500 0.500000
|
||||
vt 0.062500 0.500000
|
||||
vt 0.000000 0.125000
|
||||
vt 1.000000 0.125000
|
||||
vt 0.312500 0.437500
|
||||
vt 0.312500 0.312500
|
||||
vt 1.000000 0.312500
|
||||
vt 1.000000 0.437500
|
||||
vn -1.000000 0.000000 0.000000
|
||||
vn 0.000000 0.000000 -1.000000
|
||||
vn 1.000000 0.000000 0.000000
|
||||
vn 0.000000 0.000000 1.000000
|
||||
vn 0.000000 -1.000000 0.000000
|
||||
vn 0.000000 1.000000 0.000000
|
||||
vn -0.578000 -0.816100 0.000000
|
||||
vn 0.576200 0.817300 0.000000
|
||||
usemtl None
|
||||
s off
|
||||
f 2/1/1 4/2/1 3/3/1 1/4/1
|
||||
f 4/4/2 8/5/2 7/6/2 3/1/2
|
||||
f 8/7/3 6/8/3 5/9/3 7/10/3
|
||||
f 6/2/4 2/9/4 1/8/4 5/3/4
|
||||
f 1/9/5 3/10/5 7/11/5 5/12/5
|
||||
f 6/6/6 8/1/6 4/13/6 2/14/6
|
||||
f 10/1/1 12/2/1 11/3/1 9/4/1
|
||||
f 12/2/2 16/9/2 15/8/2 11/3/2
|
||||
f 16/7/3 14/8/3 13/9/3 15/10/3
|
||||
f 14/4/4 10/5/4 9/6/4 13/1/4
|
||||
f 9/12/5 11/11/5 15/15/5 13/16/5
|
||||
f 14/14/6 16/13/6 12/17/6 10/18/6
|
||||
f 20/2/2 24/3/2 23/19/2 19/20/2
|
||||
f 22/1/4 18/4/4 17/21/4 21/22/4
|
||||
f 17/23/5 19/24/5 23/25/5 21/26/5
|
||||
f 22/21/6 24/5/6 20/6/6 18/22/6
|
||||
f 28/27/2 32/28/2 31/29/2 27/30/2
|
||||
f 30/31/4 26/32/4 25/33/4 29/34/4
|
||||
f 25/35/7 27/10/7 31/7/7 29/36/7
|
||||
f 30/37/8 32/38/8 28/39/8 26/40/8
|
112
mods/doors/models/doors_fencegate_open.obj
Normal file
@ -0,0 +1,112 @@
|
||||
# Blender v2.76 (sub 0) OBJ File: 'gate_open.blend'
|
||||
# www.blender.org
|
||||
mtllib gate_open.mtl
|
||||
o Cube_Cube.001
|
||||
v -0.625000 -0.500000 0.125000
|
||||
v -0.625000 0.500100 0.125000
|
||||
v -0.625000 -0.500000 -0.125000
|
||||
v -0.625000 0.500100 -0.125000
|
||||
v -0.375000 -0.500000 0.125000
|
||||
v -0.375000 0.500100 0.125000
|
||||
v -0.375000 -0.500000 -0.125000
|
||||
v -0.375000 0.500100 -0.125000
|
||||
v 0.375000 -0.500000 0.125000
|
||||
v 0.375000 0.500100 0.125000
|
||||
v 0.375000 -0.500000 -0.125000
|
||||
v 0.375000 0.500100 -0.125000
|
||||
v 0.625000 -0.500000 0.125000
|
||||
v 0.625000 0.500100 0.125000
|
||||
v 0.625000 -0.500000 -0.125000
|
||||
v 0.625000 0.500100 -0.125000
|
||||
v 0.434859 0.187500 -0.872359
|
||||
v 0.434859 0.312500 -0.872359
|
||||
v 0.559859 0.187500 -0.872359
|
||||
v 0.559859 0.312500 -0.872359
|
||||
v 0.434859 0.187500 -0.122359
|
||||
v 0.434859 0.312500 -0.122359
|
||||
v 0.559859 0.187500 -0.122359
|
||||
v 0.559859 0.312500 -0.122359
|
||||
v 0.434859 0.187348 -0.872190
|
||||
v 0.434859 0.187363 -0.653701
|
||||
v 0.559859 0.187348 -0.872190
|
||||
v 0.559859 0.187363 -0.653701
|
||||
v 0.434859 -0.343683 -0.122379
|
||||
v 0.434859 -0.187304 -0.122294
|
||||
v 0.559859 -0.343683 -0.122379
|
||||
v 0.559859 -0.187304 -0.122294
|
||||
v 0.499560 -0.442900 0.005495
|
||||
vt 0.000000 0.750000
|
||||
vt 0.000000 0.500000
|
||||
vt 1.000000 0.500000
|
||||
vt 1.000000 0.750000
|
||||
vt 1.000000 1.000000
|
||||
vt -0.000000 1.000000
|
||||
vt 1.000000 -0.000000
|
||||
vt 1.000000 0.250000
|
||||
vt 0.000000 0.250000
|
||||
vt -0.000000 0.000000
|
||||
vt 0.250000 0.000000
|
||||
vt 0.250000 0.250000
|
||||
vt 0.250000 0.750000
|
||||
vt 0.250000 1.000000
|
||||
vt 0.500000 -0.000000
|
||||
vt 0.500000 0.250000
|
||||
vt 0.500000 0.750000
|
||||
vt 0.500000 1.000000
|
||||
vt 1.000000 0.625000
|
||||
vt 0.000000 0.625000
|
||||
vt 1.000000 0.875000
|
||||
vt 0.000000 0.875000
|
||||
vt -0.000000 0.687500
|
||||
vt 0.000000 0.562500
|
||||
vt 1.000000 0.562500
|
||||
vt 1.000000 0.687500
|
||||
vt 0.813740 0.249033
|
||||
vt 0.201557 0.249293
|
||||
vt 0.120995 0.125498
|
||||
vt 0.987404 0.125469
|
||||
vt 0.125000 0.375000
|
||||
vt 0.812500 0.375000
|
||||
vt 0.937500 0.500000
|
||||
vt 0.062500 0.500000
|
||||
vt 0.000000 0.125000
|
||||
vt 1.000000 0.125000
|
||||
vt 0.312500 0.437500
|
||||
vt 0.312500 0.312500
|
||||
vt 1.000000 0.312500
|
||||
vt 1.000000 0.437500
|
||||
vt 0.312500 0.625000
|
||||
vt 0.312500 0.500000
|
||||
vt 0.187500 0.500000
|
||||
vt 0.187500 0.625000
|
||||
vn -1.000000 0.000000 0.000000
|
||||
vn 0.000000 0.000000 -1.000000
|
||||
vn 1.000000 0.000000 0.000000
|
||||
vn 0.000000 0.000000 1.000000
|
||||
vn 0.000000 -1.000000 0.000000
|
||||
vn 0.000000 1.000000 0.000000
|
||||
vn 0.000000 -0.816100 -0.578000
|
||||
vn 0.000000 0.817300 0.576200
|
||||
usemtl None
|
||||
s off
|
||||
f 2/1/1 4/2/1 3/3/1 1/4/1
|
||||
f 4/4/2 8/5/2 7/6/2 3/1/2
|
||||
f 8/7/3 6/8/3 5/9/3 7/10/3
|
||||
f 6/2/4 2/9/4 1/8/4 5/3/4
|
||||
f 1/9/5 3/10/5 7/11/5 5/12/5
|
||||
f 6/6/6 8/1/6 4/13/6 2/14/6
|
||||
f 10/1/1 12/2/1 11/3/1 9/4/1
|
||||
f 12/2/2 16/9/2 15/8/2 11/3/2
|
||||
f 16/7/3 14/8/3 13/9/3 15/10/3
|
||||
f 14/4/4 10/5/4 9/6/4 13/1/4
|
||||
f 9/12/5 11/11/5 15/15/5 13/16/5
|
||||
f 14/14/6 16/13/6 12/17/6 10/18/6
|
||||
f 20/2/3 24/3/3 23/19/3 19/20/3
|
||||
f 22/1/1 18/4/1 17/21/1 21/22/1
|
||||
f 17/23/5 19/24/5 23/25/5 21/26/5
|
||||
f 22/21/6 24/5/6 20/6/6 18/22/6
|
||||
f 28/27/3 32/28/3 31/29/3 27/30/3
|
||||
f 30/31/1 26/32/1 25/33/1 29/34/1
|
||||
f 25/35/7 27/10/7 31/7/7 29/36/7
|
||||
f 30/37/8 32/38/8 28/39/8 26/40/8
|
||||
f 17/41/2 18/42/2 20/43/2 19/44/2
|
BIN
mods/doors/sounds/doors_fencegate_close.ogg
Normal file
BIN
mods/doors/sounds/doors_fencegate_open.ogg
Normal file
BIN
mods/doors/textures/doors_door_glass.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
mods/doors/textures/doors_door_obsidian_glass.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
mods/doors/textures/doors_door_steel.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
mods/doors/textures/doors_door_wood.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
mods/doors/textures/doors_item_glass.png
Normal file
After Width: | Height: | Size: 186 B |
BIN
mods/doors/textures/doors_item_obsidian_glass.png
Normal file
After Width: | Height: | Size: 186 B |
BIN
mods/doors/textures/doors_item_steel.png
Normal file
After Width: | Height: | Size: 132 B |
BIN
mods/doors/textures/doors_item_wood.png
Normal file
After Width: | Height: | Size: 130 B |
Before Width: | Height: | Size: 173 B After Width: | Height: | Size: 233 B |
BIN
mods/doors/textures/doors_trapdoor_steel.png
Normal file
After Width: | Height: | Size: 153 B |
BIN
mods/doors/textures/doors_trapdoor_steel_side.png
Normal file
After Width: | Height: | Size: 101 B |
@ -1,4 +1,4 @@
|
||||
Minetest 0.4 mod: dye
|
||||
Minetest Game mod: dye
|
||||
======================
|
||||
|
||||
See init.lua for documentation.
|
||||
|
@ -1,39 +1,58 @@
|
||||
-- minetest/dye/init.lua
|
||||
|
||||
-- Other mods can use these for looping through available colors
|
||||
|
||||
dye = {}
|
||||
dye.basecolors = {"white", "grey", "black", "red", "yellow", "green", "cyan", "blue", "magenta"}
|
||||
dye.excolors = {"white", "lightgrey", "grey", "darkgrey", "black", "red", "orange", "yellow", "lime", "green", "aqua", "cyan", "sky_blue", "blue", "violet", "magenta", "red_violet"}
|
||||
dye.excolors = {"white", "lightgrey", "grey", "darkgrey", "black", "red", "orange", "yellow",
|
||||
"lime", "green", "aqua", "cyan", "sky_blue", "blue", "violet", "magenta", "red_violet"}
|
||||
|
||||
-- Local stuff
|
||||
local dyelocal = {}
|
||||
-- Make dye names and descriptions available globally
|
||||
|
||||
-- This collection of colors is partly a historic thing, partly something else.
|
||||
dyelocal.dyes = {
|
||||
{"white", "White dye", {dye=1, basecolor_white=1, excolor_white=1, unicolor_white=1}},
|
||||
{"grey", "Grey dye", {dye=1, basecolor_grey=1, excolor_grey=1, unicolor_grey=1}},
|
||||
{"dark_grey", "Dark grey dye", {dye=1, basecolor_grey=1, excolor_darkgrey=1, unicolor_darkgrey=1}},
|
||||
{"black", "Black dye", {dye=1, basecolor_black=1, excolor_black=1, unicolor_black=1}},
|
||||
{"violet", "Violet dye", {dye=1, basecolor_magenta=1, excolor_violet=1, unicolor_violet=1}},
|
||||
{"blue", "Blue dye", {dye=1, basecolor_blue=1, excolor_blue=1, unicolor_blue=1}},
|
||||
{"cyan", "Cyan dye", {dye=1, basecolor_cyan=1, excolor_cyan=1, unicolor_cyan=1}},
|
||||
{"dark_green", "Dark green dye",{dye=1, basecolor_green=1, excolor_green=1, unicolor_dark_green=1}},
|
||||
{"green", "Green dye", {dye=1, basecolor_green=1, excolor_green=1, unicolor_green=1}},
|
||||
{"yellow", "Yellow dye", {dye=1, basecolor_yellow=1, excolor_yellow=1, unicolor_yellow=1}},
|
||||
{"brown", "Brown dye", {dye=1, basecolor_brown=1, excolor_orange=1, unicolor_dark_orange=1}},
|
||||
{"orange", "Orange dye", {dye=1, basecolor_orange=1, excolor_orange=1, unicolor_orange=1}},
|
||||
{"red", "Red dye", {dye=1, basecolor_red=1, excolor_red=1, unicolor_red=1}},
|
||||
{"magenta", "Magenta dye", {dye=1, basecolor_magenta=1, excolor_red_violet=1,unicolor_red_violet=1}},
|
||||
{"pink", "Pink dye", {dye=1, basecolor_red=1, excolor_red=1, unicolor_light_red=1}},
|
||||
dye.dyes = {
|
||||
{"white", "White"},
|
||||
{"grey", "Grey"},
|
||||
{"dark_grey", "Dark grey"},
|
||||
{"black", "Black"},
|
||||
{"violet", "Violet"},
|
||||
{"blue", "Blue"},
|
||||
{"cyan", "Cyan"},
|
||||
{"dark_green", "Dark green"},
|
||||
{"green", "Green"},
|
||||
{"yellow", "Yellow"},
|
||||
{"brown", "Brown"},
|
||||
{"orange", "Orange"},
|
||||
{"red", "Red"},
|
||||
{"magenta", "Magenta"},
|
||||
{"pink", "Pink"},
|
||||
}
|
||||
|
||||
-- This collection of colors is partly a historic thing, partly something else
|
||||
|
||||
local dyes = {
|
||||
{"white", "White dye", {dye=1, basecolor_white=1, excolor_white=1, unicolor_white=1}},
|
||||
{"grey", "Grey dye", {dye=1, basecolor_grey=1, excolor_grey=1, unicolor_grey=1}},
|
||||
{"dark_grey", "Dark grey dye", {dye=1, basecolor_grey=1, excolor_darkgrey=1, unicolor_darkgrey=1}},
|
||||
{"black", "Black dye", {dye=1, basecolor_black=1, excolor_black=1, unicolor_black=1}},
|
||||
{"violet", "Violet dye", {dye=1, basecolor_magenta=1, excolor_violet=1, unicolor_violet=1}},
|
||||
{"blue", "Blue dye", {dye=1, basecolor_blue=1, excolor_blue=1, unicolor_blue=1}},
|
||||
{"cyan", "Cyan dye", {dye=1, basecolor_cyan=1, excolor_cyan=1, unicolor_cyan=1}},
|
||||
{"dark_green", "Dark green dye", {dye=1, basecolor_green=1, excolor_green=1, unicolor_dark_green=1}},
|
||||
{"green", "Green dye", {dye=1, basecolor_green=1, excolor_green=1, unicolor_green=1}},
|
||||
{"yellow", "Yellow dye", {dye=1, basecolor_yellow=1, excolor_yellow=1, unicolor_yellow=1}},
|
||||
{"brown", "Brown dye", {dye=1, basecolor_brown=1, excolor_orange=1, unicolor_dark_orange=1}},
|
||||
{"orange", "Orange dye", {dye=1, basecolor_orange=1, excolor_orange=1, unicolor_orange=1}},
|
||||
{"red", "Red dye", {dye=1, basecolor_red=1, excolor_red=1, unicolor_red=1}},
|
||||
{"magenta", "Magenta dye", {dye=1, basecolor_magenta=1, excolor_red_violet=1, unicolor_red_violet=1}},
|
||||
{"pink", "Pink dye", {dye=1, basecolor_red=1, excolor_red=1, unicolor_light_red=1}},
|
||||
}
|
||||
|
||||
-- Define items
|
||||
for _, row in ipairs(dyelocal.dyes) do
|
||||
|
||||
for _, row in ipairs(dyes) do
|
||||
local name = row[1]
|
||||
local description = row[2]
|
||||
local groups = row[3]
|
||||
local item_name = "dye:"..name
|
||||
local item_image = "dye_"..name..".png"
|
||||
local item_name = "dye:" .. name
|
||||
local item_image = "dye_" .. name .. ".png"
|
||||
minetest.register_craftitem(item_name, {
|
||||
inventory_image = item_image,
|
||||
description = description,
|
||||
@ -41,11 +60,13 @@ for _, row in ipairs(dyelocal.dyes) do
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = item_name.." 4",
|
||||
recipe = {"group:flower,color_"..name},
|
||||
output = item_name .. " 4",
|
||||
recipe = {"group:flower,color_" .. name},
|
||||
})
|
||||
end
|
||||
-- manually add coal->black dye
|
||||
|
||||
-- Manually add coal->black dye
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "dye:black 4",
|
||||
@ -55,33 +76,34 @@ minetest.register_craft({
|
||||
-- Mix recipes
|
||||
-- Just mix everything to everything somehow sanely
|
||||
|
||||
dyelocal.mixbases = {"magenta", "red", "orange", "brown", "yellow", "green", "dark_green", "cyan", "blue", "violet", "black", "dark_grey", "grey", "white"}
|
||||
local mixbases = {"pink", "magenta", "red", "orange", "brown", "yellow", "green", "dark_green", "cyan", "blue", "violet", "black", "dark_grey", "grey", "white"}
|
||||
|
||||
dyelocal.mixes = {
|
||||
-- magenta, red, orange, brown, yellow, green, dark_green, cyan, blue, violet, black, dark_grey, grey, white
|
||||
white = {"pink", "pink", "orange", "orange", "yellow", "green", "green", "grey", "cyan", "violet", "grey", "grey", "white", "white"},
|
||||
grey = {"pink", "pink", "orange", "orange", "yellow", "green", "green", "grey", "cyan", "pink", "dark_grey","grey", "grey"},
|
||||
dark_grey={"brown","brown", "brown", "brown", "brown","dark_green","dark_green","blue","blue","violet","black", "black"},
|
||||
black = {"black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black"},
|
||||
violet= {"magenta","magenta","red", "brown", "red", "cyan", "brown", "blue", "violet","violet"},
|
||||
blue = {"violet", "magenta","brown","brown","dark_green","cyan","cyan", "cyan", "blue"},
|
||||
cyan = {"blue","brown","dark_green","dark_grey","green","cyan","dark_green","cyan"},
|
||||
dark_green={"brown","brown","brown", "brown", "green", "green", "dark_green"},
|
||||
green = {"brown", "yellow","yellow","dark_green","green","green"},
|
||||
yellow= {"red", "orange", "yellow","orange", "yellow"},
|
||||
brown = {"brown", "brown","orange", "brown"},
|
||||
orange= {"red", "orange","orange"},
|
||||
red = {"magenta","red"},
|
||||
magenta={"magenta"},
|
||||
local mixes = {
|
||||
-- pink, magenta, red, orange, brown, yellow, green, dark_green, cyan, blue, violet, black, dark_grey, grey, white
|
||||
white = {"pink", "pink", "pink", "orange", "orange", "yellow", "green", "green", "grey", "cyan", "violet","grey", "grey", "grey","white"},
|
||||
grey = {"pink", "pink", "pink", "orange", "orange", "yellow", "green", "green", "grey", "cyan", "violet","dark_grey","grey", "grey"},
|
||||
dark_grey = {"brown", "brown", "brown", "brown", "brown", "brown", "dark_green","dark_green","blue", "blue", "violet","black", "dark_grey"},
|
||||
black = {"black", "black", "black", "black", "black", "black", "black", "black", "black","black", "black", "black"},
|
||||
violet = {"magenta","magenta","magenta","red", "brown", "red", "cyan", "brown", "blue", "violet","violet"},
|
||||
blue = {"violet", "violet", "magenta","brown", "brown", "dark_green","cyan", "cyan", "cyan", "blue"},
|
||||
cyan = {"brown", "blue", "brown", "dark_green","dark_grey", "green", "cyan", "dark_green","cyan"},
|
||||
dark_green = {"brown", "brown", "brown", "brown", "brown", "green", "green", "dark_green"},
|
||||
green = {"yellow", "brown", "yellow", "yellow", "dark_green","green", "green"},
|
||||
yellow = {"orange", "red", "orange", "yellow", "orange", "yellow"},
|
||||
brown = {"brown", "brown", "brown", "orange", "brown"},
|
||||
orange = {"orange", "red", "orange", "orange"},
|
||||
red = {"pink", "magenta","red"},
|
||||
magenta = {"magenta","magenta"},
|
||||
pink = {"pink"},
|
||||
}
|
||||
|
||||
for one,results in pairs(dyelocal.mixes) do
|
||||
for i,result in ipairs(results) do
|
||||
local another = dyelocal.mixbases[i]
|
||||
for one, results in pairs(mixes) do
|
||||
for i, result in ipairs(results) do
|
||||
local another = mixbases[i]
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = 'dye:'..result..' 2',
|
||||
recipe = {'dye:'..one, 'dye:'..another},
|
||||
output = 'dye:' .. result .. ' 2',
|
||||
recipe = {'dye:' .. one, 'dye:' .. another},
|
||||
})
|
||||
end
|
||||
end
|
||||
|
@ -13,6 +13,7 @@ This mod works by adding your new plant to the {growing=1} group and numbering t
|
||||
|
||||
Changelog:
|
||||
|
||||
1.23 - Huge code tweak and tidy done and added barley seeds to be found in dry grass, barley can make flour for bread also.
|
||||
1.22 - Added grape bushes at high climates which can be cultivated into grape vines using trellis (9 sticks).
|
||||
1.21 - Added auto-refill code for planting crops (thanks crabman77), also fixed a few bugs
|
||||
1.20b- Tidied code, made api compatible with new 0.4.13 changes and changed to soil texture overlays
|
||||
|
96
mods/farming/barley.lua
Normal file
@ -0,0 +1,96 @@
|
||||
|
||||
-- barley seeds
|
||||
minetest.register_node("farming:seed_barley", {
|
||||
description = "Barley Seed",
|
||||
tiles = {"farming_barley_seed.png"},
|
||||
inventory_image = "farming_barley_seed.png",
|
||||
wield_image = "farming_barley_seed.png",
|
||||
drawtype = "signlike",
|
||||
groups = {seed = 1, snappy = 3, attached_node = 1},
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
walkable = false,
|
||||
sunlight_propagates = true,
|
||||
selection_box = farming.select,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
return farming.place_seed(itemstack, placer, pointed_thing, "farming:barley_1")
|
||||
end,
|
||||
})
|
||||
|
||||
-- harvested barley
|
||||
minetest.register_craftitem("farming:barley", {
|
||||
description = "barley",
|
||||
inventory_image = "farming_barley.png",
|
||||
})
|
||||
|
||||
-- flour
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "farming:flour",
|
||||
recipe = {"farming:barley", "farming:barley", "farming:barley", "farming:barley"}
|
||||
})
|
||||
|
||||
-- barley definition
|
||||
local crop_def = {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_barley_1.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
}
|
||||
|
||||
-- stage 1
|
||||
minetest.register_node("farming:barley_1", table.copy(crop_def))
|
||||
|
||||
-- stage 2
|
||||
crop_def.tiles = {"farming_barley_2.png"}
|
||||
minetest.register_node("farming:barley_2", table.copy(crop_def))
|
||||
|
||||
-- stage 3
|
||||
crop_def.tiles = {"farming_barley_3.png"}
|
||||
minetest.register_node("farming:barley_3", table.copy(crop_def))
|
||||
|
||||
-- stage 4
|
||||
crop_def.tiles = {"farming_barley_4.png"}
|
||||
minetest.register_node("farming:barley_4", table.copy(crop_def))
|
||||
|
||||
-- stage 5
|
||||
crop_def.tiles = {"farming_barley_5.png"}
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:barley'}, rarity = 2},
|
||||
{items = {'farming:seed_barley'}, rarity = 2},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:barley_5", table.copy(crop_def))
|
||||
|
||||
-- stage 6
|
||||
crop_def.tiles = {"farming_barley_6.png"}
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:barley'}, rarity = 2},
|
||||
{items = {'farming:seed_barley'}, rarity = 1},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:barley_6", table.copy(crop_def))
|
||||
|
||||
-- stage 7 (final)
|
||||
crop_def.tiles = {"farming_barley_7.png"}
|
||||
crop_def.groups.growing = 0
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:barley'}, rarity = 1},
|
||||
{items = {'farming:barley'}, rarity = 3},
|
||||
{items = {'farming:seed_barley'}, rarity = 1},
|
||||
{items = {'farming:seed_barley'}, rarity = 3},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:barley_7", table.copy(crop_def))
|
@ -2,39 +2,49 @@
|
||||
All textures by
|
||||
(C) Auke Kok <sofar@foo-projects.org>
|
||||
CC-BY-SA-3.0
|
||||
--]]
|
||||
]]
|
||||
|
||||
-- beans
|
||||
minetest.register_craftitem("farming:beans", {
|
||||
description = "Green Beans",
|
||||
inventory_image = "farming_beans.png",
|
||||
on_use = minetest.item_eat(1),
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
|
||||
if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then
|
||||
return
|
||||
end
|
||||
local nod = minetest.get_node_or_nil(pointed_thing.under)
|
||||
if nod and nod.name == "farming:beanpole" then
|
||||
|
||||
local nodename = minetest.get_node(pointed_thing.under).name
|
||||
|
||||
if nodename == "farming:beanpole" then
|
||||
minetest.set_node(pointed_thing.under, {name="farming:beanpole_1"})
|
||||
else
|
||||
return
|
||||
end
|
||||
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
|
||||
itemstack:take_item()
|
||||
|
||||
-- check for refill
|
||||
if itemstack:get_count() == 0 then
|
||||
|
||||
minetest.after(0.20,
|
||||
farming.refill_plant,
|
||||
placer,
|
||||
"farming:beans",
|
||||
placer:get_wield_index()
|
||||
)
|
||||
end -- END refill
|
||||
end
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
-- Beans can be used for green dye
|
||||
-- beans can be used for green dye
|
||||
minetest.register_craft({
|
||||
output = "dye:green",
|
||||
recipe = {
|
||||
@ -42,8 +52,7 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
-- Beanpole
|
||||
|
||||
-- beanpole
|
||||
minetest.register_node("farming:beanpole", {
|
||||
description = "Bean Pole (place on soil before planting beans)",
|
||||
drawtype = "plantlike",
|
||||
@ -54,36 +63,41 @@ minetest.register_node("farming:beanpole", {
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:beanpole'}, rarity = 1},
|
||||
}
|
||||
},
|
||||
drop = "farming:beanpole",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, attached_node = 1,
|
||||
not_in_creative_inventory = 1
|
||||
},
|
||||
groups = {snappy = 3, flammable = 2, attached_node = 1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
|
||||
if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then
|
||||
return
|
||||
end
|
||||
local nod = minetest.get_node_or_nil(pointed_thing.under)
|
||||
if nod and minetest.get_item_group(nod.name, "soil") < 2 then
|
||||
|
||||
local nodename = minetest.get_node(pointed_thing.under).name
|
||||
|
||||
if minetest.get_item_group(nodename, "soil") < 2 then
|
||||
return
|
||||
end
|
||||
|
||||
local top = {
|
||||
x = pointed_thing.above.x,
|
||||
y = pointed_thing.above.y + 1,
|
||||
z = pointed_thing.above.z
|
||||
}
|
||||
nod = minetest.get_node_or_nil(top)
|
||||
if nod and nod.name ~= "air" then return end
|
||||
|
||||
nodename = minetest.get_node(top).name
|
||||
|
||||
if nodename ~= "air" then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.set_node(pointed_thing.above, {name = "farming:beanpole"})
|
||||
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:take_item()
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
@ -103,9 +117,8 @@ minetest.register_craft({
|
||||
burntime = 10,
|
||||
})
|
||||
|
||||
-- Define Green Bean growth stages
|
||||
|
||||
minetest.register_node("farming:beanpole_1", {
|
||||
-- green bean definition
|
||||
local crop_def = {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_beanpole_1.png"},
|
||||
visual_scale = 1.45,
|
||||
@ -123,101 +136,38 @@ minetest.register_node("farming:beanpole_1", {
|
||||
snappy = 3, flammable = 3, not_in_creative_inventory = 1,
|
||||
attached_node = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
}
|
||||
|
||||
minetest.register_node("farming:beanpole_2", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_beanpole_2.png"},
|
||||
visual_scale = 1.45,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:beanpole'}, rarity = 1},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 1
|
||||
minetest.register_node("farming:beanpole_1", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:beanpole_3", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_beanpole_3.png"},
|
||||
visual_scale = 1.45,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:beanpole'}, rarity = 1},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage2
|
||||
crop_def.tiles = {"farming_beanpole_2.png"}
|
||||
minetest.register_node("farming:beanpole_2", table.copy(crop_def))
|
||||
|
||||
-- stage 3
|
||||
crop_def.tiles = {"farming_beanpole_3.png"}
|
||||
minetest.register_node("farming:beanpole_3", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:beanpole_4", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_beanpole_4.png"},
|
||||
visual_scale = 1.45,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:beanpole'}, rarity = 1},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 4
|
||||
crop_def.tiles = {"farming_beanpole_4.png"}
|
||||
minetest.register_node("farming:beanpole_4", table.copy(crop_def))
|
||||
|
||||
-- Last stage of growth does not have growing group so abm never checks these
|
||||
|
||||
minetest.register_node("farming:beanpole_5", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_beanpole_5.png"},
|
||||
visual_scale = 1.45,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:beanpole'}, rarity = 1},
|
||||
{items = {'farming:beans 3'}, rarity = 1},
|
||||
{items = {'farming:beans 2'}, rarity = 2},
|
||||
{items = {'farming:beans 2'}, rarity = 3},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
-- Wild Green Bean Bush (this is what you find on the map)
|
||||
-- stage 5 (final)
|
||||
crop_def.tiles = {"farming_beanpole_5.png"}
|
||||
crop_def.groups.growing = 0
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:beanpole'}, rarity = 1},
|
||||
{items = {'farming:beans 3'}, rarity = 1},
|
||||
{items = {'farming:beans 2'}, rarity = 2},
|
||||
{items = {'farming:beans 2'}, rarity = 3},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:beanpole_5", table.copy(crop_def))
|
||||
|
||||
-- wild green bean bush (this is what you find on the map)
|
||||
minetest.register_node("farming:beanbush", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_beanbush.png"},
|
||||
@ -239,4 +189,4 @@ minetest.register_node("farming:beanbush", {
|
||||
not_in_creative_inventory=1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
})
|
||||
|
@ -1,6 +1,5 @@
|
||||
|
||||
--= Blueberries
|
||||
|
||||
-- blueberries
|
||||
minetest.register_craftitem("farming:blueberries", {
|
||||
description = "Blueberries",
|
||||
inventory_image = "farming_blueberries.png",
|
||||
@ -10,7 +9,7 @@ minetest.register_craftitem("farming:blueberries", {
|
||||
on_use = minetest.item_eat(1),
|
||||
})
|
||||
|
||||
-- Blueberry Muffin (Thanks to sosogirl123 for muffin image in deviantart.com)
|
||||
-- blueberry muffin (thanks to sosogirl123 @ deviantart.com for muffin image)
|
||||
|
||||
minetest.register_craftitem("farming:muffin_blueberry", {
|
||||
description = "Blueberry Muffin",
|
||||
@ -25,9 +24,8 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
-- Define Blueberry growth stages
|
||||
|
||||
minetest.register_node("farming:blueberry_1", {
|
||||
-- blueberry definition
|
||||
local crop_def = {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_blueberry_1.png"},
|
||||
paramtype = "light",
|
||||
@ -40,64 +38,28 @@ minetest.register_node("farming:blueberry_1", {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
}
|
||||
|
||||
minetest.register_node("farming:blueberry_2", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_blueberry_2.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 1
|
||||
minetest.register_node("farming:blueberry_1", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:blueberry_3", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_blueberry_3.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 2
|
||||
crop_def.tiles = {"farming_blueberry_2.png"}
|
||||
minetest.register_node("farming:blueberry_2", table.copy(crop_def))
|
||||
|
||||
-- Last stage of growth does not have growing group so abm never checks these
|
||||
-- stage 3
|
||||
crop_def.tiles = {"farming_blueberry_3.png"}
|
||||
minetest.register_node("farming:blueberry_3", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:blueberry_4", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_blueberry_4.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:blueberries 2'}, rarity = 1},
|
||||
{items = {'farming:blueberries'}, rarity = 2},
|
||||
{items = {'farming:blueberries'}, rarity = 3},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory=1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 4 (final)
|
||||
crop_def.tiles = {"farming_blueberry_4.png"}
|
||||
crop_def.groups.growing = 0
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:blueberries 2'}, rarity = 1},
|
||||
{items = {'farming:blueberries'}, rarity = 2},
|
||||
{items = {'farming:blueberries'}, rarity = 3},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:blueberry_4", table.copy(crop_def))
|
||||
|
@ -1,7 +1,10 @@
|
||||
|
||||
--= Carrot (Original textures from PixelBox texture pack)
|
||||
-- https://forum.minetest.net/viewtopic.php?id=4990
|
||||
--[[
|
||||
Original textures from PixelBox texture pack
|
||||
https://forum.minetest.net/viewtopic.php?id=4990
|
||||
]]
|
||||
|
||||
-- carrot
|
||||
minetest.register_craftitem("farming:carrot", {
|
||||
description = "Carrot",
|
||||
inventory_image = "farming_carrot.png",
|
||||
@ -11,8 +14,7 @@ minetest.register_craftitem("farming:carrot", {
|
||||
on_use = minetest.item_eat(4),
|
||||
})
|
||||
|
||||
-- Golden Carrot
|
||||
|
||||
-- golden carrot
|
||||
minetest.register_craftitem("farming:carrot_gold", {
|
||||
description = "Golden Carrot",
|
||||
inventory_image = "farming_carrot_gold.png",
|
||||
@ -28,9 +30,8 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
-- Define Carrot growth stages
|
||||
|
||||
minetest.register_node("farming:carrot_1", {
|
||||
-- carrot definition
|
||||
local crop_def = {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_carrot_1.png"},
|
||||
paramtype = "light",
|
||||
@ -43,133 +44,50 @@ minetest.register_node("farming:carrot_1", {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
}
|
||||
|
||||
minetest.register_node("farming:carrot_2", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_carrot_2.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming:carrot_3", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_carrot_3.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 1
|
||||
minetest.register_node("farming:carrot_1", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:carrot_4", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_carrot_4.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 2
|
||||
crop_def.tiles = {"farming_carrot_2.png"}
|
||||
minetest.register_node("farming:carrot_2", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:carrot_5", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_carrot_5.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 3
|
||||
crop_def.tiles = {"farming_carrot_3.png"}
|
||||
minetest.register_node("farming:carrot_3", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:carrot_6", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_carrot_6.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 4
|
||||
crop_def.tiles = {"farming_carrot_4.png"}
|
||||
minetest.register_node("farming:carrot_4", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:carrot_7", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_carrot_7.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:carrot'}, rarity = 1},
|
||||
{items = {'farming:carrot 2'}, rarity = 3},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 5
|
||||
crop_def.tiles = {"farming_carrot_5.png"}
|
||||
minetest.register_node("farming:carrot_5", table.copy(crop_def))
|
||||
|
||||
-- Last stage of growth does not have growing group so abm never checks these
|
||||
-- stage 6
|
||||
crop_def.tiles = {"farming_carrot_6.png"}
|
||||
minetest.register_node("farming:carrot_6", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:carrot_8", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_carrot_8.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:carrot 2'}, rarity = 1},
|
||||
{items = {'farming:carrot 3'}, rarity = 2},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 7
|
||||
crop_def.tiles = {"farming_carrot_7.png"}
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:carrot'}, rarity = 1},
|
||||
{items = {'farming:carrot 2'}, rarity = 3},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:carrot_7", table.copy(crop_def))
|
||||
|
||||
-- stage 8 (final)
|
||||
crop_def.tiles = {"farming_carrot_8.png"}
|
||||
crop_def.groups.growing = 0
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:carrot 2'}, rarity = 1},
|
||||
{items = {'farming:carrot 3'}, rarity = 2},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:carrot_8", table.copy(crop_def))
|
||||
|
@ -1,17 +1,17 @@
|
||||
|
||||
-- Place Cocoa
|
||||
|
||||
-- place cocoa
|
||||
function place_cocoa(itemstack, placer, pointed_thing, plantname)
|
||||
|
||||
local pt = pointed_thing
|
||||
|
||||
-- check if pointing at a node
|
||||
if not pt and pt.type ~= "node" then
|
||||
if not pt or pt.type ~= "node" then
|
||||
return
|
||||
end
|
||||
|
||||
local under = minetest.get_node(pt.under)
|
||||
|
||||
-- return if any of the nodes is not registered
|
||||
-- return if any of the nodes are not registered
|
||||
if not minetest.registered_nodes[under.name] then
|
||||
return
|
||||
end
|
||||
@ -20,26 +20,30 @@ function place_cocoa(itemstack, placer, pointed_thing, plantname)
|
||||
if under.name ~= "default:jungletree" then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
-- add the node and remove 1 item from the itemstack
|
||||
minetest.set_node(pt.above, {name = plantname})
|
||||
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
|
||||
itemstack:take_item()
|
||||
|
||||
-- check for refill
|
||||
if itemstack:get_count() == 0 then
|
||||
|
||||
minetest.after(0.20,
|
||||
farming.refill_plant,
|
||||
placer,
|
||||
"farming:cocoa_beans",
|
||||
placer:get_wield_index()
|
||||
)
|
||||
end -- END refill
|
||||
end
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
|
||||
--= Cocoa
|
||||
|
||||
-- cocoa beans
|
||||
minetest.register_craftitem("farming:cocoa_beans", {
|
||||
description = "Cocoa Beans",
|
||||
inventory_image = "farming_cocoa_beans.png",
|
||||
@ -55,8 +59,7 @@ minetest.register_craft( {
|
||||
}
|
||||
})
|
||||
|
||||
-- Cookie
|
||||
|
||||
-- chocolate cookie
|
||||
minetest.register_craftitem("farming:cookie", {
|
||||
description = "Cookie",
|
||||
inventory_image = "farming_cookie.png",
|
||||
@ -70,8 +73,7 @@ minetest.register_craft( {
|
||||
}
|
||||
})
|
||||
|
||||
-- Bar of Dark Chocolate (Thanks to Ice Pandora for her deviantart.com chocolate tutorial)
|
||||
|
||||
-- bar of dark chocolate (thanks to Ice Pandora for her deviantart.com chocolate tutorial)
|
||||
minetest.register_craftitem("farming:chocolate_dark", {
|
||||
description = "Bar of Dark Chocolate",
|
||||
inventory_image = "farming_chocolate_dark.png",
|
||||
@ -85,9 +87,8 @@ minetest.register_craft( {
|
||||
}
|
||||
})
|
||||
|
||||
-- Define Coffee growth stages
|
||||
|
||||
minetest.register_node("farming:cocoa_1", {
|
||||
-- cocoa definition
|
||||
local crop_def = {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_cocoa_1.png"},
|
||||
paramtype = "light",
|
||||
@ -105,81 +106,64 @@ minetest.register_node("farming:cocoa_1", {
|
||||
snappy = 3, flammable = 2, plant = 1, growing = 1,
|
||||
not_in_creative_inventory=1, leafdecay = 1, leafdecay_drop = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
}
|
||||
|
||||
minetest.register_node("farming:cocoa_2", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_cocoa_2.png"},
|
||||
paramtype = "light",
|
||||
walkable = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:cocoa_beans 1'}, rarity = 1},
|
||||
}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
|
||||
},
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, growing = 1,
|
||||
not_in_creative_inventory=1, leafdecay = 1, leafdecay_drop = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 1
|
||||
minetest.register_node("farming:cocoa_1", table.copy(crop_def))
|
||||
|
||||
-- Last stage of Cocoa growth does not have growing=1 so abm never has to check these
|
||||
-- stage2
|
||||
crop_def.tiles = {"farming_cocoa_2.png"}
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:cocoa_beans 1'}, rarity = 1},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:cocoa_2", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:cocoa_3", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_cocoa_3.png"},
|
||||
paramtype = "light",
|
||||
walkable = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:cocoa_beans 2'}, rarity = 1},
|
||||
{items = {'farming:cocoa_beans 1'}, rarity = 2},
|
||||
}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
|
||||
},
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1,
|
||||
not_in_creative_inventory = 1, leafdecay = 1, leafdecay_drop = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
-- Abm to add random Cocoa Pod to Jungle Tree trunks
|
||||
-- stage 3 (final)
|
||||
crop_def.tiles = {"farming_cocoa_3.png"}
|
||||
crop_def.groups.growing = 0
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:cocoa_beans 2'}, rarity = 1},
|
||||
{items = {'farming:cocoa_beans 1'}, rarity = 2},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:cocoa_3", table.copy(crop_def))
|
||||
|
||||
-- add random cocoa pods to jungle tree trunks
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:jungletree"},
|
||||
neighbors = {"default:jungleleaves", "moretrees:jungletree_leaves_green"},
|
||||
interval = 80,
|
||||
chance = 20,
|
||||
interval = 8,
|
||||
chance = 80,
|
||||
catch_up = false,
|
||||
action = function(pos, node)
|
||||
|
||||
local dir = math.random(1,50)
|
||||
local dir = math.random(1, 50)
|
||||
|
||||
if dir == 1 then pos.x = pos.x + 1
|
||||
elseif dir == 2 then pos.x = pos.x - 1
|
||||
elseif dir == 3 then pos.z = pos.z + 1
|
||||
elseif dir == 4 then pos.z = pos.z -1
|
||||
if dir == 1 then
|
||||
pos.x = pos.x + 1
|
||||
elseif dir == 2 then
|
||||
pos.x = pos.x - 1
|
||||
elseif dir == 3 then
|
||||
pos.z = pos.z + 1
|
||||
elseif dir == 4 then
|
||||
pos.z = pos.z -1
|
||||
else return
|
||||
end
|
||||
|
||||
local nod = minetest.get_node_or_nil(pos)
|
||||
if nod then nod = nod.name else return end
|
||||
|
||||
if nod == "air"
|
||||
local nodename = minetest.get_node(pos).name
|
||||
|
||||
if nodename == "air"
|
||||
and minetest.get_node_light(pos) > 12 then
|
||||
-- print ("COCOA", pos.x, pos.y, pos.z)
|
||||
|
||||
--print ("Cocoa Pod added at " .. minetest.pos_to_string(pos))
|
||||
|
||||
minetest.set_node(pos, {
|
||||
name = "farming:cocoa_"..tostring(math.random(1, 3))
|
||||
name = "farming:cocoa_" .. tostring(math.random(1, 3))
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
})
|
||||
|
@ -1,6 +1,5 @@
|
||||
|
||||
--= Coffee
|
||||
|
||||
-- coffee
|
||||
minetest.register_craftitem("farming:coffee_beans", {
|
||||
description = "Coffee Beans",
|
||||
inventory_image = "farming_coffee_beans.png",
|
||||
@ -9,12 +8,8 @@ minetest.register_craftitem("farming:coffee_beans", {
|
||||
end,
|
||||
})
|
||||
|
||||
--= Glass Cup
|
||||
--minetest.register_craftitem("farming:drinking_cup", {
|
||||
-- description = "Drinking Cup",
|
||||
-- inventory_image = "vessels_drinking_cup.png",
|
||||
--})
|
||||
|
||||
-- drinking cup
|
||||
minetest.register_node("farming:drinking_cup", {
|
||||
description = "Drinking Cup (empty)",
|
||||
drawtype = "plantlike",
|
||||
@ -39,15 +34,9 @@ minetest.register_craft( {
|
||||
}
|
||||
})
|
||||
|
||||
--= Cold Cup of Coffee
|
||||
--minetest.register_craftitem("farming:coffee_cup", {
|
||||
-- description = "Cold Cup of Coffee",
|
||||
-- inventory_image = "farming_coffee_cup.png",
|
||||
-- on_use = minetest.item_eat(2, "farming:drinking_cup"),
|
||||
--})
|
||||
|
||||
-- cold cup of coffee
|
||||
minetest.register_node("farming:coffee_cup", {
|
||||
description = "Cup of Coffee (cold)",
|
||||
description = "Cold Cup of Coffee",
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_coffee_cup.png"},
|
||||
inventory_image = "farming_coffee_cup.png",
|
||||
@ -67,8 +56,6 @@ minetest.register_craft( {
|
||||
output = "farming:coffee_cup",
|
||||
recipe = {
|
||||
{"farming:drinking_cup", "farming:coffee_beans","bucket:bucket_water"},
|
||||
{"","",""},
|
||||
{"","",""}
|
||||
},
|
||||
replacements = {{"bucket:bucket_water", "bucket:bucket_empty"}}
|
||||
})
|
||||
@ -80,15 +67,9 @@ minetest.register_craft({
|
||||
recipe = "farming:coffee_cup"
|
||||
})
|
||||
|
||||
--= Hot Cup of Coffee
|
||||
--minetest.register_craftitem("farming:coffee_cup_hot", {
|
||||
-- description = "Hot Cup of Coffee",
|
||||
-- inventory_image = "farming_coffee_cup_hot.png",
|
||||
-- on_use = minetest.item_eat(3, "farming:drinking_cup"),
|
||||
--})
|
||||
|
||||
-- hot cup of coffee
|
||||
minetest.register_node("farming:coffee_cup_hot", {
|
||||
description = "Cup of Coffee (hot)",
|
||||
description = "Hot Cup of Coffee",
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_coffee_cup_hot.png"},
|
||||
inventory_image = "farming_coffee_cup_hot.png",
|
||||
@ -104,9 +85,8 @@ minetest.register_node("farming:coffee_cup_hot", {
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
})
|
||||
|
||||
-- Define Coffee growth stages
|
||||
|
||||
minetest.register_node("farming:coffee_1", {
|
||||
-- coffee definition
|
||||
local crop_def = {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_coffee_1.png"},
|
||||
paramtype = "light",
|
||||
@ -119,81 +99,32 @@ minetest.register_node("farming:coffee_1", {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
}
|
||||
|
||||
minetest.register_node("farming:coffee_2", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_coffee_2.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 1
|
||||
minetest.register_node("farming:coffee_1", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:coffee_3", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_coffee_3.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 2
|
||||
crop_def.tiles = {"farming_coffee_2.png"}
|
||||
minetest.register_node("farming:coffee_2", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:coffee_4", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_coffee_4.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 3
|
||||
crop_def.tiles = {"farming_coffee_3.png"}
|
||||
minetest.register_node("farming:coffee_3", table.copy(crop_def))
|
||||
|
||||
-- Last stage of growth doesn not have growing group so abm never checks these
|
||||
-- stage 4
|
||||
crop_def.tiles = {"farming_coffee_4.png"}
|
||||
minetest.register_node("farming:coffee_4", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:coffee_5", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_coffee_5.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:coffee_beans 2'}, rarity = 1},
|
||||
{items = {'farming:coffee_beans 2'}, rarity = 2},
|
||||
{items = {'farming:coffee_beans 2'}, rarity = 3},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory=1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 5 (final)
|
||||
crop_def.tiles = {"farming_coffee_5.png"}
|
||||
crop_def.groups.growing = 0
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:coffee_beans 2'}, rarity = 1},
|
||||
{items = {'farming:coffee_beans 2'}, rarity = 2},
|
||||
{items = {'farming:coffee_beans 2'}, rarity = 3},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:coffee_5", table.copy(crop_def))
|
||||
|
@ -94,4 +94,4 @@ minetest.register_alias("farming_plus:tomato_3", "farming:tomato_6")
|
||||
minetest.register_alias("farming_plus:tomato", "farming:tomato_8")
|
||||
|
||||
-- Weed
|
||||
minetest.register_alias("farming:weed", "default:grass_2")
|
||||
minetest.register_alias("farming:weed", "default:grass_2")
|
||||
|
@ -1,7 +1,10 @@
|
||||
|
||||
--= Corn (Original textures from GeMinecraft)
|
||||
-- http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/1440575-1-2-5-generation-minecraft-beta-1-2-farming-and
|
||||
--[[
|
||||
Original textures from GeMinecraft
|
||||
http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/1440575-1-2-5-generation-minecraft-beta-1-2-farming-and
|
||||
]]
|
||||
|
||||
-- corn
|
||||
minetest.register_craftitem("farming:corn", {
|
||||
description = "Corn",
|
||||
inventory_image = "farming_corn.png",
|
||||
@ -11,8 +14,7 @@ minetest.register_craftitem("farming:corn", {
|
||||
on_use = minetest.item_eat(3),
|
||||
})
|
||||
|
||||
--= Corn on the Cob (Texture by TenPlus1)
|
||||
|
||||
-- corn on the cob (texture by TenPlus1)
|
||||
minetest.register_craftitem("farming:corn_cob", {
|
||||
description = "Corn on the Cob",
|
||||
inventory_image = "farming_corn_cob.png",
|
||||
@ -26,8 +28,7 @@ minetest.register_craft({
|
||||
recipe = "farming:corn"
|
||||
})
|
||||
|
||||
--= Ethanol (Thanks to JKMurray for this idea)
|
||||
|
||||
-- ethanol (thanks to JKMurray for this idea)
|
||||
minetest.register_craftitem("farming:bottle_ethanol", {
|
||||
description = "Bottle of Ethanol",
|
||||
inventory_image = "farming_bottle_ethanol.png",
|
||||
@ -48,9 +49,8 @@ minetest.register_craft({
|
||||
replacements = {{ "farming:bottle_ethanol", "vessels:glass_bottle"}}
|
||||
})
|
||||
|
||||
-- Define Corn growth stages
|
||||
|
||||
minetest.register_node("farming:corn_1", {
|
||||
-- corn definition
|
||||
local crop_def = {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_corn_1.png"},
|
||||
paramtype = "light",
|
||||
@ -63,138 +63,52 @@ minetest.register_node("farming:corn_1", {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
}
|
||||
|
||||
minetest.register_node("farming:corn_2", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_corn_2.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 1
|
||||
minetest.register_node("farming:corn_1", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:corn_3", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_corn_3.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 2
|
||||
crop_def.tiles = {"farming_corn_2.png"}
|
||||
minetest.register_node("farming:corn_2", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:corn_4", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_corn_4.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 3
|
||||
crop_def.tiles = {"farming_corn_3.png"}
|
||||
minetest.register_node("farming:corn_3", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:corn_5", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_corn_5.png"},
|
||||
paramtype = "light",
|
||||
waving = 1,
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 4
|
||||
crop_def.tiles = {"farming_corn_4.png"}
|
||||
minetest.register_node("farming:corn_4", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:corn_6", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_corn_6.png"},
|
||||
visual_scale = 1.45,
|
||||
paramtype = "light",
|
||||
waving = 1,
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 5
|
||||
crop_def.tiles = {"farming_corn_5.png"}
|
||||
minetest.register_node("farming:corn_5", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:corn_7", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_corn_7.png"},
|
||||
visual_scale = 1.45,
|
||||
paramtype = "light",
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:corn'}, rarity = 1},
|
||||
{items = {'farming:corn'}, rarity = 2},
|
||||
{items = {'farming:corn'}, rarity = 3},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 6
|
||||
crop_def.tiles = {"farming_corn_6.png"}
|
||||
crop_def.visual_scale = 1.45
|
||||
minetest.register_node("farming:corn_6", table.copy(crop_def))
|
||||
|
||||
-- Last stage of growth doesn not have growing group so abm never checks these
|
||||
-- stage 7
|
||||
crop_def.tiles = {"farming_corn_7.png"}
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:corn'}, rarity = 1},
|
||||
{items = {'farming:corn'}, rarity = 2},
|
||||
{items = {'farming:corn'}, rarity = 3},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:corn_7", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:corn_8", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_corn_8.png"},
|
||||
visual_scale = 1.45,
|
||||
paramtype = "light",
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:corn 2'}, rarity = 1},
|
||||
{items = {'farming:corn 2'}, rarity = 2},
|
||||
{items = {'farming:corn 2'}, rarity = 2},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 8 (final)
|
||||
crop_def.tiles = {"farming_corn_8.png"}
|
||||
crop_def.groups.growing = 0
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:corn 2'}, rarity = 1},
|
||||
{items = {'farming:corn 2'}, rarity = 2},
|
||||
{items = {'farming:corn 2'}, rarity = 2},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:corn_8", table.copy(crop_def))
|
||||
|
@ -1,13 +1,5 @@
|
||||
-- Cotton Seed
|
||||
|
||||
--minetest.register_craftitem("farming:seed_cotton", {
|
||||
-- description = "Cotton Seed",
|
||||
-- inventory_image = "farming_cotton_seed.png",
|
||||
-- on_place = function(itemstack, placer, pointed_thing)
|
||||
-- return farming.place_seed(itemstack, placer, pointed_thing, "farming:cotton_1")
|
||||
-- end,
|
||||
--})
|
||||
|
||||
-- cotton seeds
|
||||
minetest.register_node("farming:seed_cotton", {
|
||||
description = "Cotton Seed",
|
||||
tiles = {"farming_cotton_seed.png"},
|
||||
@ -25,7 +17,7 @@ minetest.register_node("farming:seed_cotton", {
|
||||
end,
|
||||
})
|
||||
|
||||
-- Cotton
|
||||
-- cotton / string
|
||||
|
||||
minetest.register_craftitem("farming:cotton", {
|
||||
description = "Cotton",
|
||||
@ -34,8 +26,7 @@ minetest.register_craftitem("farming:cotton", {
|
||||
|
||||
minetest.register_alias("farming:string", "farming:cotton")
|
||||
|
||||
-- String to Wool
|
||||
|
||||
-- cotton to wool
|
||||
minetest.register_craft({
|
||||
output = "wool:white",
|
||||
recipe = {
|
||||
@ -44,9 +35,8 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
-- Define Cotton growth stages
|
||||
|
||||
minetest.register_node("farming:cotton_1", {
|
||||
-- cotton definition
|
||||
local crop_def = {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_cotton_1.png"},
|
||||
paramtype = "light",
|
||||
@ -59,147 +49,66 @@ minetest.register_node("farming:cotton_1", {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
}
|
||||
|
||||
minetest.register_node("farming:cotton_2", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_cotton_2.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 1
|
||||
minetest.register_node("farming:cotton_1", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:cotton_3", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_cotton_3.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 2
|
||||
crop_def.tiles = {"farming_cotton_2.png"}
|
||||
minetest.register_node("farming:cotton_2", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:cotton_4", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_cotton_4.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 3
|
||||
crop_def.tiles = {"farming_cotton_3.png"}
|
||||
minetest.register_node("farming:cotton_3", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:cotton_5", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_cotton_5.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {"farming:seed_cotton"}, rarity = 1},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 4
|
||||
crop_def.tiles = {"farming_cotton_4.png"}
|
||||
minetest.register_node("farming:cotton_4", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:cotton_6", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_cotton_6.png"},
|
||||
paramtype = "light",
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {"farming:cotton"}, rarity = 1},
|
||||
{items = {"farming:cotton"}, rarity = 2},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 5
|
||||
crop_def.tiles = {"farming_cotton_5.png"}
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {"farming:seed_cotton"}, rarity = 1},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:cotton_5", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:cotton_7", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_cotton_7.png"},
|
||||
paramtype = "light",
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {"farming:cotton"}, rarity = 1},
|
||||
{items = {"farming:cotton"}, rarity = 2},
|
||||
{items = {"farming:seed_cotton"}, rarity = 1},
|
||||
{items = {"farming:seed_cotton"}, rarity = 2},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 6
|
||||
crop_def.tiles = {"farming_cotton_6.png"}
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {"farming:cotton"}, rarity = 1},
|
||||
{items = {"farming:cotton"}, rarity = 2},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:cotton_6", table.copy(crop_def))
|
||||
|
||||
-- Last stage of growth does not have growing group so abm never checks these
|
||||
-- stage 7
|
||||
crop_def.tiles = {"farming_cotton_7.png"}
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {"farming:cotton"}, rarity = 1},
|
||||
{items = {"farming:cotton"}, rarity = 2},
|
||||
{items = {"farming:seed_cotton"}, rarity = 1},
|
||||
{items = {"farming:seed_cotton"}, rarity = 2},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:cotton_7", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:cotton_8", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_cotton_8.png"},
|
||||
paramtype = "light",
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {"farming:string"}, rarity = 1},
|
||||
{items = {"farming:string"}, rarity = 2},
|
||||
{items = {"farming:string"}, rarity = 3},
|
||||
{items = {"farming:seed_cotton"}, rarity = 1},
|
||||
{items = {"farming:seed_cotton"}, rarity = 2},
|
||||
{items = {"farming:seed_cotton"}, rarity = 3},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 8 (final)
|
||||
crop_def.tiles = {"farming_cotton_8.png"}
|
||||
crop_def.groups.growing = 0
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {"farming:string"}, rarity = 1},
|
||||
{items = {"farming:string"}, rarity = 2},
|
||||
{items = {"farming:string"}, rarity = 3},
|
||||
{items = {"farming:seed_cotton"}, rarity = 1},
|
||||
{items = {"farming:seed_cotton"}, rarity = 2},
|
||||
{items = {"farming:seed_cotton"}, rarity = 3},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:cotton_8", table.copy(crop_def))
|
||||
|
@ -1,7 +1,10 @@
|
||||
|
||||
--= Cucumber (Original textures from DocFarming mod)
|
||||
-- https://forum.minetest.net/viewtopic.php?id=3948
|
||||
--[[
|
||||
Original textures from DocFarming mod
|
||||
https://forum.minetest.net/viewtopic.php?id=3948
|
||||
]]
|
||||
|
||||
-- cucumber
|
||||
minetest.register_craftitem("farming:cucumber", {
|
||||
description = "Cucumber",
|
||||
inventory_image = "farming_cucumber.png",
|
||||
@ -11,9 +14,8 @@ minetest.register_craftitem("farming:cucumber", {
|
||||
on_use = minetest.item_eat(4),
|
||||
})
|
||||
|
||||
-- Define Cucumber growth stages
|
||||
|
||||
minetest.register_node("farming:cucumber_1", {
|
||||
-- cucumber definition
|
||||
local crop_def = {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_cucumber_1.png"},
|
||||
paramtype = "light",
|
||||
@ -25,60 +27,27 @@ minetest.register_node("farming:cucumber_1", {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
}
|
||||
|
||||
minetest.register_node("farming:cucumber_2", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_cucumber_2.png"},
|
||||
paramtype = "light",
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 1
|
||||
minetest.register_node("farming:cucumber_1", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:cucumber_3", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_cucumber_3.png"},
|
||||
paramtype = "light",
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 2
|
||||
crop_def.tiles = {"farming_cucumber_2.png"}
|
||||
minetest.register_node("farming:cucumber_2", table.copy(crop_def))
|
||||
|
||||
-- Last stage of growth does not have growing group so abm never checks these
|
||||
-- stage 3
|
||||
crop_def.tiles = {"farming_cucumber_3.png"}
|
||||
minetest.register_node("farming:cucumber_3", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:cucumber_4", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_cucumber_4.png"},
|
||||
paramtype = "light",
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:cucumber'}, rarity = 1},
|
||||
{items = {'farming:cucumber 2'}, rarity = 2},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 4 (final)
|
||||
crop_def.tiles = {"farming_cucumber_4.png"}
|
||||
crop_def.groups.growing = 0
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:cucumber'}, rarity = 1},
|
||||
{items = {'farming:cucumber 2'}, rarity = 2},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:cucumber_4", table.copy(crop_def))
|
||||
|
@ -1,2 +1,2 @@
|
||||
default
|
||||
wool
|
||||
wool
|
@ -1,36 +1,45 @@
|
||||
-- Grapes
|
||||
|
||||
-- grapes
|
||||
minetest.register_craftitem("farming:grapes", {
|
||||
description = "Grapes",
|
||||
inventory_image = "farming_grapes.png",
|
||||
on_use = minetest.item_eat(2),
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
|
||||
if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then
|
||||
return
|
||||
end
|
||||
local nod = minetest.get_node_or_nil(pointed_thing.under)
|
||||
if nod and nod.name == "farming:trellis" then
|
||||
|
||||
local nodename = minetest.get_node(pointed_thing.under).name
|
||||
|
||||
if nodename == "farming:trellis" then
|
||||
minetest.set_node(pointed_thing.under, {name="farming:grapes_1"})
|
||||
else
|
||||
return
|
||||
end
|
||||
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
|
||||
itemstack:take_item()
|
||||
|
||||
-- check for refill
|
||||
if itemstack:get_count() == 0 then
|
||||
|
||||
minetest.after(0.20,
|
||||
farming.refill_plant,
|
||||
placer,
|
||||
"farming:grapes",
|
||||
placer:get_wield_index()
|
||||
)
|
||||
end -- END refill
|
||||
end
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
-- Grapes can be used for violet dye
|
||||
-- grapes can be used for violet dye
|
||||
minetest.register_craft({
|
||||
output = "dye:violet",
|
||||
recipe = {
|
||||
@ -38,8 +47,7 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
-- Trellis
|
||||
|
||||
-- trellis
|
||||
minetest.register_node("farming:trellis", {
|
||||
description = "Trellis (place on soil before planting grapes)",
|
||||
drawtype = "plantlike",
|
||||
@ -50,36 +58,41 @@ minetest.register_node("farming:trellis", {
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:trellis'}, rarity = 1},
|
||||
}
|
||||
},
|
||||
drop = "farming:trellis",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, attached_node = 1,
|
||||
not_in_creative_inventory = 1
|
||||
},
|
||||
groups = {snappy = 3, flammable = 2, attached_node = 1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
|
||||
if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then
|
||||
return
|
||||
end
|
||||
local nod = minetest.get_node_or_nil(pointed_thing.under)
|
||||
if nod and minetest.get_item_group(nod.name, "soil") < 2 then
|
||||
|
||||
local nodename = minetest.get_node(pointed_thing.under).name
|
||||
|
||||
if minetest.get_item_group(nodename, "soil") < 2 then
|
||||
return
|
||||
end
|
||||
|
||||
local top = {
|
||||
x = pointed_thing.above.x,
|
||||
y = pointed_thing.above.y + 1,
|
||||
z = pointed_thing.above.z
|
||||
}
|
||||
nod = minetest.get_node_or_nil(top)
|
||||
if nod and nod.name ~= "air" then return end
|
||||
|
||||
nodename = minetest.get_node(top).name
|
||||
|
||||
if nodename ~= "air" then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.set_node(pointed_thing.above, {name = "farming:trellis"})
|
||||
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:take_item()
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
@ -99,9 +112,8 @@ minetest.register_craft({
|
||||
burntime = 15,
|
||||
})
|
||||
|
||||
-- Define Grapes growth stages
|
||||
|
||||
minetest.register_node("farming:grapes_1", {
|
||||
-- grapes definition
|
||||
local crop_def = {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_grapes_1.png"},
|
||||
visual_scale = 1.45,
|
||||
@ -119,163 +131,50 @@ minetest.register_node("farming:grapes_1", {
|
||||
snappy = 3, flammable = 3, not_in_creative_inventory = 1,
|
||||
attached_node = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
}
|
||||
|
||||
minetest.register_node("farming:grapes_2", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_grapes_2.png"},
|
||||
visual_scale = 1.45,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:trellis'}, rarity = 1},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 1
|
||||
minetest.register_node("farming:grapes_1", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:grapes_3", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_grapes_3.png"},
|
||||
visual_scale = 1.45,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:trellis'}, rarity = 1},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage2
|
||||
crop_def.tiles = {"farming_grapes_2.png"}
|
||||
minetest.register_node("farming:grapes_2", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:grapes_4", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_grapes_4.png"},
|
||||
visual_scale = 1.45,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:trellis'}, rarity = 1},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 3
|
||||
crop_def.tiles = {"farming_grapes_3.png"}
|
||||
minetest.register_node("farming:grapes_3", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:grapes_5", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_grapes_5.png"},
|
||||
visual_scale = 1.45,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:trellis'}, rarity = 1},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 4
|
||||
crop_def.tiles = {"farming_grapes_4.png"}
|
||||
minetest.register_node("farming:grapes_4", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:grapes_6", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_grapes_6.png"},
|
||||
visual_scale = 1.45,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:trellis'}, rarity = 1},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 5
|
||||
crop_def.tiles = {"farming_grapes_5.png"}
|
||||
minetest.register_node("farming:grapes_5", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:grapes_7", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_grapes_7.png"},
|
||||
visual_scale = 1.45,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:trellis'}, rarity = 1},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 6
|
||||
crop_def.tiles = {"farming_grapes_6.png"}
|
||||
minetest.register_node("farming:grapes_6", table.copy(crop_def))
|
||||
|
||||
-- Last stage of growth does not have growing group so abm never checks these
|
||||
-- stage 7
|
||||
crop_def.tiles = {"farming_grapes_7.png"}
|
||||
minetest.register_node("farming:grapes_7", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:grapes_8", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_grapes_8.png"},
|
||||
visual_scale = 1.45,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:trellis'}, rarity = 1},
|
||||
{items = {'farming:grapes 3'}, rarity = 1},
|
||||
{items = {'farming:grapes 1'}, rarity = 2},
|
||||
{items = {'farming:grapes 1'}, rarity = 3},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
-- Wild Grape Vine (this is what you find on the map)
|
||||
-- stage 8 (final)
|
||||
crop_def.tiles = {"farming_grapes_8.png"}
|
||||
crop_def.groups.growing = 0
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:trellis'}, rarity = 1},
|
||||
{items = {'farming:grapes 3'}, rarity = 1},
|
||||
{items = {'farming:grapes 1'}, rarity = 2},
|
||||
{items = {'farming:grapes 1'}, rarity = 3},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:grapes_8", table.copy(crop_def))
|
||||
|
||||
-- wild grape vine (this is what you find on the map)
|
||||
minetest.register_node("farming:grapebush", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_grapebush.png"},
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
-- Override default grass and have it drop Wheat Seeds
|
||||
for i = 3, 5 do
|
||||
|
||||
for i = 1, 5 do
|
||||
-- Override default grass and have it drop Wheat Seeds
|
||||
|
||||
minetest.override_item("default:grass_" .. i, {
|
||||
drop = {
|
||||
@ -13,6 +13,20 @@ for i = 1, 5 do
|
||||
},
|
||||
})
|
||||
|
||||
-- Override default dry grass and have it drop Barley Seeds
|
||||
if minetest.registered_nodes["default:dry_grass_1"] then
|
||||
|
||||
minetest.override_item("default:dry_grass_" .. i, {
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{items = {'farming:seed_barley'}, rarity = 6},
|
||||
{items = {'default:dry_grass_1'}},
|
||||
}
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Override default Jungle Grass and have it drop Cotton Seeds
|
||||
@ -25,4 +39,4 @@ minetest.override_item("default:junglegrass", {
|
||||
{items = {'default:junglegrass'}},
|
||||
}
|
||||
},
|
||||
})
|
||||
})
|
||||
|
@ -2,17 +2,21 @@
|
||||
-- Hoe registration function
|
||||
|
||||
farming.register_hoe = function(name, def)
|
||||
|
||||
-- Check for : prefix (register new hoes in your mod's namespace)
|
||||
if name:sub(1,1) ~= ":" then
|
||||
name = ":" .. name
|
||||
end
|
||||
|
||||
-- Check def table
|
||||
if def.description == nil then
|
||||
def.description = "Hoe"
|
||||
end
|
||||
|
||||
if def.inventory_image == nil then
|
||||
def.inventory_image = "unknown_item.png"
|
||||
end
|
||||
|
||||
if def.recipe == nil then
|
||||
def.recipe = {
|
||||
{"air","air",""},
|
||||
@ -20,9 +24,11 @@ farming.register_hoe = function(name, def)
|
||||
{"","group:stick",""}
|
||||
}
|
||||
end
|
||||
|
||||
if def.max_uses == nil then
|
||||
def.max_uses = 30
|
||||
end
|
||||
|
||||
-- Register the tool
|
||||
minetest.register_tool(name, {
|
||||
description = def.description,
|
||||
@ -31,6 +37,7 @@ farming.register_hoe = function(name, def)
|
||||
return farming.hoe_on_use(itemstack, user, pointed_thing, def.max_uses)
|
||||
end
|
||||
})
|
||||
|
||||
-- Register its recipe
|
||||
if def.material == nil then
|
||||
minetest.register_craft({
|
||||
@ -52,7 +59,9 @@ end
|
||||
-- Turns dirt with group soil=1 into soil
|
||||
|
||||
function farming.hoe_on_use(itemstack, user, pointed_thing, uses)
|
||||
|
||||
local pt = pointed_thing
|
||||
|
||||
-- check if pointing at a node
|
||||
if not pt or pt.type ~= "node" then
|
||||
return
|
||||
@ -87,10 +96,13 @@ function farming.hoe_on_use(itemstack, user, pointed_thing, uses)
|
||||
|
||||
-- turn the node into soil, wear out item and play sound
|
||||
minetest.set_node(pt.under, {name = "farming:soil"})
|
||||
|
||||
minetest.sound_play("default_dig_crumbly", {pos = pt.under, gain = 0.5})
|
||||
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/(uses-1))
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
|
||||
@ -136,4 +148,4 @@ farming.register_hoe(":farming:hoe_diamond", {
|
||||
inventory_image = "farming_tool_diamondhoe.png",
|
||||
max_uses = 500,
|
||||
material = "default:diamond"
|
||||
})
|
||||
})
|
||||
|
@ -1,5 +1,5 @@
|
||||
--[[
|
||||
Minetest Farming Redo Mod 1.22 (26th October 2015)
|
||||
Minetest Farming Redo Mod 1.22 (10th March 2016)
|
||||
by TenPlus1
|
||||
NEW growing routine by prestidigitator
|
||||
auto-refill by crabman77
|
||||
@ -21,7 +21,9 @@ local DEBUG_abm_runs = 0
|
||||
local DEBUG_abm_time = 0
|
||||
local DEBUG_timer_runs = 0
|
||||
local DEBUG_timer_time = 0
|
||||
|
||||
if farming.DEBUG then
|
||||
|
||||
function farming.DEBUG.reset_times()
|
||||
DEBUG_abm_runs = 0
|
||||
DEBUG_abm_time = 0
|
||||
@ -30,6 +32,7 @@ if farming.DEBUG then
|
||||
end
|
||||
|
||||
function farming.DEBUG.report_times()
|
||||
|
||||
local abm_n = DEBUG_abm_runs
|
||||
local abm_dt = DEBUG_abm_time
|
||||
local abm_avg = (abm_n > 0 and abm_dt / abm_n) or 0
|
||||
@ -37,15 +40,15 @@ if farming.DEBUG then
|
||||
local timer_dt = DEBUG_timer_time
|
||||
local timer_avg = (timer_n > 0 and timer_dt / timer_n) or 0
|
||||
local dt = abm_dt + timer_dt
|
||||
print("ABM ran for "..abm_dt.."µs over "..abm_n.." runs: "..
|
||||
abm_avg.."µs/run")
|
||||
print("Timer ran for "..timer_dt.."µs over "..timer_n.." runs: "..
|
||||
timer_avg.."µs/run")
|
||||
|
||||
print("ABM ran for "..abm_dt.."µs over "..abm_n.." runs: "..abm_avg.."µs/run")
|
||||
print("Timer ran for "..timer_dt.."µs over "..timer_n.." runs: "..timer_avg.."µs/run")
|
||||
print("Total farming time: "..dt.."µs")
|
||||
end
|
||||
end
|
||||
|
||||
local statistics = dofile(farming.path.."/statistics.lua")
|
||||
|
||||
dofile(farming.path.."/soil.lua")
|
||||
dofile(farming.path.."/hoes.lua")
|
||||
dofile(farming.path.."/grass.lua")
|
||||
@ -66,6 +69,7 @@ dofile(farming.path.."/blueberry.lua")
|
||||
dofile(farming.path.."/rhubarb.lua")
|
||||
dofile(farming.path.."/beanpole.lua")
|
||||
dofile(farming.path.."/grapes.lua")
|
||||
dofile(farming.path.."/barley.lua")
|
||||
dofile(farming.path.."/donut.lua")
|
||||
dofile(farming.path.."/mapgen.lua")
|
||||
dofile(farming.path.."/compatibility.lua") -- Farming Plus compatibility
|
||||
@ -73,7 +77,7 @@ dofile(farming.path.."/compatibility.lua") -- Farming Plus compatibility
|
||||
-- Utility Functions
|
||||
|
||||
local time_speed = tonumber(minetest.setting_get("time_speed")) or 72
|
||||
local SECS_PER_CYCLE = (time_speed > 0 and 24 * 60 * 60 / time_speed) or 0 --nil
|
||||
local SECS_PER_CYCLE = (time_speed > 0 and 24 * 60 * 60 / time_speed) or 0
|
||||
|
||||
local function clamp(x, min, max)
|
||||
return (x < min and min) or (x > max and max) or x
|
||||
@ -95,12 +99,14 @@ end
|
||||
-- If true, count elapsed day time. Otherwise, count elapsed night time.
|
||||
-- @return
|
||||
-- The amount of day or night time that has elapsed.
|
||||
--
|
||||
local function day_or_night_time(t_game, t_day, dt, count_day)
|
||||
local t1_day = t_day - dt / SECS_PER_CYCLE
|
||||
|
||||
local function day_or_night_time(t_game, t_day, dt, count_day)
|
||||
|
||||
local t1_day = t_day - dt / SECS_PER_CYCLE
|
||||
local t1_c, t2_c -- t1_c < t2_c and t2_c always in [0, 1)
|
||||
|
||||
if count_day then
|
||||
|
||||
if t_day < 0.25 then
|
||||
t1_c = t1_day + 0.75 -- Relative to sunup, yesterday
|
||||
t2_c = t_day + 0.75
|
||||
@ -119,6 +125,7 @@ local function day_or_night_time(t_game, t_day, dt, count_day)
|
||||
end
|
||||
|
||||
local dt_c = clamp(t2_c, 0, 0.5) - clamp(t1_c, 0, 0.5) -- this cycle
|
||||
|
||||
if t1_c < -0.5 then
|
||||
local nc = math.floor(-t1_c)
|
||||
t1_c = t1_c + nc
|
||||
@ -166,12 +173,15 @@ local MAX_LIGHT = 1000
|
||||
-- Node or position table, or node name.
|
||||
-- @return
|
||||
-- List (plant_name, stage), or nothing (nil) if node isn't loaded
|
||||
--
|
||||
|
||||
local function plant_name_stage(node)
|
||||
|
||||
local name
|
||||
|
||||
if type(node) == 'table' then
|
||||
|
||||
if node.name then
|
||||
name = node.name
|
||||
name = node.name
|
||||
elseif node.x and node.y and node.z then
|
||||
node = minetest.get_node_or_nil(node)
|
||||
name = node and node.name
|
||||
@ -179,11 +189,17 @@ local function plant_name_stage(node)
|
||||
else
|
||||
name = tostring(node)
|
||||
end
|
||||
if not name or name == "ignore" then return nil end
|
||||
|
||||
if not name or name == "ignore" then
|
||||
return nil
|
||||
end
|
||||
|
||||
local sep_pos = name:find("_[^_]+$")
|
||||
|
||||
if sep_pos and sep_pos > 1 then
|
||||
|
||||
local stage = tonumber(name:sub(sep_pos + 1))
|
||||
|
||||
if stage and stage >= 0 then
|
||||
return name:sub(1, sep_pos - 1), stage
|
||||
end
|
||||
@ -192,9 +208,11 @@ local function plant_name_stage(node)
|
||||
return name, 0
|
||||
end
|
||||
|
||||
--- Map from node name to
|
||||
-- { plant_name = ..., name = ..., stage = n, stages_left = { node_name, ... } }
|
||||
-- Map from node name to
|
||||
-- { plant_name = ..., name = ..., stage = n, stages_left = { node_name, ... } }
|
||||
|
||||
local plant_stages = {}
|
||||
|
||||
farming.plant_stages = plant_stages
|
||||
|
||||
--- Registers the stages of growth of a (possible plant) node.
|
||||
@ -204,21 +222,30 @@ farming.plant_stages = plant_stages
|
||||
-- @return
|
||||
-- The (possibly zero) number of stages of growth the plant will go through
|
||||
-- before being fully grown, or nil if not a plant.
|
||||
--
|
||||
|
||||
local register_plant_node
|
||||
|
||||
-- Recursive helper
|
||||
local function reg_plant_stages(plant_name, stage, force_last)
|
||||
|
||||
local node_name = plant_name and plant_name .. "_" .. stage
|
||||
local node_def = node_name and minetest.registered_nodes[node_name]
|
||||
if not node_def then return nil end
|
||||
|
||||
if not node_def then
|
||||
return nil
|
||||
end
|
||||
|
||||
local stages = plant_stages[node_name]
|
||||
if stages then return stages end
|
||||
|
||||
if stages then
|
||||
return stages
|
||||
end
|
||||
|
||||
if minetest.get_item_group(node_name, "growing") > 0 then
|
||||
local ns = reg_plant_stages(plant_name, stage + 1, true)
|
||||
|
||||
local ns = reg_plant_stages(plant_name, stage + 1, true)
|
||||
local stages_left = (ns and { ns.name, unpack(ns.stages_left) }) or {}
|
||||
|
||||
stages = {
|
||||
plant_name = plant_name,
|
||||
name = node_name,
|
||||
@ -227,18 +254,28 @@ local function reg_plant_stages(plant_name, stage, force_last)
|
||||
}
|
||||
|
||||
if #stages_left > 0 then
|
||||
|
||||
local old_constr = node_def.on_construct
|
||||
local old_destr = node_def.on_destruct
|
||||
|
||||
minetest.override_item(node_name,
|
||||
{
|
||||
on_construct = function(pos)
|
||||
if old_constr then old_constr(pos) end
|
||||
|
||||
if old_constr then
|
||||
old_constr(pos)
|
||||
end
|
||||
|
||||
farming.handle_growth(pos)
|
||||
end,
|
||||
|
||||
on_destruct = function(pos)
|
||||
|
||||
minetest.get_node_timer(pos):stop()
|
||||
if old_destr then old_destr(pos) end
|
||||
|
||||
if old_destr then
|
||||
old_destr(pos)
|
||||
end
|
||||
end,
|
||||
|
||||
on_timer = function(pos, elapsed)
|
||||
@ -246,7 +283,9 @@ local function reg_plant_stages(plant_name, stage, force_last)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
elseif force_last then
|
||||
|
||||
stages = {
|
||||
plant_name = plant_name,
|
||||
name = node_name,
|
||||
@ -258,12 +297,16 @@ local function reg_plant_stages(plant_name, stage, force_last)
|
||||
end
|
||||
|
||||
plant_stages[node_name] = stages
|
||||
|
||||
return stages
|
||||
end
|
||||
|
||||
register_plant_node = function(node)
|
||||
|
||||
local plant_name, stage = plant_name_stage(node)
|
||||
|
||||
if plant_name then
|
||||
|
||||
local stages = reg_plant_stages(plant_name, stage, false)
|
||||
return stages and #stages.stages_left
|
||||
else
|
||||
@ -272,150 +315,222 @@ register_plant_node = function(node)
|
||||
end
|
||||
|
||||
local function set_growing(pos, stages_left)
|
||||
if not stages_left then return end
|
||||
|
||||
if not stages_left then
|
||||
return
|
||||
end
|
||||
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
|
||||
if stages_left > 0 then
|
||||
|
||||
if not timer:is_started() then
|
||||
|
||||
local stage_length = statistics.normal(STAGE_LENGTH_AVG, STAGE_LENGTH_DEV)
|
||||
|
||||
stage_length = clamp(stage_length, 0.5 * STAGE_LENGTH_AVG, 3.0 * STAGE_LENGTH_AVG)
|
||||
|
||||
timer:set(stage_length, -0.5 * math.random() * STAGE_LENGTH_AVG)
|
||||
end
|
||||
|
||||
elseif timer:is_started() then
|
||||
timer:stop()
|
||||
end
|
||||
end
|
||||
|
||||
--- Detects a plant type node at the given position, starting or stopping the plant growth timer as appopriate
|
||||
--
|
||||
-- @param pos
|
||||
-- The node's position.
|
||||
-- @param node
|
||||
-- The cached node table if available, or nil.
|
||||
--
|
||||
-- Detects a plant type node at the given position, starting
|
||||
-- or stopping the plant growth timer as appopriate
|
||||
|
||||
-- @param pos
|
||||
-- The node's position.
|
||||
-- @param node
|
||||
-- The cached node table if available, or nil.
|
||||
|
||||
function farming.handle_growth(pos, node)
|
||||
if not pos then return end
|
||||
|
||||
if not pos then
|
||||
return
|
||||
end
|
||||
|
||||
local stages_left = register_plant_node(node or pos)
|
||||
if stages_left then set_growing(pos, stages_left) end
|
||||
|
||||
if stages_left then
|
||||
set_growing(pos, stages_left)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.after(0,
|
||||
function()
|
||||
for _, node_def in pairs(minetest.registered_nodes) do
|
||||
register_plant_node(node_def)
|
||||
end
|
||||
end)
|
||||
minetest.after(0, function()
|
||||
|
||||
for _, node_def in pairs(minetest.registered_nodes) do
|
||||
register_plant_node(node_def)
|
||||
end
|
||||
end)
|
||||
|
||||
local abm_func = farming.handle_growth
|
||||
|
||||
if farming.DEBUG then
|
||||
|
||||
local normal_abm_func = abm_func
|
||||
|
||||
abm_func = function(...)
|
||||
|
||||
local t0 = minetest.get_us_time()
|
||||
local r = { normal_abm_func(...) }
|
||||
local t1 = minetest.get_us_time()
|
||||
|
||||
DEBUG_abm_runs = DEBUG_abm_runs + 1
|
||||
DEBUG_abm_time = DEBUG_abm_time + (t1 - t0)
|
||||
|
||||
return unpack(r)
|
||||
end
|
||||
end
|
||||
|
||||
-- Just in case a growing type or added node is missed (also catches existing
|
||||
-- nodes added to map before timers were incorporated).
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = { "group:growing" },
|
||||
interval = 300,
|
||||
chance = 1,
|
||||
action = abm_func})
|
||||
interval = 300,
|
||||
chance = 1,
|
||||
action = abm_func
|
||||
})
|
||||
|
||||
-- Plant timer function.
|
||||
-- Grows plants under the right conditions.
|
||||
|
||||
--- Plant timer function.
|
||||
--
|
||||
-- Grows plants under the right conditions.
|
||||
--
|
||||
function farming.plant_growth_timer(pos, elapsed, node_name)
|
||||
|
||||
local stages = plant_stages[node_name]
|
||||
if not stages then return false end
|
||||
|
||||
if not stages then
|
||||
return false
|
||||
end
|
||||
|
||||
local max_growth = #stages.stages_left
|
||||
if max_growth <= 0 then return false end
|
||||
|
||||
if max_growth <= 0 then
|
||||
return false
|
||||
end
|
||||
|
||||
if stages.plant_name == "farming:cocoa" then
|
||||
if not minetest.find_node_near(pos, 1, { "default:jungletree", "moretrees:jungletree_leaves_green" }) then
|
||||
|
||||
if not minetest.find_node_near(pos, 1,
|
||||
{"default:jungletree", "moretrees:jungletree_leaves_green"}) then
|
||||
|
||||
return true
|
||||
end
|
||||
else
|
||||
local under = minetest.get_node_or_nil({ x = pos.x, y = pos.y - 1, z = pos.z })
|
||||
if not under or under.name ~= "farming:soil_wet" then return true end
|
||||
|
||||
if not under or under.name ~= "farming:soil_wet" then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
local growth
|
||||
|
||||
local light_pos = { x = pos.x, y = pos.y, z = pos.z }
|
||||
local light_pos = {x = pos.x, y = pos.y, z = pos.z}
|
||||
local lambda = elapsed / STAGE_LENGTH_AVG
|
||||
if lambda < 0.1 then return true end
|
||||
|
||||
if lambda < 0.1 then
|
||||
return true
|
||||
end
|
||||
|
||||
if max_growth == 1 or lambda < 2.0 then
|
||||
local light = (minetest.get_node_light(light_pos) or 0) -- CHANGED
|
||||
|
||||
local light = (minetest.get_node_light(light_pos) or 0)
|
||||
--print ("light level:", light)
|
||||
if not in_range(light, MIN_LIGHT, MAX_LIGHT) then return true end
|
||||
|
||||
if not in_range(light, MIN_LIGHT, MAX_LIGHT) then
|
||||
return true
|
||||
end
|
||||
|
||||
growth = 1
|
||||
else
|
||||
local night_light = (minetest.get_node_light(light_pos, 0) or 0) -- CHANGED
|
||||
local day_light = (minetest.get_node_light(light_pos, 0.5) or 0) -- ChANGED
|
||||
local night_light = (minetest.get_node_light(light_pos, 0) or 0)
|
||||
local day_light = (minetest.get_node_light(light_pos, 0.5) or 0)
|
||||
local night_growth = in_range(night_light, MIN_LIGHT, MAX_LIGHT)
|
||||
local day_growth = in_range(day_light, MIN_LIGHT, MAX_LIGHT)
|
||||
|
||||
if not night_growth then
|
||||
if not day_growth then return true end
|
||||
|
||||
if not day_growth then
|
||||
return true
|
||||
end
|
||||
|
||||
lambda = day_time(elapsed) / STAGE_LENGTH_AVG
|
||||
|
||||
elseif not day_growth then
|
||||
|
||||
lambda = night_time(elapsed) / STAGE_LENGTH_AVG
|
||||
end
|
||||
|
||||
growth = statistics.poisson(lambda, max_growth)
|
||||
if growth < 1 then return true end
|
||||
|
||||
if growth < 1 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
minetest.swap_node(pos, { name = stages.stages_left[growth] })
|
||||
if minetest.registered_nodes[stages.stages_left[growth]] then
|
||||
minetest.swap_node(pos, {name = stages.stages_left[growth]})
|
||||
else
|
||||
return true
|
||||
end
|
||||
|
||||
return growth ~= max_growth
|
||||
end
|
||||
|
||||
if farming.DEBUG then
|
||||
|
||||
local timer_func = farming.plant_growth_timer;
|
||||
|
||||
farming.plant_growth_timer = function(pos, elapsed, node_name)
|
||||
|
||||
local t0 = minetest.get_us_time()
|
||||
|
||||
local r = { timer_func(pos, elapsed, node_name) }
|
||||
|
||||
local t1 = minetest.get_us_time()
|
||||
|
||||
DEBUG_timer_runs = DEBUG_timer_runs + 1
|
||||
DEBUG_timer_time = DEBUG_timer_time + (t1 - t0)
|
||||
|
||||
return unpack(r)
|
||||
end
|
||||
end
|
||||
|
||||
-- refill placed plant by crabman (26/08/2015)
|
||||
local can_refill_plant = {
|
||||
["farming:blueberry_1"] = "farming:blueberries",
|
||||
["farming:carrot_1"] = "farming:carrot",
|
||||
["farming:coffee_1"] = "farming:coffee_beans",
|
||||
["farming:blueberry_1"] = "farming:blueberries",
|
||||
["farming:carrot_1"] = "farming:carrot",
|
||||
["farming:coffee_1"] = "farming:coffee_beans",
|
||||
["farming:corn_1"] = "farming:corn",
|
||||
["farming:cotton_1"] = "farming:seed_cotton",
|
||||
["farming:cucumber_1"] = "farming:cucumber",
|
||||
["farming:melon_1"] = "farming:melon_slice",
|
||||
["farming:potato_1"] = "farming:potato",
|
||||
["farming:pumpkin_1"] = "farming:pumpkin_slice",
|
||||
["farming:raspberry_1"] = "farming:raspberries",
|
||||
["farming:rhubarb_1"] = "farming:rhubarb",
|
||||
["farming:tomato_1"] = "farming:tomato",
|
||||
["farming:wheat_1"] = "farming:seed_wheat"
|
||||
["farming:cotton_1"] = "farming:seed_cotton",
|
||||
["farming:cucumber_1"] = "farming:cucumber",
|
||||
["farming:melon_1"] = "farming:melon_slice",
|
||||
["farming:potato_1"] = "farming:potato",
|
||||
["farming:pumpkin_1"] = "farming:pumpkin_slice",
|
||||
["farming:raspberry_1"] = "farming:raspberries",
|
||||
["farming:rhubarb_1"] = "farming:rhubarb",
|
||||
["farming:tomato_1"] = "farming:tomato",
|
||||
["farming:wheat_1"] = "farming:seed_wheat",
|
||||
["farming:grapes_1"] = "farming:grapes",
|
||||
["farming:beans_1"] = "farming:beans",
|
||||
["farming:rhubarb_1"] = "farming:rhubarb",
|
||||
["farming:cocoa_1"] = "farming:cocoa_beans",
|
||||
}
|
||||
|
||||
function farming.refill_plant(player, plantname, index)
|
||||
|
||||
local inv = player:get_inventory()
|
||||
local old_stack = inv:get_stack("main", index)
|
||||
if old_stack:get_name() ~= "" then return end
|
||||
for i,stack in ipairs(inv:get_list("main")) do
|
||||
|
||||
if old_stack:get_name() ~= "" then
|
||||
return
|
||||
end
|
||||
|
||||
for i, stack in pairs(inv:get_list("main")) do
|
||||
|
||||
if stack:get_name() == plantname and i ~= index then
|
||||
|
||||
inv:set_stack("main", index, stack)
|
||||
stack:clear()
|
||||
inv:set_stack("main", i, stack)
|
||||
@ -423,11 +538,12 @@ function farming.refill_plant(player, plantname, index)
|
||||
return
|
||||
end
|
||||
end
|
||||
end -- END refill
|
||||
end
|
||||
|
||||
-- Place Seeds on Soil
|
||||
|
||||
function farming.place_seed(itemstack, placer, pointed_thing, plantname)
|
||||
|
||||
local pt = pointed_thing
|
||||
|
||||
-- check if pointing at a node
|
||||
@ -459,20 +575,26 @@ function farming.place_seed(itemstack, placer, pointed_thing, plantname)
|
||||
|
||||
-- if not protected then add node and remove 1 item from the itemstack
|
||||
if not minetest.is_protected(pt.above, placer:get_player_name()) then
|
||||
|
||||
minetest.set_node(pt.above, {name = plantname, param2 = 1})
|
||||
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
|
||||
itemstack:take_item()
|
||||
|
||||
-- check for refill
|
||||
if itemstack:get_count() == 0
|
||||
and can_refill_plant[plantname] then
|
||||
|
||||
minetest.after(0.10,
|
||||
farming.refill_plant,
|
||||
placer,
|
||||
can_refill_plant[plantname],
|
||||
placer:get_wield_index()
|
||||
)
|
||||
end -- END refill
|
||||
end
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
@ -480,6 +602,7 @@ end
|
||||
-- Function to register plants (for compatibility)
|
||||
|
||||
farming.register_plant = function(name, def)
|
||||
|
||||
local mname = name:split(":")[1]
|
||||
local pname = name:split(":")[2]
|
||||
|
||||
@ -487,15 +610,18 @@ farming.register_plant = function(name, def)
|
||||
if not def.description then
|
||||
def.description = "Seed"
|
||||
end
|
||||
|
||||
if not def.inventory_image then
|
||||
def.inventory_image = "unknown_item.png"
|
||||
end
|
||||
|
||||
if not def.steps then
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Register seed
|
||||
minetest.register_node(":" .. mname .. ":seed_" .. pname, {
|
||||
|
||||
description = def.description,
|
||||
tiles = {def.inventory_image},
|
||||
inventory_image = def.inventory_image,
|
||||
@ -507,6 +633,7 @@ farming.register_plant = function(name, def)
|
||||
walkable = false,
|
||||
sunlight_propagates = true,
|
||||
selection_box = farming.select,
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
return farming.place_seed(itemstack, placer, pointed_thing, mname .. ":"..pname.."_1")
|
||||
end
|
||||
@ -520,6 +647,7 @@ farming.register_plant = function(name, def)
|
||||
|
||||
-- Register growing steps
|
||||
for i = 1, def.steps do
|
||||
|
||||
local drop = {
|
||||
items = {
|
||||
{items = {mname .. ":" .. pname}, rarity = 9 - i},
|
||||
@ -530,12 +658,14 @@ farming.register_plant = function(name, def)
|
||||
}
|
||||
|
||||
local g = {snappy = 3, flammable = 2, plant = 1, not_in_creative_inventory = 1, attached_node = 1, growing = 1}
|
||||
|
||||
-- Last step doesn't need growing=1 so Abm never has to check these
|
||||
if i == def.steps then
|
||||
g = {snappy = 3, flammable = 2, plant = 1, not_in_creative_inventory = 1, attached_node = 1}
|
||||
end
|
||||
|
||||
local node_name = mname .. ":" .. pname .. "_" .. i
|
||||
|
||||
minetest.register_node(node_name, {
|
||||
drawtype = "plantlike",
|
||||
waving = 1,
|
||||
@ -548,6 +678,7 @@ farming.register_plant = function(name, def)
|
||||
groups = g,
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
register_plant_node(node_name)
|
||||
end
|
||||
|
||||
@ -562,6 +693,3 @@ farming.register_plant("farming:cotton", {
|
||||
inventory_image = "farming_cotton_seed.png",
|
||||
steps = 8,
|
||||
})]]
|
||||
|
||||
|
||||
|
||||
|
@ -31,13 +31,13 @@ function farming.register_mgv6_decorations()
|
||||
register_plant("melon_8", 1, 20, "group:water", 1)
|
||||
register_plant("pumpkin_8", 1, 20, "group:water", 1)
|
||||
register_plant("raspberry_4", 3, 10, "", -1)
|
||||
register_plant("rhubarb_3", 3, 15, "group:tree", 1)
|
||||
register_plant("rhubarb_3", 3, 15, "", -1)
|
||||
register_plant("blueberry_4", 3, 10, "", -1)
|
||||
register_plant("beanbush", 18, 35, "", -1)
|
||||
register_plant("grapebush", 25, 45, "", -1)
|
||||
end
|
||||
|
||||
-- v7 maps have a beach so plants growing near water is limited to 6- high
|
||||
-- v7 maps have a beach so plants growing near water is limited to 6 high
|
||||
function farming.register_mgv7_decorations()
|
||||
register_plant("potato_3", 15, 40, "", -1)
|
||||
register_plant("tomato_7", 5, 20, "", -1)
|
||||
@ -49,7 +49,7 @@ function farming.register_mgv7_decorations()
|
||||
register_plant("melon_8", 1, 6, "", -1)
|
||||
register_plant("pumpkin_8", 1, 6, "", -1)
|
||||
register_plant("raspberry_4", 3, 10, "", -1)
|
||||
register_plant("rhubarb_3", 3, 15, "group:tree", 1)
|
||||
register_plant("rhubarb_3", 3, 15, "", -1)
|
||||
register_plant("blueberry_4", 3, 10, "", -1)
|
||||
register_plant("beanbush", 18, 35, "", -1)
|
||||
register_plant("grapebush", 25, 45, "", -1)
|
||||
|
@ -1,6 +1,5 @@
|
||||
|
||||
--= Melon
|
||||
|
||||
-- melon
|
||||
minetest.register_craftitem("farming:melon_slice", {
|
||||
description = "Melon Slice",
|
||||
inventory_image = "farming_melon_slice.png",
|
||||
@ -26,9 +25,8 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
-- Define Melon growth stages
|
||||
|
||||
minetest.register_node("farming:melon_1", {
|
||||
-- melon definition
|
||||
local crop_def = {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_melon_1.png"},
|
||||
paramtype = "light",
|
||||
@ -41,119 +39,41 @@ minetest.register_node("farming:melon_1", {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
}
|
||||
|
||||
minetest.register_node("farming:melon_2", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_melon_2.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 1
|
||||
minetest.register_node("farming:melon_1", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:melon_3", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_melon_3.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 2
|
||||
crop_def.tiles = {"farming_melon_2.png"}
|
||||
minetest.register_node("farming:melon_2", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:melon_4", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_melon_4.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 3
|
||||
crop_def.tiles = {"farming_melon_3.png"}
|
||||
minetest.register_node("farming:melon_3", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:melon_5", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_melon_5.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 4
|
||||
crop_def.tiles = {"farming_melon_4.png"}
|
||||
minetest.register_node("farming:melon_4", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:melon_6", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_melon_6.png"},
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 5
|
||||
crop_def.tiles = {"farming_melon_5.png"}
|
||||
minetest.register_node("farming:melon_5", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:melon_7", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_melon_7.png"},
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 6
|
||||
crop_def.tiles = {"farming_melon_6.png"}
|
||||
minetest.register_node("farming:melon_6", table.copy(crop_def))
|
||||
|
||||
-- Last stage of growth does not have growing group so abm never checks these
|
||||
-- stage 7
|
||||
crop_def.tiles = {"farming_melon_7.png"}
|
||||
minetest.register_node("farming:melon_7", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:melon_8", {
|
||||
--drawtype = "nodebox",
|
||||
description = "Melon",
|
||||
tiles = {"farming_melon_top.png", "farming_melon_top.png", "farming_melon_side.png"},
|
||||
paramtype = "light",
|
||||
walkable = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:melon_slice 9'}, rarity = 1},
|
||||
}
|
||||
},
|
||||
groups = {snappy = 1, oddly_breakable_by_hand = 1, flammable = 2, plant = 1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
-- stage 8 (final)
|
||||
crop_def.drawtype = "nodebox"
|
||||
crop_def.description = "Melon"
|
||||
crop_def.tiles = {"farming_melon_top.png", "farming_melon_top.png", "farming_melon_side.png"}
|
||||
crop_def.selection_box = {-.5, -.5, -.5, .5, .5, .5}
|
||||
crop_def.groups = {snappy = 1, oddly_breakable_by_hand = 1, flammable = 2, plant = 1}
|
||||
crop_def.drop = "farming:melon_slice 9"
|
||||
minetest.register_node("farming:melon_8", table.copy(crop_def))
|
||||
|
@ -1,7 +1,10 @@
|
||||
|
||||
--= Potato (Original textures from DocFarming mod)
|
||||
-- https://forum.minetest.net/viewtopic.php?id=3948
|
||||
--[[
|
||||
Original textures from DocFarming mod
|
||||
https://forum.minetest.net/viewtopic.php?id=3948
|
||||
]]
|
||||
|
||||
-- potato
|
||||
minetest.register_craftitem("farming:potato", {
|
||||
description = "Potato",
|
||||
inventory_image = "farming_potato.png",
|
||||
@ -11,6 +14,7 @@ minetest.register_craftitem("farming:potato", {
|
||||
on_use = minetest.item_eat(1),
|
||||
})
|
||||
|
||||
-- baked potato
|
||||
minetest.register_craftitem("farming:baked_potato", {
|
||||
description = "Baked Potato",
|
||||
inventory_image = "farming_baked_potato.png",
|
||||
@ -24,9 +28,8 @@ minetest.register_craft({
|
||||
recipe = "farming:potato"
|
||||
})
|
||||
|
||||
-- Define Potato growth stages
|
||||
|
||||
minetest.register_node("farming:potato_1", {
|
||||
-- potato definition
|
||||
local crop_def = {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_potato_1.png"},
|
||||
paramtype = "light",
|
||||
@ -40,68 +43,33 @@ minetest.register_node("farming:potato_1", {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
}
|
||||
|
||||
minetest.register_node("farming:potato_2", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_potato_2.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 1
|
||||
minetest.register_node("farming:potato_1", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:potato_3", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_potato_3.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:potato'}, rarity = 1},
|
||||
{items = {'farming:potato'}, rarity = 3},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 2
|
||||
crop_def.tiles = {"farming_potato_2.png"}
|
||||
minetest.register_node("farming:potato_2", table.copy(crop_def))
|
||||
|
||||
-- Last stage of growth does not have growing group so abm never checks these
|
||||
-- stage 3
|
||||
crop_def.tiles = {"farming_potato_3.png"}
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:potato'}, rarity = 1},
|
||||
{items = {'farming:potato'}, rarity = 3},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:potato_3", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:potato_4", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_potato_4.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:potato 2'}, rarity = 1},
|
||||
{items = {'farming:potato 3'}, rarity = 2},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory=1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 4
|
||||
crop_def.tiles = {"farming_potato_4.png"}
|
||||
crop_def.groups.growing = 0
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:potato 2'}, rarity = 1},
|
||||
{items = {'farming:potato 3'}, rarity = 2},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:potato_4", table.copy(crop_def))
|
||||
|
@ -1,6 +1,9 @@
|
||||
|
||||
--= Pumpkin (Big thanks to the PainterlyPack.net for Minecraft for allowing me to use these textures)
|
||||
--[[
|
||||
Big thanks to PainterlyPack.net for allowing me to use these textures
|
||||
]]
|
||||
|
||||
-- pumpkin
|
||||
minetest.register_node("farming:pumpkin", {
|
||||
description = "Pumpkin",
|
||||
tiles = {
|
||||
@ -20,6 +23,7 @@ minetest.register_node("farming:pumpkin", {
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
-- pumpkin slice
|
||||
minetest.register_craftitem("farming:pumpkin_slice", {
|
||||
description = "Pumpkin Slice",
|
||||
inventory_image = "farming_pumpkin_slice.png",
|
||||
@ -45,7 +49,7 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
-- Jack 'O Lantern
|
||||
-- jack 'o lantern
|
||||
minetest.register_node("farming:jackolantern", {
|
||||
description = "Jack 'O Lantern",
|
||||
tiles = {
|
||||
@ -61,7 +65,7 @@ minetest.register_node("farming:jackolantern", {
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_punch = function(pos, node, puncher)
|
||||
node.name = "farming:jackolantern_on"
|
||||
minetest.set_node(pos, node)
|
||||
minetest.swap_node(pos, node)
|
||||
end,
|
||||
})
|
||||
|
||||
@ -82,7 +86,7 @@ minetest.register_node("farming:jackolantern_on", {
|
||||
drop = "farming:jackolantern",
|
||||
on_punch = function(pos, node, puncher)
|
||||
node.name = "farming:jackolantern"
|
||||
minetest.set_node(pos, node)
|
||||
minetest.swap_node(pos, node)
|
||||
end,
|
||||
})
|
||||
|
||||
@ -95,7 +99,7 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
-- Pumpkin Bread
|
||||
-- pumpkin bread
|
||||
minetest.register_craftitem("farming:pumpkin_bread", {
|
||||
description = ("Pumpkin Bread"),
|
||||
inventory_image = "farming_pumpkin_bread.png",
|
||||
@ -120,9 +124,8 @@ minetest.register_craft({
|
||||
cooktime = 10
|
||||
})
|
||||
|
||||
-- Define Pumpkin growth stages
|
||||
|
||||
minetest.register_node("farming:pumpkin_1", {
|
||||
-- pumpkin definition
|
||||
local crop_def = {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_pumpkin_1.png"},
|
||||
paramtype = "light",
|
||||
@ -136,125 +139,42 @@ minetest.register_node("farming:pumpkin_1", {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
}
|
||||
|
||||
minetest.register_node("farming:pumpkin_2", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_pumpkin_2.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory =1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 1
|
||||
minetest.register_node("farming:pumpkin_1", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:pumpkin_3", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_pumpkin_3.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 2
|
||||
crop_def.tiles = {"farming_pumpkin_2.png"}
|
||||
minetest.register_node("farming:pumpkin_2", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:pumpkin_4", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_pumpkin_4.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 3
|
||||
crop_def.tiles = {"farming_pumpkin_3.png"}
|
||||
minetest.register_node("farming:pumpkin_3", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:pumpkin_5", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_pumpkin_5.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 4
|
||||
crop_def.tiles = {"farming_pumpkin_4.png"}
|
||||
minetest.register_node("farming:pumpkin_4", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:pumpkin_6", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_pumpkin_6.png"},
|
||||
paramtype = "light",
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 5
|
||||
crop_def.tiles = {"farming_pumpkin_5.png"}
|
||||
minetest.register_node("farming:pumpkin_5", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:pumpkin_7", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_pumpkin_7.png"},
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 6
|
||||
crop_def.tiles = {"farming_pumpkin_6.png"}
|
||||
minetest.register_node("farming:pumpkin_6", table.copy(crop_def))
|
||||
|
||||
-- Last stage of growth does not have growing group so abm never checks these
|
||||
-- stage 7
|
||||
crop_def.tiles = {"farming_pumpkin_7.png"}
|
||||
minetest.register_node("farming:pumpkin_7", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:pumpkin_8", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_pumpkin_8.png"},
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:pumpkin_slice 9'}, rarity = 1},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1
|
||||
},
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
-- stage 8 (final)
|
||||
crop_def.tiles = {"farming_pumpkin_8.png"}
|
||||
crop_def.groups.growing = 0
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:pumpkin_slice 9'}, rarity = 1},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:pumpkin_8", table.copy(crop_def))
|
||||
|
@ -1,6 +1,5 @@
|
||||
|
||||
--= Raspberries
|
||||
|
||||
-- raspberries
|
||||
minetest.register_craftitem("farming:raspberries", {
|
||||
description = "Raspberries",
|
||||
inventory_image = "farming_raspberries.png",
|
||||
@ -10,8 +9,7 @@ minetest.register_craftitem("farming:raspberries", {
|
||||
on_use = minetest.item_eat(1),
|
||||
})
|
||||
|
||||
-- Raspberry Smoothie
|
||||
|
||||
-- raspberry smoothie
|
||||
minetest.register_craftitem("farming:smoothie_raspberry", {
|
||||
description = "Raspberry Smoothie",
|
||||
inventory_image = "farming_raspberry_smoothie.png",
|
||||
@ -27,9 +25,8 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
-- Define Raspberry growth stages
|
||||
|
||||
minetest.register_node("farming:raspberry_1", {
|
||||
-- raspberries definition
|
||||
local crop_def = {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_raspberry_1.png"},
|
||||
paramtype = "light",
|
||||
@ -42,64 +39,28 @@ minetest.register_node("farming:raspberry_1", {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
}
|
||||
|
||||
minetest.register_node("farming:raspberry_2", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_raspberry_2.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 1
|
||||
minetest.register_node("farming:raspberry_1", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:raspberry_3", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_raspberry_3.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 2
|
||||
crop_def.tiles = {"farming_raspberry_2.png"}
|
||||
minetest.register_node("farming:raspberry_2", table.copy(crop_def))
|
||||
|
||||
-- Last stage of growth does not have growing group so abm never checks these
|
||||
-- stage 3
|
||||
crop_def.tiles = {"farming_raspberry_3.png"}
|
||||
minetest.register_node("farming:raspberry_3", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:raspberry_4", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_raspberry_4.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:raspberries 2'}, rarity = 1},
|
||||
{items = {'farming:raspberries'}, rarity = 2},
|
||||
{items = {'farming:raspberries'}, rarity = 3},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 4 (final)
|
||||
crop_def.tiles = {"farming_raspberry_4.png"}
|
||||
crop_def.groups.growing = 0
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:raspberries 2'}, rarity = 1},
|
||||
{items = {'farming:raspberries'}, rarity = 2},
|
||||
{items = {'farming:raspberries'}, rarity = 3},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:raspberry_4", table.copy(crop_def))
|
||||
|
@ -1,6 +1,5 @@
|
||||
|
||||
--= Rhubarb
|
||||
|
||||
-- rhubarb
|
||||
minetest.register_craftitem("farming:rhubarb", {
|
||||
description = "Rhubarb",
|
||||
inventory_image = "farming_rhubarb.png",
|
||||
@ -10,6 +9,7 @@ minetest.register_craftitem("farming:rhubarb", {
|
||||
on_use = minetest.item_eat(1),
|
||||
})
|
||||
|
||||
-- rhubarb pie
|
||||
minetest.register_craftitem("farming:rhubarb_pie", {
|
||||
description = "Rhubarb Pie",
|
||||
inventory_image = "farming_rhubarb_pie.png",
|
||||
@ -25,9 +25,8 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
-- Define Rhubarb growth stages
|
||||
|
||||
minetest.register_node("farming:rhubarb_1", {
|
||||
-- rhubarb definition
|
||||
local crop_def = {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_rhubarb_1.png"},
|
||||
paramtype = "light",
|
||||
@ -40,47 +39,24 @@ minetest.register_node("farming:rhubarb_1", {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
}
|
||||
|
||||
minetest.register_node("farming:rhubarb_2", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_rhubarb_2.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 1
|
||||
minetest.register_node("farming:rhubarb_1", table.copy(crop_def))
|
||||
|
||||
-- Last stage of growth does not have growing group so abm never checks these
|
||||
-- stage2
|
||||
crop_def.tiles = {"farming_rhubarb_2.png"}
|
||||
minetest.register_node("farming:rhubarb_2", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:rhubarb_3", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_rhubarb_3.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:rhubarb 2'}, rarity = 1},
|
||||
{items = {'farming:rhubarb'}, rarity = 2},
|
||||
{items = {'farming:rhubarb'}, rarity = 3},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 3 (final)
|
||||
crop_def.tiles = {"farming_rhubarb_3.png"}
|
||||
crop_def.groups.growing = 0
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:rhubarb 2'}, rarity = 1},
|
||||
{items = {'farming:rhubarb'}, rarity = 2},
|
||||
{items = {'farming:rhubarb'}, rarity = 3},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:rhubarb_3", table.copy(crop_def))
|
||||
|
@ -26,6 +26,7 @@ minetest.register_abm({
|
||||
interval = 15,
|
||||
chance = 4,
|
||||
catch_up = false,
|
||||
|
||||
action = function(pos, node)
|
||||
|
||||
pos.y = pos.y + 1
|
||||
@ -52,8 +53,10 @@ minetest.register_abm({
|
||||
if node.name == "farming:soil" then
|
||||
minetest.set_node(pos, {name = "farming:soil_wet"})
|
||||
end
|
||||
|
||||
elseif node.name == "farming:soil_wet" then
|
||||
minetest.set_node(pos, {name = "farming:soil"})
|
||||
|
||||
elseif node.name == "farming:soil" then
|
||||
minetest.set_node(pos, {name = "default:dirt"})
|
||||
end
|
||||
|
@ -1,9 +1,9 @@
|
||||
local statistics = {}
|
||||
|
||||
local ROOT_2 = math.sqrt(2.0)
|
||||
|
||||
-- Approximations for erf(x) and erfInv(x) from
|
||||
-- https://en.wikipedia.org/wiki/Error_function
|
||||
-- https://en.wikipedia.org/wiki/Error_function
|
||||
|
||||
local erf
|
||||
local erf_inv
|
||||
|
||||
@ -13,19 +13,26 @@ local C = 2.0/(math.pi * A)
|
||||
local D = 1.0 / A
|
||||
|
||||
erf = function(x)
|
||||
|
||||
if x == 0 then return 0; end
|
||||
|
||||
local xSq = x * x
|
||||
local aXSq = A * xSq
|
||||
local v = math.sqrt(1.0 - math.exp(-xSq * (B + aXSq) / (1.0 + aXSq)))
|
||||
|
||||
return (x > 0 and v) or -v
|
||||
end
|
||||
|
||||
erf_inv = function(x)
|
||||
|
||||
if x == 0 then return 0; end
|
||||
|
||||
if x <= -1 or x >= 1 then return nil; end
|
||||
|
||||
local y = math.log(1 - x * x)
|
||||
local u = C + 0.5 * y
|
||||
local v = math.sqrt(math.sqrt(u * u - D * y) - u)
|
||||
|
||||
return (x > 0 and v) or -v
|
||||
end
|
||||
|
||||
@ -37,6 +44,7 @@ local poisson
|
||||
local cdf_table = {}
|
||||
|
||||
local function generate_cdf(lambda_index, lambda)
|
||||
|
||||
local max = math.ceil(4 * lambda)
|
||||
local pdf = math.exp(-lambda)
|
||||
local cdf = pdf
|
||||
@ -56,6 +64,7 @@ for li = 1, 100 do
|
||||
end
|
||||
|
||||
poisson = function(lambda, max)
|
||||
|
||||
if max < 2 then
|
||||
return (math.random() < math.exp(-lambda) and 0) or 1
|
||||
elseif lambda >= 2 * max then
|
||||
@ -67,6 +76,7 @@ poisson = function(lambda, max)
|
||||
local cdfs = cdf_table[lambda_index]
|
||||
|
||||
if cdfs then
|
||||
|
||||
lambda = 0.25 * lambda_index
|
||||
|
||||
if u < cdfs[0] then return 0; end
|
||||
@ -74,9 +84,13 @@ poisson = function(lambda, max)
|
||||
if u >= cdfs[max - 1] then return max; end
|
||||
|
||||
if max > 4 then -- Binary search
|
||||
|
||||
local s = 0
|
||||
|
||||
while s + 1 < max do
|
||||
|
||||
local m = math.floor(0.5 * (s + max))
|
||||
|
||||
if u < cdfs[m] then max = m; else s = m; end
|
||||
end
|
||||
else
|
||||
@ -88,6 +102,7 @@ poisson = function(lambda, max)
|
||||
return max
|
||||
else
|
||||
local x = lambda + math.sqrt(lambda) * std_normal(u)
|
||||
|
||||
return (x < 0.5 and 0) or (x >= max - 0.5 and max) or math.floor(x + 0.5)
|
||||
end
|
||||
end
|
||||
@ -102,14 +117,17 @@ statistics.erf_inv = erf_inv
|
||||
--
|
||||
-- @return
|
||||
-- Any real number (actually between -3.0 and 3.0).
|
||||
--
|
||||
|
||||
statistics.std_normal = function()
|
||||
|
||||
local u = math.random()
|
||||
|
||||
if u < 0.001 then
|
||||
return -3.0
|
||||
elseif u > 0.999 then
|
||||
return 3.0
|
||||
end
|
||||
|
||||
return std_normal(u)
|
||||
end
|
||||
|
||||
@ -121,14 +139,17 @@ end
|
||||
-- The distribution standard deviation.
|
||||
-- @return
|
||||
-- Any real number (actually between -3*sigma and 3*sigma).
|
||||
--
|
||||
|
||||
statistics.normal = function(mu, sigma)
|
||||
|
||||
local u = math.random()
|
||||
|
||||
if u < 0.001 then
|
||||
return mu - 3.0 * sigma
|
||||
elseif u > 0.999 then
|
||||
return mu + 3.0 * sigma
|
||||
end
|
||||
|
||||
return mu + sigma * std_normal(u)
|
||||
end
|
||||
|
||||
@ -140,11 +161,14 @@ end
|
||||
-- The distribution maximum.
|
||||
-- @return
|
||||
-- An integer between 0 and max (both inclusive).
|
||||
--
|
||||
|
||||
statistics.poisson = function(lambda, max)
|
||||
|
||||
lambda, max = tonumber(lambda), tonumber(max)
|
||||
|
||||
if not lambda or not max or lambda <= 0 or max < 1 then return 0; end
|
||||
|
||||
return poisson(lambda, max)
|
||||
end
|
||||
|
||||
return statistics
|
||||
return statistics
|
||||
|
BIN
mods/farming/textures/farming_barley.png
Normal file
After Width: | Height: | Size: 230 B |
BIN
mods/farming/textures/farming_barley_1.png
Normal file
After Width: | Height: | Size: 140 B |
BIN
mods/farming/textures/farming_barley_2.png
Normal file
After Width: | Height: | Size: 151 B |
BIN
mods/farming/textures/farming_barley_3.png
Normal file
After Width: | Height: | Size: 209 B |
BIN
mods/farming/textures/farming_barley_4.png
Normal file
After Width: | Height: | Size: 229 B |
BIN
mods/farming/textures/farming_barley_5.png
Normal file
After Width: | Height: | Size: 246 B |
BIN
mods/farming/textures/farming_barley_6.png
Normal file
After Width: | Height: | Size: 271 B |
BIN
mods/farming/textures/farming_barley_7.png
Normal file
After Width: | Height: | Size: 277 B |
BIN
mods/farming/textures/farming_barley_seed.png
Normal file
After Width: | Height: | Size: 145 B |
@ -1,7 +1,10 @@
|
||||
|
||||
--= Tomato (Original textures from link below)
|
||||
-- http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1288375-food-plus-mod-more-food-than-you-can-imagine-v2-9)
|
||||
--[[
|
||||
Textures edited from:
|
||||
http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1288375-food-plus-mod-more-food-than-you-can-imagine-v2-9)
|
||||
]]
|
||||
|
||||
-- tomato
|
||||
minetest.register_craftitem("farming:tomato", {
|
||||
description = "Tomato",
|
||||
inventory_image = "farming_tomato.png",
|
||||
@ -11,9 +14,8 @@ minetest.register_craftitem("farming:tomato", {
|
||||
on_use = minetest.item_eat(4),
|
||||
})
|
||||
|
||||
-- Define Tomato growth stages
|
||||
|
||||
minetest.register_node("farming:tomato_1", {
|
||||
-- tomato definition
|
||||
local crop_def = {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_tomato_1.png"},
|
||||
paramtype = "light",
|
||||
@ -26,133 +28,49 @@ minetest.register_node("farming:tomato_1", {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
}
|
||||
|
||||
minetest.register_node("farming:tomato_2", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_tomato_2.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 1
|
||||
minetest.register_node("farming:tomato_1", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:tomato_3", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_tomato_3.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage2
|
||||
crop_def.tiles = {"farming_tomato_2.png"}
|
||||
minetest.register_node("farming:tomato_2", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:tomato_4", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_tomato_4.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 3
|
||||
crop_def.tiles = {"farming_tomato_3.png"}
|
||||
minetest.register_node("farming:tomato_3", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:tomato_5", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_tomato_5.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 4
|
||||
crop_def.tiles = {"farming_tomato_4.png"}
|
||||
minetest.register_node("farming:tomato_4", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:tomato_6", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_tomato_6.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 5
|
||||
crop_def.tiles = {"farming_tomato_5.png"}
|
||||
minetest.register_node("farming:tomato_5", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:tomato_7", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_tomato_7.png"},
|
||||
paramtype = "light",
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:tomato'}, rarity = 1},
|
||||
{items = {'farming:tomato'}, rarity = 3},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 6
|
||||
crop_def.tiles = {"farming_tomato_6.png"}
|
||||
minetest.register_node("farming:tomato_6", table.copy(crop_def))
|
||||
|
||||
-- Last stage of growth does not have growing group so abm never checks these
|
||||
-- stage 7
|
||||
crop_def.tiles = {"farming_tomato_7.png"}
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:tomato'}, rarity = 1},
|
||||
{items = {'farming:tomato'}, rarity = 3},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:tomato_7", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:tomato_8", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_tomato_8.png"},
|
||||
paramtype = "light",
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:tomato 3'}, rarity = 1},
|
||||
{items = {'farming:tomato 3'}, rarity = 2},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 8 (final)
|
||||
crop_def.tiles = {"farming_tomato_8.png"}
|
||||
crop_def.groups.growing = 0
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:tomato 3'}, rarity = 1},
|
||||
{items = {'farming:tomato 3'}, rarity = 2},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:tomato_8", table.copy(crop_def))
|
||||
|
@ -1,16 +1,5 @@
|
||||
|
||||
--= Wheat
|
||||
|
||||
-- Wheat Seed
|
||||
|
||||
--minetest.register_craftitem("farming:seed_wheat", {
|
||||
-- description = "Wheat Seed",
|
||||
-- inventory_image = "farming_wheat_seed.png",
|
||||
-- on_place = function(itemstack, placer, pointed_thing)
|
||||
-- return farming.place_seed(itemstack, placer, pointed_thing, "farming:wheat_1")
|
||||
-- end,
|
||||
--})
|
||||
|
||||
-- wheat seeds
|
||||
minetest.register_node("farming:seed_wheat", {
|
||||
description = "Wheat Seed",
|
||||
tiles = {"farming_wheat_seed.png"},
|
||||
@ -28,15 +17,13 @@ minetest.register_node("farming:seed_wheat", {
|
||||
end,
|
||||
})
|
||||
|
||||
-- Harvested Wheat
|
||||
|
||||
-- harvested wheat
|
||||
minetest.register_craftitem("farming:wheat", {
|
||||
description = "Wheat",
|
||||
inventory_image = "farming_wheat.png",
|
||||
})
|
||||
|
||||
-- Straw
|
||||
|
||||
-- straw
|
||||
minetest.register_node("farming:straw", {
|
||||
description = "Straw",
|
||||
tiles = {"farming_straw.png"},
|
||||
@ -62,7 +49,6 @@ minetest.register_craft({
|
||||
})
|
||||
|
||||
-- flour
|
||||
|
||||
minetest.register_craftitem("farming:flour", {
|
||||
description = "Flour",
|
||||
inventory_image = "farming_flour.png",
|
||||
@ -74,8 +60,7 @@ minetest.register_craft({
|
||||
recipe = {"farming:wheat", "farming:wheat", "farming:wheat", "farming:wheat"}
|
||||
})
|
||||
|
||||
-- Bread
|
||||
|
||||
-- bread
|
||||
minetest.register_craftitem("farming:bread", {
|
||||
description = "Bread",
|
||||
inventory_image = "farming_bread.png",
|
||||
@ -89,9 +74,8 @@ minetest.register_craft({
|
||||
recipe = "farming:flour"
|
||||
})
|
||||
|
||||
-- Define Wheat growth stages
|
||||
|
||||
minetest.register_node("farming:wheat_1", {
|
||||
-- wheat definition
|
||||
local crop_def = {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_wheat_1.png"},
|
||||
paramtype = "light",
|
||||
@ -100,152 +84,69 @@ minetest.register_node("farming:wheat_1", {
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing=1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming:wheat_2", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_wheat_2.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
}
|
||||
|
||||
minetest.register_node("farming:wheat_3", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_wheat_3.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 1
|
||||
minetest.register_node("farming:wheat_1", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:wheat_4", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_wheat_4.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "",
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 2
|
||||
crop_def.tiles = {"farming_wheat_2.png"}
|
||||
minetest.register_node("farming:wheat_2", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:wheat_5", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_wheat_5.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:wheat'}, rarity = 2},
|
||||
{items = {'farming:seed_wheat'}, rarity = 2},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 3
|
||||
crop_def.tiles = {"farming_wheat_3.png"}
|
||||
minetest.register_node("farming:wheat_3", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:wheat_6", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_wheat_6.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:wheat'}, rarity = 2},
|
||||
{items = {'farming:seed_wheat'}, rarity = 1},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 4
|
||||
crop_def.tiles = {"farming_wheat_4.png"}
|
||||
minetest.register_node("farming:wheat_4", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:wheat_7", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_wheat_7.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:wheat'}, rarity = 1},
|
||||
{items = {'farming:wheat'}, rarity = 3},
|
||||
{items = {'farming:seed_wheat'}, rarity = 1},
|
||||
{items = {'farming:seed_wheat'}, rarity = 3},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1, growing = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 5
|
||||
crop_def.tiles = {"farming_wheat_5.png"}
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:wheat'}, rarity = 2},
|
||||
{items = {'farming:seed_wheat'}, rarity = 2},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:wheat_5", table.copy(crop_def))
|
||||
|
||||
-- Last stage of growth does not have growing group so abm never checks these
|
||||
-- stage 6
|
||||
crop_def.tiles = {"farming_wheat_6.png"}
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:wheat'}, rarity = 2},
|
||||
{items = {'farming:seed_wheat'}, rarity = 1},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:wheat_6", table.copy(crop_def))
|
||||
|
||||
minetest.register_node("farming:wheat_8", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_wheat_8.png"},
|
||||
paramtype = "light",
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = {
|
||||
items = {
|
||||
{items = {'farming:wheat'}, rarity = 1},
|
||||
{items = {'farming:wheat'}, rarity = 2},
|
||||
{items = {'farming:seed_wheat'}, rarity = 1},
|
||||
{items = {'farming:seed_wheat'}, rarity = 2},
|
||||
}
|
||||
},
|
||||
selection_box = farming.select,
|
||||
groups = {
|
||||
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
|
||||
not_in_creative_inventory = 1
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
-- stage 7
|
||||
crop_def.tiles = {"farming_wheat_7.png"}
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:wheat'}, rarity = 1},
|
||||
{items = {'farming:wheat'}, rarity = 3},
|
||||
{items = {'farming:seed_wheat'}, rarity = 1},
|
||||
{items = {'farming:seed_wheat'}, rarity = 3},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:wheat_7", table.copy(crop_def))
|
||||
|
||||
-- stage 8 (final)
|
||||
crop_def.tiles = {"farming_wheat_8.png"}
|
||||
crop_def.groups.growing = 0
|
||||
crop_def.drop = {
|
||||
items = {
|
||||
{items = {'farming:wheat'}, rarity = 1},
|
||||
{items = {'farming:wheat'}, rarity = 3},
|
||||
{items = {'farming:seed_wheat'}, rarity = 1},
|
||||
{items = {'farming:seed_wheat'}, rarity = 3},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:wheat_8", table.copy(crop_def))
|
||||
|
@ -1,7 +1,5 @@
|
||||
This is maikerumine's no burn fire for no griefing on a server.
|
||||
|
||||
Minetest 0.4 mod: fire
|
||||
======================
|
||||
Minetest Game mod: fire
|
||||
=======================
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
@ -32,3 +30,7 @@ fire_large.ogg sampled from:
|
||||
|
||||
fire_basic_flame_animated.png:
|
||||
Muadtralk
|
||||
|
||||
fire_flint_steel.png
|
||||
Gambit (WTFPL)
|
||||
|
||||
|
@ -1,68 +1,151 @@
|
||||
-- minetest/fire/init.lua
|
||||
|
||||
-- Global namespace for functions
|
||||
|
||||
fire = {}
|
||||
|
||||
|
||||
-- Register flame nodes
|
||||
|
||||
minetest.register_node("fire:basic_flame", {
|
||||
description = "Fire",
|
||||
drawtype = "plantlike",
|
||||
tiles = {{
|
||||
name="fire_basic_flame_animated.png",
|
||||
animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},
|
||||
}},
|
||||
drawtype = "firelike",
|
||||
tiles = {
|
||||
{
|
||||
name = "fire_basic_flame_animated.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 1
|
||||
},
|
||||
},
|
||||
},
|
||||
inventory_image = "fire_basic_flame.png",
|
||||
paramtype = "light",
|
||||
light_source = 14,
|
||||
groups = {igniter=2,dig_immediate=3,hot=3},
|
||||
drop = '',
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
damage_per_second = 4,
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
fire.on_flame_add_at(pos)
|
||||
groups = {igniter = 2, dig_immediate = 3, not_in_creative_inventory = 1},
|
||||
drop = "",
|
||||
|
||||
on_construct = function(pos)
|
||||
minetest.after(0, fire.on_flame_add_at, pos)
|
||||
end,
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
fire.on_flame_remove_at(pos)
|
||||
|
||||
on_destruct = function(pos)
|
||||
minetest.after(0, fire.on_flame_remove_at, pos)
|
||||
end,
|
||||
|
||||
on_blast = function()
|
||||
end, -- unaffected by explosions
|
||||
})
|
||||
|
||||
minetest.register_node("fire:permanent_flame", {
|
||||
description = "Permanent Flame",
|
||||
drawtype = "firelike",
|
||||
tiles = {
|
||||
{
|
||||
name = "fire_basic_flame_animated.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 1
|
||||
},
|
||||
},
|
||||
},
|
||||
inventory_image = "fire_basic_flame.png",
|
||||
paramtype = "light",
|
||||
light_source = 14,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
damage_per_second = 4,
|
||||
groups = {igniter = 2, dig_immediate = 3},
|
||||
drop = "",
|
||||
|
||||
on_blast = function()
|
||||
end,
|
||||
})
|
||||
|
||||
fire = {}
|
||||
fire.D = 6
|
||||
-- key: position hash of low corner of area
|
||||
-- value: {handle=sound handle, name=sound name}
|
||||
fire.sounds = {}
|
||||
minetest.register_tool("fire:flint_and_steel", {
|
||||
description = "Flint and Steel",
|
||||
inventory_image = "fire_flint_steel.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local player_name = user:get_player_name()
|
||||
local pt = pointed_thing
|
||||
|
||||
if pt.type == "node" and minetest.get_node(pt.above).name == "air" then
|
||||
if not minetest.is_protected(pt.above, player_name) then
|
||||
minetest.set_node(pt.above, {name="fire:basic_flame"})
|
||||
else
|
||||
minetest.chat_send_player(player_name, "This area is protected")
|
||||
end
|
||||
end
|
||||
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(1000)
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "fire:flint_and_steel",
|
||||
recipe = {
|
||||
{"default:flint", "default:steel_ingot"}
|
||||
}
|
||||
})
|
||||
|
||||
-- Get sound area of position
|
||||
|
||||
fire.D = 6 -- size of sound areas
|
||||
|
||||
function fire.get_area_p0p1(pos)
|
||||
local p0 = {
|
||||
x=math.floor(pos.x/fire.D)*fire.D,
|
||||
y=math.floor(pos.y/fire.D)*fire.D,
|
||||
z=math.floor(pos.z/fire.D)*fire.D,
|
||||
x = math.floor(pos.x / fire.D) * fire.D,
|
||||
y = math.floor(pos.y / fire.D) * fire.D,
|
||||
z = math.floor(pos.z / fire.D) * fire.D,
|
||||
}
|
||||
local p1 = {
|
||||
x=p0.x+fire.D-1,
|
||||
y=p0.y+fire.D-1,
|
||||
z=p0.z+fire.D-1
|
||||
x = p0.x + fire.D - 1,
|
||||
y = p0.y + fire.D - 1,
|
||||
z = p0.z + fire.D - 1
|
||||
}
|
||||
return p0, p1
|
||||
end
|
||||
|
||||
|
||||
-- Fire sounds table
|
||||
-- key: position hash of low corner of area
|
||||
-- value: {handle=sound handle, name=sound name}
|
||||
fire.sounds = {}
|
||||
|
||||
|
||||
-- Update fire sounds in sound area of position
|
||||
|
||||
function fire.update_sounds_around(pos)
|
||||
local p0, p1 = fire.get_area_p0p1(pos)
|
||||
local cp = {x=(p0.x+p1.x)/2, y=(p0.y+p1.y)/2, z=(p0.z+p1.z)/2}
|
||||
local cp = {x = (p0.x + p1.x) / 2, y = (p0.y + p1.y) / 2, z = (p0.z + p1.z) / 2}
|
||||
local flames_p = minetest.find_nodes_in_area(p0, p1, {"fire:basic_flame"})
|
||||
--print("number of flames at "..minetest.pos_to_string(p0).."/"
|
||||
-- ..minetest.pos_to_string(p1)..": "..#flames_p)
|
||||
local should_have_sound = (#flames_p > 0)
|
||||
local wanted_sound = nil
|
||||
if #flames_p >= 9 then
|
||||
wanted_sound = {name="fire_large", gain=1.5}
|
||||
wanted_sound = {name = "fire_large", gain = 0.7}
|
||||
elseif #flames_p > 0 then
|
||||
wanted_sound = {name="fire_small", gain=1.5}
|
||||
wanted_sound = {name = "fire_small", gain = 0.9}
|
||||
end
|
||||
local p0_hash = minetest.hash_node_position(p0)
|
||||
local sound = fire.sounds[p0_hash]
|
||||
if not sound then
|
||||
if should_have_sound then
|
||||
fire.sounds[p0_hash] = {
|
||||
handle = minetest.sound_play(wanted_sound, {pos=cp, loop=true}),
|
||||
handle = minetest.sound_play(wanted_sound,
|
||||
{pos = cp, max_hear_distance = 16, loop = true}),
|
||||
name = wanted_sound.name,
|
||||
}
|
||||
end
|
||||
@ -73,61 +156,136 @@ function fire.update_sounds_around(pos)
|
||||
elseif sound.name ~= wanted_sound.name then
|
||||
minetest.sound_stop(sound.handle)
|
||||
fire.sounds[p0_hash] = {
|
||||
handle = minetest.sound_play(wanted_sound, {pos=cp, loop=true}),
|
||||
handle = minetest.sound_play(wanted_sound,
|
||||
{pos = cp, max_hear_distance = 16, loop = true}),
|
||||
name = wanted_sound.name,
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Update fire sounds on flame node construct or destruct
|
||||
|
||||
function fire.on_flame_add_at(pos)
|
||||
--print("flame added at "..minetest.pos_to_string(pos))
|
||||
fire.update_sounds_around(pos)
|
||||
end
|
||||
|
||||
|
||||
function fire.on_flame_remove_at(pos)
|
||||
--print("flame removed at "..minetest.pos_to_string(pos))
|
||||
fire.update_sounds_around(pos)
|
||||
end
|
||||
|
||||
|
||||
-- Return positions for flames around a burning node
|
||||
|
||||
function fire.find_pos_for_flame_around(pos)
|
||||
return minetest.find_node_near(pos, 1, {"air"})
|
||||
end
|
||||
|
||||
|
||||
-- Detect nearby extinguishing nodes
|
||||
|
||||
function fire.flame_should_extinguish(pos)
|
||||
if minetest.setting_getbool("disable_fire") then return true end
|
||||
--return minetest.find_node_near(pos, 1, {"group:puts_out_fire"})
|
||||
local p0 = {x=pos.x-2, y=pos.y, z=pos.z-2}
|
||||
local p1 = {x=pos.x+2, y=pos.y, z=pos.z+2}
|
||||
local ps = minetest.find_nodes_in_area(p0, p1, {"group:puts_out_fire"})
|
||||
return (#ps ~= 0)
|
||||
return minetest.find_node_near(pos, 1, {"group:puts_out_fire"})
|
||||
end
|
||||
--Here is where we comment out griefing from fire.
|
||||
--[[ Ignite neighboring nodes
|
||||
|
||||
|
||||
-- Extinguish all flames quickly with water, snow, ice
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:flammable"},
|
||||
neighbors = {"group:igniter"},
|
||||
interval = 1,
|
||||
chance = 2,
|
||||
nodenames = {"fire:basic_flame", "fire:permanent_flame"},
|
||||
neighbors = {"group:puts_out_fire"},
|
||||
interval = 3,
|
||||
chance = 1,
|
||||
catch_up = false,
|
||||
action = function(p0, node, _, _)
|
||||
-- If there is water or stuff like that around flame, don't ignite
|
||||
if fire.flame_should_extinguish(p0) then
|
||||
return
|
||||
end
|
||||
local p = fire.find_pos_for_flame_around(p0)
|
||||
if p then
|
||||
minetest.set_node(p, {name="fire:basic_flame"})
|
||||
fire.on_flame_add_at(p)
|
||||
end
|
||||
minetest.remove_node(p0)
|
||||
minetest.sound_play("fire_extinguish_flame",
|
||||
{pos = p0, max_hear_distance = 16, gain = 0.25})
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
-- Enable the following ABMs according to 'disable fire' setting
|
||||
|
||||
if minetest.setting_getbool("disable_fire") then
|
||||
|
||||
-- Remove basic flames only
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"fire:basic_flame"},
|
||||
interval = 7,
|
||||
chance = 1,
|
||||
catch_up = false,
|
||||
action = function(p0, node, _, _)
|
||||
minetest.remove_node(p0)
|
||||
end,
|
||||
})
|
||||
|
||||
else
|
||||
|
||||
-- Ignite neighboring nodes, add basic flames
|
||||
--[[
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:flammable"},
|
||||
neighbors = {"group:igniter"},
|
||||
interval = 7,
|
||||
chance = 16,
|
||||
catch_up = false,
|
||||
action = function(p0, node, _, _)
|
||||
-- If there is water or stuff like that around node, don't ignite
|
||||
if fire.flame_should_extinguish(p0) then
|
||||
return
|
||||
end
|
||||
local p = fire.find_pos_for_flame_around(p0)
|
||||
if p then
|
||||
minetest.set_node(p, {name = "fire:basic_flame"})
|
||||
end
|
||||
end,
|
||||
})
|
||||
]]
|
||||
-- Remove basic flames and flammable nodes
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"fire:basic_flame"},
|
||||
interval = 5,
|
||||
chance = 16,
|
||||
catch_up = false,
|
||||
action = function(p0, node, _, _)
|
||||
-- If there are no flammable nodes around flame, remove flame
|
||||
local p = minetest.find_node_near(p0, 1, {"group:flammable"})
|
||||
if not p then
|
||||
minetest.remove_node(p0)
|
||||
return
|
||||
end
|
||||
if math.random(1, 4) == 1 then
|
||||
-- remove flammable nodes around flame
|
||||
local node = minetest.get_node(p)
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
if def.on_burn then
|
||||
def.on_burn(p)
|
||||
else
|
||||
minetest.remove_node(p)
|
||||
nodeupdate(p)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Rarely ignite things from far
|
||||
|
||||
--[[ Currently disabled to reduce the chance of uncontrollable spreading
|
||||
fires that disrupt servers. Also for less lua processing load.
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:igniter"},
|
||||
neighbors = {"air"},
|
||||
interval = 4,
|
||||
chance = 40,
|
||||
interval = 5,
|
||||
chance = 10,
|
||||
action = function(p0, node, _, _)
|
||||
local reg = minetest.registered_nodes[node.name]
|
||||
if not reg or not reg.groups.igniter or reg.groups.igniter < 2 then
|
||||
@ -142,52 +300,9 @@ minetest.register_abm({
|
||||
end
|
||||
local p2 = fire.find_pos_for_flame_around(p)
|
||||
if p2 then
|
||||
minetest.set_node(p2, {name="fire:basic_flame"})
|
||||
fire.on_flame_add_at(p2)
|
||||
minetest.set_node(p2, {name = "fire:basic_flame"})
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
]]
|
||||
|
||||
-- Remove flammable nodes and flame
|
||||
minetest.register_abm({
|
||||
nodenames = {"fire:basic_flame"},
|
||||
interval = 1,
|
||||
chance = 2,
|
||||
action = function(p0, node, _, _)
|
||||
-- If there is water or stuff like that around flame, remove flame
|
||||
if fire.flame_should_extinguish(p0) then
|
||||
minetest.remove_node(p0)
|
||||
fire.on_flame_remove_at(p0)
|
||||
return
|
||||
end
|
||||
-- Make the following things rarer
|
||||
if math.random(1,3) == 1 then
|
||||
return
|
||||
end
|
||||
-- If there are no flammable nodes around flame, remove flame
|
||||
if not minetest.find_node_near(p0, 1, {"group:flammable"}) then
|
||||
minetest.remove_node(p0)
|
||||
fire.on_flame_remove_at(p0)
|
||||
return
|
||||
end
|
||||
if math.random(1,4) == 1 then
|
||||
-- remove a flammable node around flame
|
||||
local p = minetest.find_node_near(p0, 1, {"group:flammable"})
|
||||
if p then
|
||||
-- If there is water or stuff like that around flame, don't remove
|
||||
if fire.flame_should_extinguish(p0) then
|
||||
return
|
||||
end
|
||||
minetest.remove_node(p)
|
||||
nodeupdate(p)
|
||||
end
|
||||
else
|
||||
-- remove flame
|
||||
minetest.remove_node(p0)
|
||||
fire.on_flame_remove_at(p0)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
--]]
|
||||
|
Before Width: | Height: | Size: 785 B After Width: | Height: | Size: 646 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.0 KiB |
BIN
mods/fire/textures/fire_flint_steel.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
@ -1,5 +1,5 @@
|
||||
Minetest 0.4 mod: flowers
|
||||
=========================
|
||||
Minetest Game mod: flowers
|
||||
==========================
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
@ -16,7 +16,8 @@ License of media (textures and sounds)
|
||||
WTFPL
|
||||
|
||||
Gambit (WTFPL):
|
||||
flowers_mushroom_*.png
|
||||
flowers_mushroom_*.png
|
||||
flowers_waterlily.png
|
||||
|
||||
DanDuncombe (WTFPL):
|
||||
flowers_spores_*.png
|
||||
flowers_spores_*.png
|
||||
|
@ -46,6 +46,7 @@ local function add_simple_flower(name, desc, box, f_groups)
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
stack_max = 99,
|
||||
groups = f_groups,
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
@ -75,8 +76,8 @@ end
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:flora"},
|
||||
neighbors = {"default:dirt_with_grass", "default:desert_sand"},
|
||||
interval = 50,
|
||||
chance = 25,
|
||||
interval = 13,
|
||||
chance = 96,
|
||||
action = function(pos, node)
|
||||
pos.y = pos.y - 1
|
||||
local under = minetest.get_node(pos)
|
||||
@ -123,116 +124,127 @@ minetest.register_abm({
|
||||
-- Mushrooms
|
||||
--
|
||||
|
||||
local mushrooms_datas = {
|
||||
{"brown", 2},
|
||||
{"red", -6}
|
||||
}
|
||||
minetest.register_node("flowers:mushroom_red", {
|
||||
description = "Red Mushroom",
|
||||
tiles = {"flowers_mushroom_red.png"},
|
||||
inventory_image = "flowers_mushroom_red.png",
|
||||
wield_image = "flowers_mushroom_red.png",
|
||||
drawtype = "plantlike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy = 3, flammable = 3, attached_node = 1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
on_use = minetest.item_eat(-5),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3}
|
||||
}
|
||||
})
|
||||
|
||||
for _, m in pairs(mushrooms_datas) do
|
||||
local name, nut = m[1], m[2]
|
||||
|
||||
-- Register fertile mushrooms
|
||||
|
||||
-- These are placed by mapgen and the growing ABM.
|
||||
-- These drop an infertile mushroom, and 0 to 3 spore
|
||||
-- nodes with an average of 1.25 per mushroom, for
|
||||
-- a slow multiplication of mushrooms when farming.
|
||||
|
||||
minetest.register_node("flowers:mushroom_fertile_" .. name, {
|
||||
description = string.sub(string.upper(name), 0, 1) ..
|
||||
string.sub(name, 2) .. " Fertile Mushroom",
|
||||
tiles = {"flowers_mushroom_" .. name .. ".png"},
|
||||
inventory_image = "flowers_mushroom_" .. name .. ".png",
|
||||
wield_image = "flowers_mushroom_" .. name .. ".png",
|
||||
drawtype = "plantlike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy = 3, flammable = 3, attached_node = 1,
|
||||
not_in_creative_inventory = 1},
|
||||
drop = {
|
||||
items = {
|
||||
{items = {"flowers:mushroom_" .. name}},
|
||||
{items = {"flowers:mushroom_spores_" .. name}, rarity = 4},
|
||||
{items = {"flowers:mushroom_spores_" .. name}, rarity = 2},
|
||||
{items = {"flowers:mushroom_spores_" .. name}, rarity = 2}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
on_use = minetest.item_eat(nut),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3}
|
||||
}
|
||||
})
|
||||
|
||||
-- Register infertile mushrooms
|
||||
|
||||
-- These do not drop spores, to avoid the use of repeated digging
|
||||
-- and placing of a single mushroom to generate unlimited spores.
|
||||
|
||||
minetest.register_node("flowers:mushroom_" .. name, {
|
||||
description = string.sub(string.upper(name), 0, 1) ..
|
||||
string.sub(name, 2) .. " Mushroom",
|
||||
tiles = {"flowers_mushroom_" .. name .. ".png"},
|
||||
inventory_image = "flowers_mushroom_" .. name .. ".png",
|
||||
wield_image = "flowers_mushroom_" .. name .. ".png",
|
||||
drawtype = "plantlike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy = 3, flammable = 3, attached_node = 1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
on_use = minetest.item_eat(nut),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3}
|
||||
}
|
||||
})
|
||||
|
||||
-- Register mushroom spores
|
||||
|
||||
minetest.register_node("flowers:mushroom_spores_" .. name, {
|
||||
description = string.sub(string.upper(name), 0, 1) ..
|
||||
string.sub(name, 2) .. " Mushroom Spores",
|
||||
drawtype = "signlike",
|
||||
tiles = {"flowers_mushroom_spores_" .. name .. ".png"},
|
||||
inventory_image = "flowers_mushroom_spores_" .. name .. ".png",
|
||||
wield_image = "flowers_mushroom_spores_" .. name .. ".png",
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
selection_box = {
|
||||
type = "wallmounted",
|
||||
},
|
||||
groups = {dig_immediate = 3, attached_node = 1},
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
-- Register growing ABM
|
||||
minetest.register_node("flowers:mushroom_brown", {
|
||||
description = "Brown Mushroom",
|
||||
tiles = {"flowers_mushroom_brown.png"},
|
||||
inventory_image = "flowers_mushroom_brown.png",
|
||||
wield_image = "flowers_mushroom_brown.png",
|
||||
drawtype = "plantlike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy = 3, flammable = 3, attached_node = 1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
on_use = minetest.item_eat(1),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3}
|
||||
}
|
||||
})
|
||||
|
||||
-- mushroom spread and death
|
||||
minetest.register_abm({
|
||||
nodenames = {"flowers:mushroom_spores_brown", "flowers:mushroom_spores_red"},
|
||||
nodenames = {"flowers:mushroom_brown", "flowers:mushroom_red"},
|
||||
interval = 11,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
local node_under = minetest.get_node_or_nil({x = pos.x,
|
||||
y = pos.y - 1, z = pos.z})
|
||||
if minetest.get_node_light(pos, nil) == 15 then
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
local random = {
|
||||
x = pos.x + math.random(-2,2),
|
||||
y = pos.y + math.random(-1,1),
|
||||
z = pos.z + math.random(-2,2)
|
||||
}
|
||||
local random_node = minetest.get_node_or_nil(random)
|
||||
if not random_node then
|
||||
return
|
||||
end
|
||||
if random_node.name ~= "air" then
|
||||
return
|
||||
end
|
||||
local node_under = minetest.get_node_or_nil({x = random.x,
|
||||
y = random.y - 1, z = random.z})
|
||||
if not node_under then
|
||||
return
|
||||
end
|
||||
if minetest.get_item_group(node_under.name, "soil") ~= 0 and
|
||||
minetest.get_node_light(pos, nil) <= 13 then
|
||||
if node.name == "flowers:mushroom_spores_brown" then
|
||||
minetest.set_node(pos, {name = "flowers:mushroom_fertile_brown"})
|
||||
elseif node.name == "flowers:mushroom_spores_red" then
|
||||
minetest.set_node(pos, {name = "flowers:mushroom_fertile_red"})
|
||||
end
|
||||
minetest.get_node_light(pos, nil) <= 9 and
|
||||
minetest.get_node_light(random, nil) <= 9 then
|
||||
minetest.set_node(random, {name = node.name})
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
-- these old mushroom related nodes can be simplified now
|
||||
minetest.register_alias("flowers:mushroom_spores_brown", "flowers:mushroom_brown")
|
||||
minetest.register_alias("flowers:mushroom_spores_red", "flowers:mushroom_red")
|
||||
minetest.register_alias("flowers:mushroom_fertile_brown", "flowers:mushroom_brown")
|
||||
minetest.register_alias("flowers:mushroom_fertile_red", "flowers:mushroom_red")
|
||||
|
||||
|
||||
--
|
||||
-- Waterlily
|
||||
--
|
||||
|
||||
minetest.register_node("flowers:waterlily", {
|
||||
description = "Waterlily",
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"flowers_waterlily.png"},
|
||||
inventory_image = "flowers_waterlily.png",
|
||||
wield_image = "flowers_waterlily.png",
|
||||
liquids_pointable = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy = 3, flower = 1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -0.46875, 0.5}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5}
|
||||
},
|
||||
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
local find_water = minetest.find_nodes_in_area({x = pos.x - 1, y = pos.y, z = pos.z - 1},
|
||||
{x = pos.x + 1, y = pos.y, z = pos.z + 1}, "default:water_source")
|
||||
local find_river_water = minetest.find_nodes_in_area({x = pos.x - 1, y = pos.y, z = pos.z - 1},
|
||||
{x = pos.x + 1, y = pos.y, z = pos.z + 1}, "default:river_water_source")
|
||||
if #find_water ~= 0 then
|
||||
minetest.set_node(pos, {name = "default:water_source"})
|
||||
pos.y = pos.y + 1
|
||||
minetest.set_node(pos, {name = "flowers:waterlily", param2 = math.random(0, 3)})
|
||||
elseif #find_river_water ~= 0 then
|
||||
minetest.set_node(pos, {name = "default:river_water_source"})
|
||||
pos.y = pos.y + 1
|
||||
minetest.set_node(pos, {name = "flowers:waterlily", param2 = math.random(0, 3)})
|
||||
else
|
||||
minetest.remove_node(pos)
|
||||
return true
|
||||
end
|
||||
end
|
||||
})
|
||||
|
@ -10,7 +10,7 @@ local function register_mgv6_flower(name)
|
||||
noise_params = {
|
||||
offset = 0,
|
||||
scale = 0.006,
|
||||
spread = {x=100, y=100, z=100},
|
||||
spread = {x = 100, y = 100, z = 100},
|
||||
seed = 436,
|
||||
octaves = 3,
|
||||
persist = 0.6
|
||||
@ -29,7 +29,7 @@ local function register_mgv6_mushroom(name)
|
||||
noise_params = {
|
||||
offset = 0,
|
||||
scale = 0.04,
|
||||
spread = {x=100, y=100, z=100},
|
||||
spread = {x = 100, y = 100, z = 100},
|
||||
seed = 7133,
|
||||
octaves = 3,
|
||||
persist = 0.6
|
||||
@ -42,6 +42,26 @@ local function register_mgv6_mushroom(name)
|
||||
})
|
||||
end
|
||||
|
||||
local function register_mgv6_waterlily()
|
||||
minetest.register_decoration({
|
||||
deco_type = "schematic",
|
||||
place_on = {"default:dirt"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = -0.12,
|
||||
scale = 0.3,
|
||||
spread = {x = 100, y = 100, z = 100},
|
||||
seed = 33,
|
||||
octaves = 3,
|
||||
persist = 0.7
|
||||
},
|
||||
y_min = 0,
|
||||
y_max = 0,
|
||||
schematic = minetest.get_modpath("flowers").."/schematics/waterlily.mts",
|
||||
rotation = "random",
|
||||
})
|
||||
end
|
||||
|
||||
function flowers.register_mgv6_decorations()
|
||||
register_mgv6_flower("rose")
|
||||
register_mgv6_flower("tulip")
|
||||
@ -50,8 +70,10 @@ function flowers.register_mgv6_decorations()
|
||||
register_mgv6_flower("viola")
|
||||
register_mgv6_flower("dandelion_white")
|
||||
|
||||
register_mgv6_mushroom("mushroom_fertile_brown")
|
||||
register_mgv6_mushroom("mushroom_fertile_red")
|
||||
register_mgv6_mushroom("mushroom_brown")
|
||||
register_mgv6_mushroom("mushroom_red")
|
||||
|
||||
register_mgv6_waterlily()
|
||||
end
|
||||
|
||||
|
||||
@ -65,20 +87,16 @@ local function register_flower(seed, name)
|
||||
place_on = {"default:dirt_with_grass"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = -0.02,
|
||||
scale = 0.03,
|
||||
spread = {x=200, y=200, z=200},
|
||||
offset = -0.015,
|
||||
scale = 0.025,
|
||||
spread = {x = 200, y = 200, z = 200},
|
||||
seed = seed,
|
||||
octaves = 3,
|
||||
persist = 0.6
|
||||
},
|
||||
biomes = {
|
||||
"stone_grassland",
|
||||
"sandstone_grassland",
|
||||
"deciduous_forest",
|
||||
"coniferous_forest",
|
||||
},
|
||||
y_min = 6,
|
||||
biomes = {"stone_grassland", "sandstone_grassland",
|
||||
"deciduous_forest", "coniferous_forest"},
|
||||
y_min = 1,
|
||||
y_max = 31000,
|
||||
decoration = "flowers:"..name,
|
||||
})
|
||||
@ -92,18 +110,39 @@ local function register_mushroom(name)
|
||||
noise_params = {
|
||||
offset = 0,
|
||||
scale = 0.006,
|
||||
spread = {x=200, y=200, z=200},
|
||||
spread = {x = 200, y = 200, z = 200},
|
||||
seed = 2,
|
||||
octaves = 3,
|
||||
persist = 0.66
|
||||
},
|
||||
biomes = {"deciduous_forest", "coniferous_forest"},
|
||||
y_min = 6,
|
||||
y_min = 1,
|
||||
y_max = 31000,
|
||||
decoration = "flowers:"..name,
|
||||
})
|
||||
end
|
||||
|
||||
local function register_waterlily()
|
||||
minetest.register_decoration({
|
||||
deco_type = "schematic",
|
||||
place_on = {"default:dirt"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = -0.12,
|
||||
scale = 0.3,
|
||||
spread = {x = 200, y = 200, z = 200},
|
||||
seed = 33,
|
||||
octaves = 3,
|
||||
persist = 0.7
|
||||
},
|
||||
biomes = {"rainforest_swamp", "savanna_swamp", "deciduous_forest_swamp"},
|
||||
y_min = 0,
|
||||
y_max = 0,
|
||||
schematic = minetest.get_modpath("flowers").."/schematics/waterlily.mts",
|
||||
rotation = "random",
|
||||
})
|
||||
end
|
||||
|
||||
function flowers.register_decorations()
|
||||
register_flower(436, "rose")
|
||||
register_flower(19822, "tulip")
|
||||
@ -112,8 +151,10 @@ function flowers.register_decorations()
|
||||
register_flower(1133, "viola")
|
||||
register_flower(73133, "dandelion_white")
|
||||
|
||||
register_mushroom("mushroom_fertile_brown")
|
||||
register_mushroom("mushroom_fertile_red")
|
||||
register_mushroom("mushroom_brown")
|
||||
register_mushroom("mushroom_red")
|
||||
|
||||
register_waterlily()
|
||||
end
|
||||
|
||||
|
||||
|
BIN
mods/flowers/schematics/waterlily.mts
Normal file
BIN
mods/flowers/textures/flowers_waterlily.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
@ -1,4 +1,4 @@
|
||||
Minetest 0.4 mod: stairs
|
||||
Minetest Game mod: stairs
|
||||
=========================
|
||||
|
||||
License of source code:
|
||||
|
@ -22,6 +22,7 @@ local replace = minetest.setting_getbool("enable_stairs_replace_abm")
|
||||
-- Node will be called stairs:stair_<subname>
|
||||
|
||||
function stairs.register_stair(subname, recipeitem, groups, images, description, sounds)
|
||||
groups.stair = 1
|
||||
minetest.register_node(":stairs:stair_" .. subname, {
|
||||
description = description,
|
||||
drawtype = "mesh",
|
||||
@ -111,6 +112,7 @@ end
|
||||
-- Node will be called stairs:slab_<subname>
|
||||
|
||||
function stairs.register_slab(subname, recipeitem, groups, images, description, sounds)
|
||||
groups.slab = 1
|
||||
minetest.register_node(":stairs:slab_" .. subname, {
|
||||
description = description,
|
||||
drawtype = "nodebox",
|
||||
@ -170,7 +172,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
||||
|
||||
-- Upside down slabs
|
||||
if p0.y - 1 == p1.y then
|
||||
-- Turn into full block if pointing at a existing slab
|
||||
@ -231,7 +233,7 @@ end
|
||||
if replace then
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:slabs_replace"},
|
||||
interval = 8,
|
||||
interval = 16,
|
||||
chance = 1,
|
||||
action = function(pos, node)
|
||||
node.name = minetest.registered_nodes[node.name].replace_name
|
||||
@ -287,6 +289,13 @@ stairs.register_stair_and_slab("acacia_wood", "default:acacia_wood",
|
||||
"Acacia Wood Slab",
|
||||
default.node_sound_wood_defaults())
|
||||
|
||||
stairs.register_stair_and_slab("aspen_wood", "default:aspen_wood",
|
||||
{snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3},
|
||||
{"default_aspen_wood.png"},
|
||||
"Aspen Wood Stair",
|
||||
"Aspen Wood Slab",
|
||||
default.node_sound_wood_defaults())
|
||||
|
||||
stairs.register_stair_and_slab("stone", "default:stone",
|
||||
{cracky = 3},
|
||||
{"default_stone.png"},
|
||||
@ -335,7 +344,7 @@ stairs.register_stair_and_slab("sandstone", "default:sandstone",
|
||||
"Sandstone Stair",
|
||||
"Sandstone Slab",
|
||||
default.node_sound_stone_defaults())
|
||||
|
||||
|
||||
stairs.register_stair_and_slab("sandstonebrick", "default:sandstonebrick",
|
||||
{crumbly = 2, cracky = 2},
|
||||
{"default_sandstone_brick.png"},
|
||||
@ -398,4 +407,3 @@ stairs.register_stair_and_slab("goldblock", "default:goldblock",
|
||||
"Gold Block Stair",
|
||||
"Gold Block Slab",
|
||||
default.node_sound_stone_defaults())
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
=== TNT mod for Minetest ===
|
||||
Minetest Game mod: tnt
|
||||
======================
|
||||
by PilzAdam and ShadowNinja
|
||||
|
||||
Introduction:
|
||||
|
@ -1,12 +1,17 @@
|
||||
tnt = {}
|
||||
|
||||
|
||||
--[[
|
||||
-- Default to enabled in singleplayer and disabled in multiplayer
|
||||
local singleplayer = minetest.is_singleplayer()
|
||||
local setting = minetest.setting_getbool("enable_tnt")
|
||||
if (not singleplayer and setting ~= true) or
|
||||
(singleplayer and setting == false) then
|
||||
return
|
||||
end
|
||||
]]
|
||||
-- loss probabilities array (one in X will be lost)
|
||||
local loss_prob = {}
|
||||
|
||||
loss_prob["default:cobble"] = 3
|
||||
loss_prob["default:dirt"] = 4
|
||||
loss_prob["tnt:tnt"] = 1
|
||||
|
||||
local radius = tonumber(minetest.setting_get("tnt_radius") or 3)
|
||||
|
||||
@ -18,17 +23,29 @@ minetest.after(0, function()
|
||||
name = name,
|
||||
drops = def.drops,
|
||||
flammable = def.groups.flammable,
|
||||
groups = def.groups,
|
||||
on_blast = def.on_blast,
|
||||
}
|
||||
end
|
||||
end)
|
||||
|
||||
function tnt:rand_pos(center, pos, radius)
|
||||
pos.x = center.x + math.random(-radius, radius)
|
||||
pos.z = center.z + math.random(-radius, radius)
|
||||
local function rand_pos(center, pos, radius)
|
||||
local def
|
||||
local reg_nodes = minetest.registered_nodes
|
||||
local i = 0
|
||||
repeat
|
||||
-- Give up and use the center if this takes too long
|
||||
if i > 4 then
|
||||
pos.x, pos.z = center.x, center.z
|
||||
break
|
||||
end
|
||||
pos.x = center.x + math.random(-radius, radius)
|
||||
pos.z = center.z + math.random(-radius, radius)
|
||||
def = reg_nodes[minetest.get_node(pos).name]
|
||||
i = i + 1
|
||||
until def and not def.walkable
|
||||
end
|
||||
|
||||
function tnt:eject_drops(drops, pos, radius)
|
||||
local function eject_drops(drops, pos, radius)
|
||||
local drop_pos = vector.new(pos)
|
||||
for _, item in pairs(drops) do
|
||||
local count = item:get_count()
|
||||
@ -40,7 +57,7 @@ function tnt:eject_drops(drops, pos, radius)
|
||||
if count < max then
|
||||
item:set_count(count)
|
||||
end
|
||||
tnt:rand_pos(pos, drop_pos, radius)
|
||||
rand_pos(pos, drop_pos, radius)
|
||||
local obj = minetest.add_item(drop_pos, item)
|
||||
if obj then
|
||||
obj:get_luaentity().collect = true
|
||||
@ -53,7 +70,7 @@ function tnt:eject_drops(drops, pos, radius)
|
||||
end
|
||||
end
|
||||
|
||||
function tnt:add_drop(drops, item)
|
||||
local function add_drop(drops, item)
|
||||
item = ItemStack(item)
|
||||
local name = item:get_name()
|
||||
if loss_prob[name] ~= nil and math.random(1, loss_prob[name]) == 1 then
|
||||
@ -68,37 +85,39 @@ function tnt:add_drop(drops, item)
|
||||
end
|
||||
end
|
||||
|
||||
function tnt:destroy(drops, pos, cid)
|
||||
local fire_node = {name="fire:basic_flame"}
|
||||
|
||||
local function destroy(drops, pos, cid)
|
||||
if minetest.is_protected(pos, "") then
|
||||
return
|
||||
end
|
||||
local def = cid_data[cid]
|
||||
-- bedrock
|
||||
if def and def.groups.immortal ~= nil then
|
||||
if def and def.on_blast then
|
||||
def.on_blast(vector.new(pos), 1)
|
||||
return
|
||||
end
|
||||
-- obsidian
|
||||
if def and def.name == "default:obsidian" then
|
||||
return
|
||||
end
|
||||
minetest.remove_node(pos)
|
||||
if def then
|
||||
local node_drops = minetest.get_node_drops(def.name, "")
|
||||
for _, item in ipairs(node_drops) do
|
||||
tnt:add_drop(drops, item)
|
||||
if def and def.flammable then
|
||||
minetest.set_node(pos, fire_node)
|
||||
else
|
||||
minetest.remove_node(pos)
|
||||
if def then
|
||||
local node_drops = minetest.get_node_drops(def.name, "")
|
||||
for _, item in ipairs(node_drops) do
|
||||
add_drop(drops, item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function tnt:calc_velocity(pos1, pos2, old_vel, power)
|
||||
local function calc_velocity(pos1, pos2, old_vel, power)
|
||||
local vel = vector.direction(pos1, pos2)
|
||||
vel = vector.normalize(vel)
|
||||
vel = vector.multiply(vel, power)
|
||||
|
||||
-- Divide by distance
|
||||
local dist = vector.distance(pos1, pos2)
|
||||
dist = math.max(dist, 3)
|
||||
dist = math.max(dist, 1)
|
||||
vel = vector.divide(vel, dist)
|
||||
|
||||
-- Add old velocity
|
||||
@ -106,7 +125,7 @@ function tnt:calc_velocity(pos1, pos2, old_vel, power)
|
||||
return vel
|
||||
end
|
||||
|
||||
function tnt:entity_physics(pos, radius)
|
||||
local function entity_physics(pos, radius)
|
||||
-- Make the damage radius larger than the destruction radius
|
||||
radius = radius * 2
|
||||
local objs = minetest.get_objects_inside_radius(pos, radius)
|
||||
@ -116,10 +135,8 @@ function tnt:entity_physics(pos, radius)
|
||||
local dist = math.max(1, vector.distance(pos, obj_pos))
|
||||
|
||||
if obj_vel ~= nil then
|
||||
local vel = tnt:calc_velocity(pos, obj_pos,
|
||||
obj_vel, radius * 10)
|
||||
obj:setvelocity({x=vel.x, y=vel.y, z=vel.z})
|
||||
obj:setacceleration({x=-vel.x/5, y=-10, z=-vel.z/5})
|
||||
obj:setvelocity(calc_velocity(pos, obj_pos,
|
||||
obj_vel, radius * 10))
|
||||
end
|
||||
|
||||
local damage = (4 / dist) * radius
|
||||
@ -127,7 +144,7 @@ function tnt:entity_physics(pos, radius)
|
||||
end
|
||||
end
|
||||
|
||||
function tnt:add_effects(pos, radius)
|
||||
local function add_effects(pos, radius)
|
||||
minetest.add_particlespawner({
|
||||
amount = 128,
|
||||
time = 1,
|
||||
@ -145,11 +162,12 @@ function tnt:add_effects(pos, radius)
|
||||
})
|
||||
end
|
||||
|
||||
function tnt:burn(pos)
|
||||
local function burn(pos)
|
||||
local name = minetest.get_node(pos).name
|
||||
if name == "tnt:tnt" then
|
||||
minetest.sound_play("tnt_ignite", {pos=pos})
|
||||
tnt:lit(pos, name)
|
||||
minetest.set_node(pos, {name="tnt:tnt_burning"})
|
||||
minetest.get_node_timer(pos):start(1)
|
||||
elseif name == "tnt:gunpowder" then
|
||||
minetest.sound_play("tnt_gunpowder_burning", {pos=pos, gain=2})
|
||||
minetest.set_node(pos, {name="tnt:gunpowder_burning"})
|
||||
@ -157,7 +175,7 @@ function tnt:burn(pos)
|
||||
end
|
||||
end
|
||||
|
||||
function tnt:explode(pos, radius)
|
||||
local function explode(pos, radius)
|
||||
local pos = vector.round(pos)
|
||||
local vm = VoxelManip()
|
||||
local pr = PseudoRandom(os.time())
|
||||
@ -171,23 +189,10 @@ function tnt:explode(pos, radius)
|
||||
local p = {}
|
||||
|
||||
local c_air = minetest.get_content_id("air")
|
||||
local c_tnt = minetest.get_content_id("tnt:tnt")
|
||||
local c_bomb = minetest.get_content_id("tnt:bomb")
|
||||
local c_tnt_burning = minetest.get_content_id("tnt:tnt_burning")
|
||||
local c_gunpowder = minetest.get_content_id("tnt:gunpowder")
|
||||
local c_gunpowder_burning = minetest.get_content_id("tnt:gunpowder_burning")
|
||||
local c_boom = minetest.get_content_id("tnt:boom")
|
||||
local c_fire = minetest.get_content_id("fire:basic_flame")
|
||||
|
||||
-- don't destroy any blocks when in water
|
||||
local p0 = {x=pos.x-1, y=pos.y, z=pos.z-1}
|
||||
local p1 = {x=pos.x+1, y=pos.y, z=pos.z+1}
|
||||
if #minetest.find_nodes_in_area(p0, p1, {"group:water"}) > 0 then return {} end
|
||||
|
||||
for z = -radius, radius do
|
||||
for y = -radius, radius do
|
||||
local vi = a:index(pos.x + (-radius), pos.y + y, pos.z + z)
|
||||
local ntnt = 1
|
||||
for x = -radius, radius do
|
||||
if (x * x) + (y * y) + (z * z) <=
|
||||
(radius * radius) + pr:next(-radius, radius) then
|
||||
@ -195,20 +200,8 @@ function tnt:explode(pos, radius)
|
||||
p.x = pos.x + x
|
||||
p.y = pos.y + y
|
||||
p.z = pos.z + z
|
||||
if cid == c_tnt or cid == c_bomb then
|
||||
minetest.after(ntnt+math.random(1,9)/10, function()
|
||||
tnt:boom(p)
|
||||
end)
|
||||
ntnt = ntnt + 1
|
||||
end
|
||||
if cid == c_gunpowder then
|
||||
tnt:burn(p)
|
||||
elseif cid ~= c_tnt_burning and
|
||||
cid ~= c_gunpowder_burning and
|
||||
cid ~= c_air and
|
||||
cid ~= c_fire and
|
||||
cid ~= c_boom then
|
||||
tnt:destroy(drops, p, cid)
|
||||
if cid ~= c_air then
|
||||
destroy(drops, p, cid)
|
||||
end
|
||||
end
|
||||
vi = vi + 1
|
||||
@ -220,157 +213,97 @@ function tnt:explode(pos, radius)
|
||||
end
|
||||
|
||||
|
||||
--integrate with city-block
|
||||
--[[function tnt:explode(pos, radius)
|
||||
local pos = vector.round(pos)
|
||||
local vm = VoxelManip()
|
||||
local pr = PseudoRandom(os.time())
|
||||
local p1 = vector.subtract(pos, radius)
|
||||
local p2 = vector.add(pos, radius)
|
||||
local minp, maxp = vm:read_from_map(p1, p2)
|
||||
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
|
||||
local data = vm:get_data()
|
||||
|
||||
local drops = {}
|
||||
local p = {}
|
||||
|
||||
local c_air = minetest.get_content_id("air")
|
||||
local c_tnt = minetest.get_content_id("tnt:tnt")
|
||||
local c_tnt_burning = minetest.get_content_id("tnt:tnt_burning")
|
||||
local c_gunpowder = minetest.get_content_id("tnt:gunpowder")
|
||||
local c_gunpowder_burning = minetest.get_content_id("tnt:gunpowder_burning")
|
||||
local c_boom = minetest.get_content_id("tnt:boom")
|
||||
local c_fire = minetest.get_content_id("fire:basic_flame")
|
||||
|
||||
-- don't destroy any blocks when protected
|
||||
local p0 = {x=pos.x-33, y=pos.y-33, z=pos.z-33}
|
||||
local p1 = {x=pos.x+33, y=pos.y+33, z=pos.z+33}
|
||||
if #minetest.find_nodes_in_area(p0, p1, {"city_block:cityblock"}) > 0 then return {} end
|
||||
|
||||
for z = -radius, radius do
|
||||
for y = -radius, radius do
|
||||
local vi = a:index(pos.x + (-radius), pos.y + y, pos.z + z)
|
||||
local ntnt = 1
|
||||
for x = -radius, radius do
|
||||
if (x * x) + (y * y) + (z * z) <=
|
||||
(radius * radius) + pr:next(-radius, radius) then
|
||||
local cid = data[vi]
|
||||
p.x = pos.x + x
|
||||
p.y = pos.y + y
|
||||
p.z = pos.z + z
|
||||
if cid == c_tnt then
|
||||
minetest.after(ntnt+math.random(1,9)/10, function()
|
||||
tnt:boom(p)
|
||||
end)
|
||||
ntnt = ntnt + 1
|
||||
end
|
||||
if cid == c_gunpowder then
|
||||
tnt:burn(p)
|
||||
elseif cid ~= c_tnt_burning and
|
||||
cid ~= c_gunpowder_burning and
|
||||
cid ~= c_air and
|
||||
cid ~= c_fire and
|
||||
cid ~= c_boom then
|
||||
tnt:destroy(drops, p, cid)
|
||||
|
||||
|
||||
|
||||
|
||||
if city_block:in_city(pos) then
|
||||
minetest.chat_send_player(placer:get_player_name(), "Don't do that in town!")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
vi = vi + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return drops
|
||||
end]]
|
||||
|
||||
|
||||
function tnt:lit( p, n )
|
||||
minetest.remove_node( p )
|
||||
minetest.add_entity( p, 'tnt:tnt_ent' )
|
||||
end
|
||||
|
||||
function tnt:lit2( p, n )
|
||||
minetest.remove_node( p )
|
||||
minetest.add_entity( p, 'tnt:tnt2_ent' )
|
||||
end
|
||||
|
||||
|
||||
|
||||
function tnt:boom(pos)
|
||||
local function boom(pos)
|
||||
minetest.sound_play("tnt_explode", {pos=pos, gain=1.5, max_hear_distance=2*64})
|
||||
minetest.set_node(pos, {name="tnt:boom"})
|
||||
minetest.get_node_timer(pos):start(0.5)
|
||||
|
||||
local drops = tnt:explode(pos, radius)
|
||||
tnt:entity_physics(pos, radius)
|
||||
tnt:eject_drops(drops, pos, radius)
|
||||
tnt:add_effects(pos, radius)
|
||||
end
|
||||
|
||||
local function meseboom(pos)
|
||||
minetest.remove_node(pos)
|
||||
tnt:boom(pos)
|
||||
end
|
||||
|
||||
local function lavaboom(pos)
|
||||
local name = minetest.get_node(pos).name
|
||||
tnt:lit(pos, name)
|
||||
local drops = explode(pos, radius)
|
||||
entity_physics(pos, radius)
|
||||
eject_drops(drops, pos, radius)
|
||||
add_effects(pos, radius)
|
||||
end
|
||||
|
||||
minetest.register_node("tnt:tnt", {
|
||||
description = "TNT",
|
||||
tiles = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png"},
|
||||
is_ground_content = false,
|
||||
groups = {dig_immediate=2, mesecon=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_punch = function(pos, node, puncher)
|
||||
if puncher:get_wielded_item():get_name() == "default:torch" then
|
||||
minetest.sound_play("tnt_ignite", {pos=pos})
|
||||
tnt:lit(pos, node)
|
||||
minetest.set_node(pos, {name="tnt:tnt_burning"})
|
||||
end
|
||||
end,
|
||||
mesecons = {effector = {action_on = meseboom}},
|
||||
on_blast = function(pos, intensity)
|
||||
burn(pos)
|
||||
end,
|
||||
mesecons = {effector = {action_on = boom}},
|
||||
})
|
||||
|
||||
minetest.register_node("tnt:bomb", {
|
||||
description = "TNT Air Drop Bomb",
|
||||
tiles = {"tnt2_top.png", "tnt2_top.png", "tnt2_side.png"},
|
||||
groups = {dig_immediate=2, mesecon=2},
|
||||
minetest.register_node("tnt:tnt_burning", {
|
||||
tiles = {
|
||||
{
|
||||
name = "tnt_top_burning_animated.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 1,
|
||||
}
|
||||
},
|
||||
"tnt_bottom.png", "tnt_side.png"},
|
||||
light_source = 5,
|
||||
drop = "",
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_punch = function(pos, node, puncher)
|
||||
if puncher:get_wielded_item():get_name() == "default:mese" then
|
||||
minetest.sound_play("tnt_ignite", {pos=pos})
|
||||
tnt:lit2(pos, node)
|
||||
end
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(4)
|
||||
end,
|
||||
mesecons = {effector = {action_on = meseboom}},
|
||||
on_timer = boom,
|
||||
-- unaffected by explosions
|
||||
on_blast = function() end,
|
||||
})
|
||||
|
||||
minetest.register_node("tnt:boom", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"tnt_boom.png"},
|
||||
light_source = default.LIGHT_MAX,
|
||||
walkable = false,
|
||||
drop = "",
|
||||
groups = {dig_immediate=3},
|
||||
on_timer = function(pos, elapsed)
|
||||
minetest.remove_node(pos)
|
||||
end,
|
||||
-- unaffected by explosions
|
||||
on_blast = function() end,
|
||||
})
|
||||
|
||||
minetest.register_node("tnt:gunpowder", {
|
||||
description = "Gun Powder",
|
||||
drawtype = "raillike",
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
tiles = {"tnt_gunpowder.png",},
|
||||
tiles = {"tnt_gunpowder_straight.png", "tnt_gunpowder_curved.png", "tnt_gunpowder_t_junction.png", "tnt_gunpowder_crossing.png"},
|
||||
inventory_image = "tnt_gunpowder_inventory.png",
|
||||
wield_image = "tnt_gunpowder_inventory.png",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
||||
},
|
||||
groups = {dig_immediate=2,attached_node=1},
|
||||
groups = {dig_immediate=2,attached_node=1,connect_to_raillike=minetest.raillike_group("gunpowder")},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
|
||||
|
||||
on_punch = function(pos, node, puncher)
|
||||
if puncher:get_wielded_item():get_name() == "default:torch" then
|
||||
tnt:burn(pos)
|
||||
burn(pos)
|
||||
end
|
||||
end,
|
||||
on_blast = function(pos, intensity)
|
||||
burn(pos)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("tnt:gunpowder_burning", {
|
||||
@ -380,7 +313,34 @@ minetest.register_node("tnt:gunpowder_burning", {
|
||||
walkable = false,
|
||||
light_source = 5,
|
||||
tiles = {{
|
||||
name = "tnt_gunpowder_burning_animated.png",
|
||||
name = "tnt_gunpowder_burning_straight_animated.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 1,
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "tnt_gunpowder_burning_curved_animated.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 1,
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "tnt_gunpowder_burning_t_junction_animated.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 1,
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "tnt_gunpowder_burning_crossing_animated.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
@ -393,14 +353,14 @@ minetest.register_node("tnt:gunpowder_burning", {
|
||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
||||
},
|
||||
drop = "",
|
||||
groups = {dig_immediate=2,attached_node=1},
|
||||
groups = {dig_immediate=2,attached_node=1,connect_to_raillike=minetest.raillike_group("gunpowder")},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
on_timer = function(pos, elapsed)
|
||||
for dx = -1, 1 do
|
||||
for dz = -1, 1 do
|
||||
for dy = -1, 1 do
|
||||
if not (dx == 0 and dz == 0) then
|
||||
tnt:burn({
|
||||
burn({
|
||||
x = pos.x + dx,
|
||||
y = pos.y + dy,
|
||||
z = pos.z + dz,
|
||||
@ -410,15 +370,17 @@ minetest.register_node("tnt:gunpowder_burning", {
|
||||
end
|
||||
end
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end,
|
||||
-- unaffected by explosions
|
||||
on_blast = function() end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"tnt:tnt", "tnt:bomb","tnt:gunpowder"},
|
||||
nodenames = {"tnt:tnt", "tnt:gunpowder"},
|
||||
neighbors = {"fire:basic_flame", "default:lava_source", "default:lava_flowing"},
|
||||
interval = 1,
|
||||
interval = 4,
|
||||
chance = 1,
|
||||
action = lavaboom,
|
||||
action = burn,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
@ -426,6 +388,7 @@ minetest.register_craft({
|
||||
type = "shapeless",
|
||||
recipe = {"default:coal_lump", "default:gravel"}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "tnt:tnt",
|
||||
recipe = {
|
||||
@ -434,133 +397,3 @@ minetest.register_craft({
|
||||
{"", "group:wood", ""}
|
||||
}
|
||||
})
|
||||
--------------------------------------------------------------------------------
|
||||
-- TNT
|
||||
--------------------------------------------------------------------------------
|
||||
-- A simple TNT mod which damages both terrain and entities.
|
||||
-- Barely based on bcmpinc's pull request.
|
||||
--
|
||||
-- (c)2012 Fernando Zapata (ZLovesPancakes, Franz.ZPT)
|
||||
-- Code licensed under GNU GPLv2
|
||||
-- http://www.gnu.org/licenses/gpl-2.0.html
|
||||
-- Content licensed under CC BY-SA 3.0
|
||||
-- http://creativecommons.org/licenses/by-sa/3.0/
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-------------------------------------------------------------- Entities --------
|
||||
|
||||
tnt.ent_proto = {
|
||||
hp_max = 1000,
|
||||
physical = true,
|
||||
collisionbox = { -1/2, -1/2, -1/2, 1/2, 1/2, 1/2 },
|
||||
visual = 'cube',
|
||||
textures = { 'tnt_top.png', 'tnt_bottom.png', 'tnt_side.png',
|
||||
'tnt_side.png', 'tnt_side.png', 'tnt_side.png' },
|
||||
|
||||
timer = 0,
|
||||
btimer = 0,
|
||||
bstatus = true,
|
||||
physical_state = true,
|
||||
|
||||
on_activate = function( sf, sd )
|
||||
sf.object:set_armor_groups( { immortal=1 } )
|
||||
sf.object:setvelocity({x=math.random(-40,40)/40, y=4, z=math.random(-40,40)/40})
|
||||
sf.object:setacceleration({x=0, y=-10, z=0})
|
||||
sf.object:settexturemod('^[brighten')
|
||||
end,
|
||||
|
||||
on_step = function( sf, dt )
|
||||
sf.timer = sf.timer + dt
|
||||
sf.btimer = sf.btimer + dt
|
||||
if sf.btimer > 0.5 then
|
||||
sf.btimer = sf.btimer - 0.5
|
||||
if sf.bstatus then
|
||||
sf.object:settexturemod('')
|
||||
else
|
||||
sf.object:settexturemod('^[brighten')
|
||||
end
|
||||
sf.bstatus = not sf.bstatus
|
||||
end
|
||||
if sf.timer > 0.5 then
|
||||
local p = sf.object:getpos()
|
||||
p.y = p.y - 0.501
|
||||
local nn = minetest.get_node(p).name
|
||||
if not minetest.registered_nodes[nn] or
|
||||
minetest.registered_nodes[nn].walkable then
|
||||
sf.object:setvelocity({x=0,y=0,z=0})
|
||||
sf.object:setacceleration({x=0, y=0, z=0})
|
||||
end
|
||||
end
|
||||
if sf.timer > 4 then
|
||||
local pos = sf.object:getpos()
|
||||
local pos2 = {x=math.floor(pos.x+0.5), y=math.floor(pos.y+0.5),
|
||||
z=math.floor(pos.z+0.5)}
|
||||
tnt:boom(pos2)
|
||||
sf.object:remove()
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
minetest.register_entity( 'tnt:tnt_ent', tnt.ent_proto )
|
||||
|
||||
tnt.ent_proto2 = {
|
||||
hp_max = 1000,
|
||||
physical = true,
|
||||
collisionbox = { -1/2, -1/2, -1/2, 1/2, 1/2, 1/2 },
|
||||
visual = 'cube',
|
||||
textures = { 'tnt2_top.png', 'tnt2_top.png', 'tnt2_side.png',
|
||||
'tnt2_side.png', 'tnt2_side.png', 'tnt2_side.png' },
|
||||
|
||||
timer = 0,
|
||||
btimer = 0,
|
||||
bstatus = true,
|
||||
physical_state = true,
|
||||
|
||||
on_activate = function( sf, sd )
|
||||
sf.object:set_armor_groups( { immortal=1 } )
|
||||
sf.object:setvelocity({x=math.random(-40,40)/40, y=4, z=math.random(-40,40)/40})
|
||||
sf.object:setacceleration({x=0, y=-10, z=0})
|
||||
sf.object:settexturemod('^[brighten')
|
||||
end,
|
||||
|
||||
on_step = function( sf, dt )
|
||||
sf.timer = sf.timer + dt
|
||||
sf.btimer = sf.btimer + dt
|
||||
if sf.btimer > 0.5 then
|
||||
sf.btimer = sf.btimer - 0.5
|
||||
if sf.bstatus then
|
||||
sf.object:settexturemod('')
|
||||
else
|
||||
sf.object:settexturemod('^[brighten')
|
||||
end
|
||||
sf.bstatus = not sf.bstatus
|
||||
end
|
||||
if sf.timer > 0.5 then
|
||||
local p = sf.object:getpos()
|
||||
p.y = p.y - 0.501
|
||||
local nn = minetest.get_node(p).name
|
||||
if not minetest.registered_nodes[nn] or
|
||||
minetest.registered_nodes[nn].walkable then
|
||||
sf.object:setvelocity({x=0,y=0,z=0})
|
||||
sf.object:setacceleration({x=0, y=0, z=0})
|
||||
end
|
||||
end
|
||||
if sf.timer > 4 then
|
||||
local pos = sf.object:getpos()
|
||||
local pos2 = {x=math.floor(pos.x+0.5), y=math.floor(pos.y+0.5),
|
||||
z=math.floor(pos.z+0.5)}
|
||||
tnt:boom(pos2)
|
||||
sf.object:remove()
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
minetest.register_entity( 'tnt:tnt2_ent', tnt.ent_proto2 )
|
||||
|
||||
|
||||
|
||||
|
||||
if minetest.setting_get("log_mods") then
|
||||
minetest.debug("[TNT] Loaded!")
|
||||
end
|
||||
|
||||
|
BIN
mods/tnt/textures/tnt_gunpowder_burning_crossing_animated.png
Normal file
After Width: | Height: | Size: 612 B |
BIN
mods/tnt/textures/tnt_gunpowder_burning_curved_animated.png
Normal file
After Width: | Height: | Size: 432 B |
BIN
mods/tnt/textures/tnt_gunpowder_burning_straight_animated.png
Normal file
After Width: | Height: | Size: 461 B |
BIN
mods/tnt/textures/tnt_gunpowder_burning_t_junction_animated.png
Normal file
After Width: | Height: | Size: 672 B |
BIN
mods/tnt/textures/tnt_gunpowder_crossing.png
Normal file
After Width: | Height: | Size: 245 B |
BIN
mods/tnt/textures/tnt_gunpowder_curved.png
Normal file
After Width: | Height: | Size: 268 B |
BIN
mods/tnt/textures/tnt_gunpowder_straight.png
Normal file
After Width: | Height: | Size: 225 B |
BIN
mods/tnt/textures/tnt_gunpowder_t_junction.png
Normal file
After Width: | Height: | Size: 328 B |
@ -1,4 +1,4 @@
|
||||
Minetest 0.4 mod: vessels
|
||||
Minetest Game mod: vessels
|
||||
==========================
|
||||
|
||||
Crafts
|
||||
|
1
mods/walls/depends.txt
Normal file
@ -0,0 +1 @@
|
||||
default
|
149
mods/walls/init.lua
Normal file
@ -0,0 +1,149 @@
|
||||
|
||||
--[[
|
||||
|
||||
Walls mod for Minetest
|
||||
|
||||
Copyright (C) 2015 Auke Kok <sofar@foo-projects.org>
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
--]]
|
||||
|
||||
walls = {}
|
||||
--[[
|
||||
--NEW CODE
|
||||
walls.register = function(wall_name, wall_desc, wall_texture, wall_mat, wall_sounds)
|
||||
-- inventory node, and pole-type wall start item
|
||||
minetest.register_node(wall_name, {
|
||||
description = wall_desc,
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "connected",
|
||||
fixed = {{-1/4, -1/2, -1/4, 1/4, 1/2, 1/4}},
|
||||
-- connect_bottom =
|
||||
connect_front = {{-3/16, -1/2, -1/2, 3/16, 3/8, -1/4}},
|
||||
connect_left = {{-1/2, -1/2, -3/16, -1/4, 3/8, 3/16}},
|
||||
connect_back = {{-3/16, -1/2, 1/4, 3/16, 3/8, 1/2}},
|
||||
connect_right = {{ 1/4, -1/2, -3/16, 1/2, 3/8, 3/16}},
|
||||
},
|
||||
connects_to = { "group:cracky", "group:wall", "group:stone" },
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
tiles = { wall_texture, },
|
||||
walkable = true,
|
||||
groups = { cracky = 3, wall = 1, stone = 2 },
|
||||
sounds = wall_sounds,
|
||||
})
|
||||
|
||||
-- crafting recipe
|
||||
minetest.register_craft({
|
||||
output = wall_name .. " 6",
|
||||
recipe = {
|
||||
{ '', '', '' },
|
||||
{ wall_mat, wall_mat, wall_mat},
|
||||
{ wall_mat, wall_mat, wall_mat},
|
||||
}
|
||||
})
|
||||
|
||||
end
|
||||
]]
|
||||
|
||||
walls.register = function(wall_name, wall_desc, wall_texture, wall_mat, wall_sounds)
|
||||
-- inventory node, and pole-type wall start item
|
||||
minetest.register_node(wall_name, {
|
||||
description = wall_desc,
|
||||
--drawtype = "nodebox",
|
||||
drawtype = "fencelike",
|
||||
node_box = {
|
||||
type = "connected",
|
||||
fixed = {{-1/4, -1/2, -1/4, 1/4, 1/2, 1/4}},
|
||||
-- connect_bottom =
|
||||
--connect_front = {{-3/16, -1/2, -1/2, 3/16, 3/8, -1/4}},
|
||||
--connect_left = {{-1/2, -1/2, -3/16, -1/4, 3/8, 3/16}},
|
||||
--connect_back = {{-3/16, -1/2, 1/4, 3/16, 3/8, 1/2}},
|
||||
--connect_right = {{ 1/4, -1/2, -3/16, 1/2, 3/8, 3/16}},
|
||||
},
|
||||
--connects_to = { "group:cracky", "group:wall", "group:stone" },
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
tiles = { wall_texture, },
|
||||
walkable = true,
|
||||
groups = { cracky = 3, wall = 1, stone = 2 },
|
||||
sounds = wall_sounds,
|
||||
})
|
||||
|
||||
-- crafting recipe
|
||||
minetest.register_craft({
|
||||
output = wall_name .. " 6",
|
||||
recipe = {
|
||||
{ '', '', '' },
|
||||
{ wall_mat, wall_mat, wall_mat},
|
||||
{ wall_mat, wall_mat, wall_mat},
|
||||
}
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--CURRENT FENCE CODE REF
|
||||
--[[
|
||||
-- Fence registration helper
|
||||
--
|
||||
function default.register_fence(name, def)
|
||||
minetest.register_craft({
|
||||
output = name .. " 4",
|
||||
recipe = {
|
||||
{ def.material, 'group:stick', def.material },
|
||||
{ def.material, 'group:stick', def.material },
|
||||
}
|
||||
})
|
||||
|
||||
local fence_texture = "default_fence_overlay.png^" .. def.texture ..
|
||||
"^default_fence_overlay.png^[makealpha:255,126,126"
|
||||
-- Allow almost everything to be overridden
|
||||
local default_fields = {
|
||||
paramtype = "light",
|
||||
drawtype = "fencelike",
|
||||
inventory_image = fence_texture,
|
||||
wield_image = fence_texture,
|
||||
tiles = { def.texture },
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
|
||||
},
|
||||
groups = {},
|
||||
}
|
||||
for k, v in pairs(default_fields) do
|
||||
if not def[k] then
|
||||
def[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
-- Always add to the fence group, even if no group provided
|
||||
def.groups.fence = 1
|
||||
|
||||
def.texture = nil
|
||||
def.material = nil
|
||||
|
||||
minetest.register_node(name, def)
|
||||
end
|
||||
]]
|
||||
|
||||
walls.register("walls:cobble", "Cobblestone Wall", "default_cobble.png",
|
||||
"default:cobble", default.node_sound_stone_defaults())
|
||||
|
||||
walls.register("walls:mossycobble", "Mossy Cobblestone Wall", "default_mossycobble.png",
|
||||
"default:mossycobble", default.node_sound_stone_defaults())
|
||||
|
||||
walls.register("walls:desertcobble", "Desert Cobblestone Wall", "default_desert_cobble.png",
|
||||
"default:desert_cobble", default.node_sound_stone_defaults())
|
||||
|
@ -1,5 +1,5 @@
|
||||
Minetest 0.4 mod: wool
|
||||
======================
|
||||
Minetest Game mod: wool
|
||||
=======================
|
||||
|
||||
Mostly backward-compatible with jordach's 16-color wool mod.
|
||||
|
||||
|
@ -9,7 +9,7 @@ local wool = {}
|
||||
-- colors, and then some recipes using more specific colors for a few non-base
|
||||
-- colors available. When crafting, the last recipes will be checked first.
|
||||
wool.dyes = {
|
||||
{"white", "White", nil},
|
||||
{"white", "White", "basecolor_white"},
|
||||
{"grey", "Grey", "basecolor_grey"},
|
||||
{"black", "Black", "basecolor_black"},
|
||||
{"red", "Red", "basecolor_red"},
|
||||
@ -34,7 +34,7 @@ for _, row in ipairs(wool.dyes) do
|
||||
minetest.register_node("wool:"..name, {
|
||||
description = desc.." Wool",
|
||||
tiles = {"wool_"..name..".png"},
|
||||
--tiles = {"wool_white.png^[colorize:"..name..":170"},
|
||||
is_ground_content = false,
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,flammable=3,wool=1},
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
@ -1,5 +1,5 @@
|
||||
Minetest 0.4.x mod: xpanes
|
||||
==========================
|
||||
Minetest Game mod: xpanes
|
||||
=========================
|
||||
|
||||
License:
|
||||
--------
|
||||
|
@ -17,11 +17,7 @@ local function update_pane(pos, name)
|
||||
end
|
||||
local sum = 0
|
||||
for i, dir in pairs(directions) do
|
||||
local node = minetest.get_node({
|
||||
x = pos.x + dir.x,
|
||||
y = pos.y + dir.y,
|
||||
z = pos.z + dir.z
|
||||
})
|
||||
local node = minetest.get_node(vector.add(pos, dir))
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
local pane_num = def and def.groups.pane or 0
|
||||
if pane_num > 0 or not def or (def.walkable ~= false and
|
||||
@ -50,14 +46,13 @@ local function update_nearby(pos, node)
|
||||
name = name:sub(8, underscore_pos - 1)
|
||||
end
|
||||
for i, dir in pairs(directions) do
|
||||
update_pane({
|
||||
x = pos.x + dir.x,
|
||||
y = pos.y + dir.y,
|
||||
z = pos.z + dir.z
|
||||
}, name)
|
||||
update_pane(vector.add(pos, dir), name)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_placenode(update_nearby)
|
||||
minetest.register_on_dignode(update_nearby)
|
||||
|
||||
local half_boxes = {
|
||||
{0, -0.5, -1/32, 0.5, 0.5, 1/32},
|
||||
{-1/32, -0.5, 0, 1/32, 0.5, 0.5},
|
||||
@ -82,6 +77,18 @@ local sb_full_boxes = {
|
||||
{-0.06, -0.5, -0.5, 0.06, 0.5, 0.5}
|
||||
}
|
||||
|
||||
local pane_def_fields = {
|
||||
drawtype = "airlike",
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
air_equivalent = true,
|
||||
}
|
||||
|
||||
function xpanes.register_pane(name, def)
|
||||
for i = 1, 15 do
|
||||
local need = {}
|
||||
@ -132,6 +139,10 @@ function xpanes.register_pane(name, def)
|
||||
})
|
||||
end
|
||||
|
||||
for k, v in pairs(pane_def_fields) do
|
||||
def[k] = def[k] or v
|
||||
end
|
||||
|
||||
def.on_construct = function(pos)
|
||||
update_pane(pos, name)
|
||||
end
|
||||
@ -144,52 +155,29 @@ function xpanes.register_pane(name, def)
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_on_placenode(update_nearby)
|
||||
minetest.register_on_dignode(update_nearby)
|
||||
|
||||
xpanes.register_pane("pane", {
|
||||
description = "Glass Pane",
|
||||
tiles = {"xpanes_space.png"},
|
||||
drawtype = "airlike",
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
air_equivalent = true,
|
||||
textures = {"default_glass.png","xpanes_pane_half.png","xpanes_white.png"},
|
||||
inventory_image = "default_glass.png",
|
||||
wield_image = "default_glass.png",
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
groups = {snappy=2, cracky=3, oddly_breakable_by_hand=3, pane=1},
|
||||
recipe = {
|
||||
{'default:glass', 'default:glass', 'default:glass'},
|
||||
{'default:glass', 'default:glass', 'default:glass'}
|
||||
{"default:glass", "default:glass", "default:glass"},
|
||||
{"default:glass", "default:glass", "default:glass"}
|
||||
}
|
||||
})
|
||||
|
||||
xpanes.register_pane("bar", {
|
||||
description = "Iron bar",
|
||||
tiles = {"xpanes_space.png"},
|
||||
drawtype = "airlike",
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
air_equivalent = true,
|
||||
textures = {"xpanes_bar.png","xpanes_bar.png","xpanes_space.png"},
|
||||
inventory_image = "xpanes_bar.png",
|
||||
wield_image = "xpanes_bar.png",
|
||||
groups = {snappy=2, cracky=3, oddly_breakable_by_hand=3, pane=1},
|
||||
groups = {cracky=2, pane=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
recipe = {
|
||||
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
|
||||
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}
|
||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}
|
||||
}
|
||||
})
|
||||
|
||||
|