Add some mods
|
@ -0,0 +1,26 @@
|
|||
Minetest Game mod: beds
|
||||
=======================
|
||||
See license.txt for license information.
|
||||
|
||||
Authors of source code
|
||||
----------------------
|
||||
Originally by BlockMen (MIT)
|
||||
Various Minetest developers and contributors (MIT)
|
||||
|
||||
Authors of media (textures)
|
||||
---------------------------
|
||||
BlockMen (CC BY-SA 3.0)
|
||||
|
||||
This mod adds a bed to Minetest which allows to skip the night.
|
||||
To sleep, rightclick the bed. If playing in singleplayer mode the night gets skipped
|
||||
immediately. If playing multiplayer you get shown how many other players are in bed too,
|
||||
if all players are sleeping the night gets skipped. The night skip can be forced if more
|
||||
than 50% of the players are lying in bed and use this option.
|
||||
|
||||
Another feature is a controlled respawning. If you have slept in bed (not just lying in
|
||||
it) your respawn point 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 disable the night skip feature by setting "enable_bed_night_skip = false" in
|
||||
minetest.conf or by using the /set command in-game.
|
|
@ -0,0 +1,171 @@
|
|||
|
||||
local reverse = true
|
||||
|
||||
local function destruct_bed(pos, n)
|
||||
local node = minetest.get_node(pos)
|
||||
local other
|
||||
|
||||
if n == 2 then
|
||||
local dir = minetest.facedir_to_dir(node.param2)
|
||||
other = vector.subtract(pos, dir)
|
||||
elseif n == 1 then
|
||||
local dir = minetest.facedir_to_dir(node.param2)
|
||||
other = vector.add(pos, dir)
|
||||
end
|
||||
|
||||
if reverse then
|
||||
reverse = not reverse
|
||||
minetest.remove_node(other)
|
||||
minetest.check_for_falling(other)
|
||||
else
|
||||
reverse = not reverse
|
||||
end
|
||||
end
|
||||
|
||||
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 = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 1},
|
||||
sounds = def.sounds or default.node_sound_wood_defaults(),
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = def.nodebox.bottom,
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = def.selectionbox,
|
||||
},
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local under = pointed_thing.under
|
||||
local node = minetest.get_node(under)
|
||||
local udef = minetest.registered_nodes[node.name]
|
||||
if udef and udef.on_rightclick and
|
||||
not (placer and placer:is_player() and
|
||||
placer:get_player_control().sneak) then
|
||||
return udef.on_rightclick(under, node, placer, itemstack,
|
||||
pointed_thing) or itemstack
|
||||
end
|
||||
|
||||
local pos
|
||||
if udef and udef.buildable_to then
|
||||
pos = under
|
||||
else
|
||||
pos = pointed_thing.above
|
||||
end
|
||||
|
||||
local player_name = placer and placer:get_player_name() or ""
|
||||
|
||||
if minetest.is_protected(pos, player_name) and
|
||||
not minetest.check_player_privs(player_name, "protection_bypass") then
|
||||
minetest.record_protection_violation(pos, player_name)
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local node_def = minetest.registered_nodes[minetest.get_node(pos).name]
|
||||
if not node_def or not node_def.buildable_to then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local dir = placer and placer:get_look_dir() and
|
||||
minetest.dir_to_facedir(placer:get_look_dir()) or 0
|
||||
local botpos = vector.add(pos, minetest.facedir_to_dir(dir))
|
||||
|
||||
if minetest.is_protected(botpos, player_name) and
|
||||
not minetest.check_player_privs(player_name, "protection_bypass") then
|
||||
minetest.record_protection_violation(botpos, player_name)
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local botdef = minetest.registered_nodes[minetest.get_node(botpos).name]
|
||||
if not botdef or not botdef.buildable_to then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
minetest.set_node(pos, {name = name .. "_bottom", param2 = dir})
|
||||
minetest.set_node(botpos, {name = name .. "_top", param2 = dir})
|
||||
|
||||
if not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(player_name)) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_destruct = function(pos)
|
||||
destruct_bed(pos, 1)
|
||||
end,
|
||||
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
beds.on_rightclick(pos, clicker)
|
||||
return itemstack
|
||||
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 node_def = node3 and minetest.registered_nodes[node3.name]
|
||||
if not node_def or not node_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
|
||||
-- do not remove_node here - it will trigger destroy_bed()
|
||||
minetest.set_node(p, {name = "air"})
|
||||
minetest.set_node(pos, node)
|
||||
minetest.set_node(newp, {name = name .. "_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 = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 2},
|
||||
sounds = def.sounds or default.node_sound_wood_defaults(),
|
||||
drop = name .. "_bottom",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = def.nodebox.top,
|
||||
},
|
||||
on_destruct = function(pos)
|
||||
destruct_bed(pos, 2)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_alias(name, name .. "_bottom")
|
||||
|
||||
minetest.register_craft({
|
||||
output = name,
|
||||
recipe = def.recipe
|
||||
})
|
||||
end
|
|
@ -0,0 +1,102 @@
|
|||
-- Fancy shaped bed
|
||||
|
||||
beds.register_bed("beds:fancy_bed", {
|
||||
description = "Fancy Bed",
|
||||
inventory_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",
|
||||
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_bed_side_top.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_bed_side_bottom.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")
|
||||
|
||||
-- Fuel
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "beds:fancy_bed_bottom",
|
||||
burntime = 13,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "beds:bed_bottom",
|
||||
burntime = 12,
|
||||
})
|
|
@ -0,0 +1,2 @@
|
|||
default
|
||||
wool
|
|
@ -0,0 +1,192 @@
|
|||
local pi = math.pi
|
||||
local player_in_bed = 0
|
||||
local is_sp = minetest.is_singleplayer()
|
||||
local enable_respawn = minetest.settings:get_bool("enable_bed_respawn")
|
||||
if enable_respawn == nil then
|
||||
enable_respawn = true
|
||||
end
|
||||
|
||||
-- Helper functions
|
||||
|
||||
local function get_look_yaw(pos)
|
||||
local rotation = minetest.get_node(pos).param2
|
||||
if rotation > 3 then
|
||||
rotation = rotation % 4 -- Mask colorfacedir values
|
||||
end
|
||||
if rotation == 1 then
|
||||
return pi / 2, rotation
|
||||
elseif rotation == 3 then
|
||||
return -pi / 2, rotation
|
||||
elseif rotation == 0 then
|
||||
return pi, rotation
|
||||
else
|
||||
return 0, rotation
|
||||
end
|
||||
end
|
||||
|
||||
local function is_night_skip_enabled()
|
||||
local enable_night_skip = minetest.settings:get_bool("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
|
||||
-- lay down
|
||||
else
|
||||
beds.player[name] = 1
|
||||
player_in_bed = player_in_bed + 1
|
||||
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)
|
||||
end
|
||||
|
||||
function beds.on_rightclick(pos, player)
|
||||
local name = player:get_player_name()
|
||||
local ppos = player:getpos()
|
||||
|
||||
-- move to bed
|
||||
if not beds.player[name] then
|
||||
lay_down(player, ppos, pos)
|
||||
beds.set_spawns() -- save respawn positions when entering bed
|
||||
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(0, 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
|
||||
-- Only register respawn callback if respawn enabled
|
||||
if enable_respawn then
|
||||
-- respawn player at bed if enabled and valid position is found
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
local pos = beds.spawn[name]
|
||||
if pos then
|
||||
player:setpos(pos)
|
||||
return true
|
||||
end
|
||||
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)
|
|
@ -0,0 +1,17 @@
|
|||
beds = {}
|
||||
beds.player = {}
|
||||
beds.pos = {}
|
||||
beds.spawn = {}
|
||||
|
||||
beds.formspec = "size[8,15;true]" ..
|
||||
"bgcolor[#080808BB; true]" ..
|
||||
"button_exit[2,12;4,0.75;leave;Leave Bed]"
|
||||
|
||||
local modpath = minetest.get_modpath("beds")
|
||||
|
||||
-- Load files
|
||||
|
||||
dofile(modpath .. "/functions.lua")
|
||||
dofile(modpath .. "/api.lua")
|
||||
dofile(modpath .. "/beds.lua")
|
||||
dofile(modpath .. "/spawns.lua")
|
|
@ -0,0 +1,60 @@
|
|||
License of source code
|
||||
----------------------
|
||||
|
||||
The MIT License (MIT)
|
||||
Copyright (C) 2014-2016 BlockMen
|
||||
Copyright (C) 2014-2016 Various Minetest developers and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
software and associated documentation files (the "Software"), to deal in the Software
|
||||
without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more details:
|
||||
https://opensource.org/licenses/MIT
|
||||
|
||||
|
||||
Licenses of media (textures)
|
||||
----------------------------
|
||||
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
Copyright (C) 2014-2016 BlockMen
|
||||
|
||||
You are free to:
|
||||
Share — copy and redistribute the material in any medium or format.
|
||||
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
|
||||
The licensor cannot revoke these freedoms as long as you follow the license terms.
|
||||
|
||||
Under the following terms:
|
||||
|
||||
Attribution — You must give appropriate credit, provide a link to the license, and
|
||||
indicate if changes were made. You may do so in any reasonable manner, but not in any way
|
||||
that suggests the licensor endorses you or your use.
|
||||
|
||||
ShareAlike — If you remix, transform, or build upon the material, you must distribute
|
||||
your contributions under the same license as the original.
|
||||
|
||||
No additional restrictions — You may not apply legal terms or technological measures that
|
||||
legally restrict others from doing anything the license permits.
|
||||
|
||||
Notices:
|
||||
|
||||
You do not have to comply with the license for elements of the material in the public
|
||||
domain or where your use is permitted by an applicable exception or limitation.
|
||||
No warranties are given. The license may not give you all of the permissions necessary
|
||||
for your intended use. For example, other rights such as publicity, privacy, or moral
|
||||
rights may limit how you use the material.
|
||||
|
||||
For more details:
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
|
@ -0,0 +1,63 @@
|
|||
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()
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
beds.read_spawns()
|
||||
|
||||
function beds.save_spawns()
|
||||
if not beds.spawn then
|
||||
return
|
||||
end
|
||||
local data = {}
|
||||
local output = io.open(org_file, "w")
|
||||
for k, v in pairs(beds.spawn) do
|
||||
table.insert(data, string.format("%.1f %.1f %.1f %s\n", v.x, v.y, v.z, k))
|
||||
end
|
||||
output:write(table.concat(data))
|
||||
io.close(output)
|
||||
end
|
||||
|
||||
function beds.set_spawns()
|
||||
for name,_ in pairs(beds.player) do
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local p = player:getpos()
|
||||
-- but don't change spawn location if borrowing a bed
|
||||
if not minetest.is_protected(p, name) then
|
||||
beds.spawn[name] = p
|
||||
end
|
||||
end
|
||||
beds.save_spawns()
|
||||
end
|
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 509 B |
After Width: | Height: | Size: 525 B |
After Width: | Height: | Size: 398 B |
After Width: | Height: | Size: 386 B |
After Width: | Height: | Size: 524 B |
After Width: | Height: | Size: 517 B |
After Width: | Height: | Size: 478 B |
After Width: | Height: | Size: 500 B |
After Width: | Height: | Size: 758 B |
After Width: | Height: | Size: 726 B |
After Width: | Height: | Size: 689 B |
After Width: | Height: | Size: 644 B |
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -0,0 +1,86 @@
|
|||
minetest.register_node("bells:bronze_bell", {
|
||||
description = "Bronze Bell",
|
||||
drawtype = "mesh",
|
||||
tiles = {"default_bronze_block.png"},
|
||||
paramtype = "light",
|
||||
mesh = "bells_bell.obj",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.55, -0.5, -0.55, 0.55, 0.5, 0.55}
|
||||
},
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 2},
|
||||
on_punch = function (pos, node, puncher)
|
||||
minetest.sound_play('bells_bell_punch', {pos = pos, gain = 1.5, max_hear_distance = 2000});
|
||||
end,
|
||||
on_rightclick = function(pos, node, puncher)
|
||||
minetest.sound_play('bells_bell', {pos = pos, gain = 15, max_hear_distance = 1000});
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "bells:bronze_bell",
|
||||
recipe = {
|
||||
{"default:bronze_ingot", "default:bronze_ingot", "default:bronze_ingot"},
|
||||
{"default:bronze_ingot", "", "default:bronze_ingot"},
|
||||
{"default:bronze_ingot", "", "default:bronze_ingot"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("bells:silver_bell", {
|
||||
description = "Silver Bell",
|
||||
drawtype = "mesh",
|
||||
tiles = {"default_steel_block.png"},
|
||||
paramtype = "light",
|
||||
mesh = "bells_bell.obj",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.55, -0.5, -0.55, 0.55, 0.5, 0.55}
|
||||
},
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 2},
|
||||
on_punch = function (pos, node, puncher)
|
||||
minetest.sound_play('bells_bell_punch', {pos = pos, gain = 1.5, max_hear_distance = 2000});
|
||||
end,
|
||||
on_rightclick = function(pos, node, puncher)
|
||||
minetest.sound_play('bells_bell', {pos = pos, gain = 15, max_hear_distance = 1000});
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "bells:silver_bell",
|
||||
recipe = {
|
||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "", "default:steel_ingot"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("bells:iron_bell", {
|
||||
description = "Iron Bell",
|
||||
drawtype = "mesh",
|
||||
tiles = {"default_iron_block.png"},
|
||||
paramtype = "light",
|
||||
mesh = "bells_bell.obj",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.55, -0.5, -0.55, 0.55, 0.5, 0.55}
|
||||
},
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 2},
|
||||
on_punch = function (pos, node, puncher)
|
||||
minetest.sound_play('bells_bell_punch', {pos = pos, gain = 1.5, max_hear_distance = 2000});
|
||||
end,
|
||||
on_rightclick = function(pos, node, puncher)
|
||||
minetest.sound_play('bells_bell', {pos = pos, gain = 15, max_hear_distance = 1000});
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "bells:iron_bell",
|
||||
recipe = {
|
||||
{"default:iron_lump", "default:iron_lump", "default:iron_lump"},
|
||||
{"default:iron_lump", "", "default:iron_lump"},
|
||||
{"default:iron_lump", "", "default:iron_lump"},
|
||||
}
|
||||
})
|
|
@ -0,0 +1,10 @@
|
|||
original bell sound licensed under cc0 by dsp9000 from http://www.freesound.org/people/dsp9000/sounds/76405/
|
||||
modified by mootpoint licensed under cc0
|
||||
===========================================
|
||||
file name: church_bell_punch.ogg
|
||||
Author: Ulrich Metzner
|
||||
http://opengameart.org/content/church-bell
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
https://creativecommons.org/licenses/by-sa/3.0/
|
||||
original file name: churchbell.flac
|
||||
===========================================
|
|
@ -0,0 +1,15 @@
|
|||
Minetest Game mod: boats
|
||||
========================
|
||||
See license.txt for license information.
|
||||
|
||||
Authors of source code
|
||||
----------------------
|
||||
Originally by PilzAdam (MIT)
|
||||
Various Minetest developers and contributors (MIT)
|
||||
|
||||
Authors of media (textures and model)
|
||||
-------------------------------------
|
||||
Textures: Zeg9 (CC BY-SA 3.0)
|
||||
Model: thetoon and Zeg9 (CC BY-SA 3.0),
|
||||
modified by PavelS(SokolovPavel) (CC BY-SA 3.0),
|
||||
modified by sofar (CC BY-SA 3.0)
|
|
@ -0,0 +1,2 @@
|
|||
default
|
||||
player_api
|
|
@ -0,0 +1,275 @@
|
|||
--
|
||||
-- Helper functions
|
||||
--
|
||||
|
||||
local function is_water(pos)
|
||||
local nn = minetest.get_node(pos).name
|
||||
return minetest.get_item_group(nn, "water") ~= 0
|
||||
end
|
||||
|
||||
|
||||
local function get_sign(i)
|
||||
if i == 0 then
|
||||
return 0
|
||||
else
|
||||
return i / math.abs(i)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function get_velocity(v, yaw, y)
|
||||
local x = -math.sin(yaw) * v
|
||||
local z = math.cos(yaw) * v
|
||||
return {x = x, y = y, z = z}
|
||||
end
|
||||
|
||||
|
||||
local function get_v(v)
|
||||
return math.sqrt(v.x ^ 2 + v.z ^ 2)
|
||||
end
|
||||
|
||||
--
|
||||
-- Boat entity
|
||||
--
|
||||
|
||||
local boat = {
|
||||
physical = true,
|
||||
-- Warning: Do not change the position of the collisionbox top surface,
|
||||
-- lowering it causes the boat to fall through the world if underwater
|
||||
collisionbox = {-0.5, -0.35, -0.5, 0.5, 0.3, 0.5},
|
||||
visual = "mesh",
|
||||
mesh = "boats_boat.obj",
|
||||
textures = {"default_wood.png"},
|
||||
|
||||
driver = nil,
|
||||
v = 0,
|
||||
last_v = 0,
|
||||
removed = false
|
||||
}
|
||||
|
||||
|
||||
function boat.on_rightclick(self, clicker)
|
||||
if not clicker or not clicker:is_player() then
|
||||
return
|
||||
end
|
||||
local name = clicker:get_player_name()
|
||||
if self.driver and clicker == self.driver then
|
||||
self.driver = nil
|
||||
clicker:set_detach()
|
||||
player_api.player_attached[name] = false
|
||||
player_api.set_animation(clicker, "stand" , 30)
|
||||
local pos = clicker:getpos()
|
||||
pos = {x = pos.x, y = pos.y + 0.2, z = pos.z}
|
||||
minetest.after(0.1, function()
|
||||
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.5, y = 1, z = -3}, {x = 0, y = 0, z = 0})
|
||||
player_api.player_attached[name] = true
|
||||
minetest.after(0.2, function()
|
||||
player_api.set_animation(clicker, "sit" , 30)
|
||||
end)
|
||||
clicker:set_look_horizontal(self.object:getyaw())
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function boat.on_activate(self, staticdata, dtime_s)
|
||||
self.object:set_armor_groups({immortal = 1})
|
||||
if staticdata then
|
||||
self.v = tonumber(staticdata)
|
||||
end
|
||||
self.last_v = self.v
|
||||
end
|
||||
|
||||
|
||||
function boat.get_staticdata(self)
|
||||
return tostring(self.v)
|
||||
end
|
||||
|
||||
|
||||
function boat.on_punch(self, puncher)
|
||||
if not puncher or not puncher:is_player() or self.removed then
|
||||
return
|
||||
end
|
||||
if self.driver and puncher == self.driver then
|
||||
self.driver = nil
|
||||
puncher:set_detach()
|
||||
player_api.player_attached[puncher:get_player_name()] = false
|
||||
end
|
||||
if not self.driver then
|
||||
self.removed = true
|
||||
local inv = puncher:get_inventory()
|
||||
if not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(puncher:get_player_name()))
|
||||
or not inv:contains_item("main", "boats:boat") then
|
||||
local leftover = inv:add_item("main", "boats:boat")
|
||||
-- if no room in inventory add a replacement boat to the world
|
||||
if not leftover:is_empty() then
|
||||
minetest.add_item(self.object:getpos(), leftover)
|
||||
end
|
||||
end
|
||||
-- delay remove to ensure player is detached
|
||||
minetest.after(0.1, function()
|
||||
self.object:remove()
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function boat.on_step(self, dtime)
|
||||
self.v = get_v(self.object:getvelocity()) * get_sign(self.v)
|
||||
if self.driver then
|
||||
local ctrl = self.driver:get_player_control()
|
||||
local yaw = self.object:getyaw()
|
||||
if ctrl.up then
|
||||
self.v = self.v + 0.1
|
||||
elseif ctrl.down then
|
||||
self.v = self.v - 0.1
|
||||
end
|
||||
if ctrl.left then
|
||||
if self.v < 0 then
|
||||
self.object:setyaw(yaw - (1 + dtime) * 0.03)
|
||||
else
|
||||
self.object:setyaw(yaw + (1 + dtime) * 0.03)
|
||||
end
|
||||
elseif ctrl.right then
|
||||
if self.v < 0 then
|
||||
self.object:setyaw(yaw + (1 + dtime) * 0.03)
|
||||
else
|
||||
self.object:setyaw(yaw - (1 + dtime) * 0.03)
|
||||
end
|
||||
end
|
||||
end
|
||||
local velo = self.object:getvelocity()
|
||||
if self.v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
||||
self.object:setpos(self.object:getpos())
|
||||
return
|
||||
end
|
||||
local s = get_sign(self.v)
|
||||
self.v = self.v - 0.02 * s
|
||||
if s ~= get_sign(self.v) then
|
||||
self.object:setvelocity({x = 0, y = 0, z = 0})
|
||||
self.v = 0
|
||||
return
|
||||
end
|
||||
if math.abs(self.v) > 5 then
|
||||
self.v = 5 * get_sign(self.v)
|
||||
end
|
||||
|
||||
local p = self.object:getpos()
|
||||
p.y = p.y - 0.5
|
||||
local new_velo
|
||||
local new_acce = {x = 0, y = 0, z = 0}
|
||||
if not is_water(p) then
|
||||
local nodedef = minetest.registered_nodes[minetest.get_node(p).name]
|
||||
if (not nodedef) or nodedef.walkable then
|
||||
self.v = 0
|
||||
new_acce = {x = 0, y = 1, z = 0}
|
||||
else
|
||||
new_acce = {x = 0, y = -9.8, z = 0}
|
||||
end
|
||||
new_velo = get_velocity(self.v, self.object:getyaw(),
|
||||
self.object:getvelocity().y)
|
||||
self.object:setpos(self.object:getpos())
|
||||
else
|
||||
p.y = p.y + 1
|
||||
if is_water(p) then
|
||||
local y = self.object:getvelocity().y
|
||||
if y >= 5 then
|
||||
y = 5
|
||||
elseif y < 0 then
|
||||
new_acce = {x = 0, y = 20, z = 0}
|
||||
else
|
||||
new_acce = {x = 0, y = 5, z = 0}
|
||||
end
|
||||
new_velo = get_velocity(self.v, self.object:getyaw(), y)
|
||||
self.object:setpos(self.object:getpos())
|
||||
else
|
||||
new_acce = {x = 0, y = 0, z = 0}
|
||||
if math.abs(self.object:getvelocity().y) < 1 then
|
||||
local pos = self.object:getpos()
|
||||
pos.y = math.floor(pos.y) + 0.5
|
||||
self.object:setpos(pos)
|
||||
new_velo = get_velocity(self.v, self.object:getyaw(), 0)
|
||||
else
|
||||
new_velo = get_velocity(self.v, self.object:getyaw(),
|
||||
self.object:getvelocity().y)
|
||||
self.object:setpos(self.object:getpos())
|
||||
end
|
||||
end
|
||||
end
|
||||
self.object:setvelocity(new_velo)
|
||||
self.object:setacceleration(new_acce)
|
||||
end
|
||||
|
||||
|
||||
minetest.register_entity("boats:boat", boat)
|
||||
|
||||
|
||||
minetest.register_craftitem("boats:boat", {
|
||||
description = "Boat",
|
||||
inventory_image = "boats_inventory.png",
|
||||
wield_image = "boats_wield.png",
|
||||
wield_scale = {x = 2, y = 2, z = 1},
|
||||
liquids_pointable = true,
|
||||
groups = {flammable = 2},
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local under = pointed_thing.under
|
||||
local node = minetest.get_node(under)
|
||||
local udef = minetest.registered_nodes[node.name]
|
||||
if udef and udef.on_rightclick and
|
||||
not (placer and placer:is_player() and
|
||||
placer:get_player_control().sneak) then
|
||||
return udef.on_rightclick(under, node, placer, itemstack,
|
||||
pointed_thing) or itemstack
|
||||
end
|
||||
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
if not is_water(pointed_thing.under) then
|
||||
return itemstack
|
||||
end
|
||||
pointed_thing.under.y = pointed_thing.under.y + 0.5
|
||||
boat = minetest.add_entity(pointed_thing.under, "boats:boat")
|
||||
if boat then
|
||||
if placer then
|
||||
boat:setyaw(placer:get_look_horizontal())
|
||||
end
|
||||
local player_name = placer and placer:get_player_name() or ""
|
||||
if not (creative and creative.is_enabled_for and
|
||||
creative.is_enabled_for(player_name)) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "boats:boat",
|
||||
recipe = {
|
||||
{"", "", "" },
|
||||
{"group:wood", "", "group:wood"},
|
||||
{"group:wood", "group:wood", "group:wood"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "boats:boat",
|
||||
burntime = 20,
|
||||
})
|
|
@ -0,0 +1,63 @@
|
|||
License of source code
|
||||
----------------------
|
||||
|
||||
The MIT License (MIT)
|
||||
Copyright (C) 2012-2016 PilzAdam
|
||||
Copyright (C) 2012-2016 Various Minetest developers and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
software and associated documentation files (the "Software"), to deal in the Software
|
||||
without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more details:
|
||||
https://opensource.org/licenses/MIT
|
||||
|
||||
|
||||
Licenses of media (textures and model)
|
||||
--------------------------------------
|
||||
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
Copyright (C) 2012-2016 Zeg9
|
||||
Copyright (C) 2012-2016 thetoon
|
||||
Copyright (C) 2012-2016 PavelS(SokolovPavel)
|
||||
Copyright (C) 2016 sofar (sofar@foo-projects.org)
|
||||
|
||||
You are free to:
|
||||
Share — copy and redistribute the material in any medium or format.
|
||||
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
|
||||
The licensor cannot revoke these freedoms as long as you follow the license terms.
|
||||
|
||||
Under the following terms:
|
||||
|
||||
Attribution — You must give appropriate credit, provide a link to the license, and
|
||||
indicate if changes were made. You may do so in any reasonable manner, but not in any way
|
||||
that suggests the licensor endorses you or your use.
|
||||
|
||||
ShareAlike — If you remix, transform, or build upon the material, you must distribute
|
||||
your contributions under the same license as the original.
|
||||
|
||||
No additional restrictions — You may not apply legal terms or technological measures that
|
||||
legally restrict others from doing anything the license permits.
|
||||
|
||||
Notices:
|
||||
|
||||
You do not have to comply with the license for elements of the material in the public
|
||||
domain or where your use is permitted by an applicable exception or limitation.
|
||||
No warranties are given. The license may not give you all of the permissions necessary
|
||||
for your intended use. For example, other rights such as publicity, privacy, or moral
|
||||
rights may limit how you use the material.
|
||||
|
||||
For more details:
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
|
@ -0,0 +1,358 @@
|
|||
# Blender v2.76 (sub 11) OBJ File: 'boat.blend'
|
||||
# www.blender.org
|
||||
mtllib boat.mtl
|
||||
o boats_boat
|
||||
v -6.786140 -3.033999 -9.415440
|
||||
v -6.786140 -1.967150 -9.415440
|
||||
v -6.786140 -1.967150 8.793510
|
||||
v -6.786140 -3.033999 8.793510
|
||||
v 5.732520 -1.967150 -9.415440
|
||||
v 5.732520 -3.033999 -9.415440
|
||||
v 5.732520 -3.033999 8.793510
|
||||
v 5.732520 -1.967150 8.793510
|
||||
v -2.233900 -3.033999 -9.415440
|
||||
v -2.233900 -1.967150 -9.415440
|
||||
v -2.233900 -1.967150 8.793510
|
||||
v -2.233900 -3.033999 8.793510
|
||||
v 2.318340 -3.033999 -9.415440
|
||||
v 2.318340 -1.967150 -9.415440
|
||||
v 2.318340 -1.967150 8.793510
|
||||
v 2.318340 -3.033999 8.793510
|
||||
v -3.371960 -3.033999 8.793510
|
||||
v -3.371960 -1.967150 8.793510
|
||||
v -3.371960 -1.967150 -9.415440
|
||||
v -3.371960 -3.033999 -9.415440
|
||||
v 2.318340 0.276645 8.793510
|
||||
v 1.180280 -1.967150 8.793510
|
||||
v 5.732520 0.276645 8.793510
|
||||
v 5.732520 1.039180 8.793510
|
||||
v 6.870580 0.276645 8.793510
|
||||
v 6.870580 -1.967150 8.793510
|
||||
v 2.318340 1.039180 8.793510
|
||||
v 1.180280 0.276645 8.793510
|
||||
v 1.180280 1.039180 8.793510
|
||||
v 1.180280 -3.033999 8.793510
|
||||
v -2.233900 0.276645 8.793510
|
||||
v -3.371960 0.276645 8.793510
|
||||
v -2.233900 1.039180 8.793510
|
||||
v -3.371960 1.039180 8.793510
|
||||
v -6.786140 0.276645 8.793510
|
||||
v -7.786200 0.276645 8.793510
|
||||
v -7.786200 -1.967150 8.793510
|
||||
v -6.786140 1.039180 8.793510
|
||||
v 1.180280 -1.967150 -9.415440
|
||||
v 1.180280 -3.033999 -9.415440
|
||||
v 2.318340 0.276645 -9.415440
|
||||
v 1.180280 0.276645 -9.415440
|
||||
v 2.318340 1.039180 -9.415440
|
||||
v 5.732520 0.276645 -9.415440
|
||||
v 6.870580 -1.967150 -9.415440
|
||||
v 5.732520 1.039180 -9.415440
|
||||
v 6.870580 0.276645 -9.415440
|
||||
v 0.042220 1.039180 -9.415440
|
||||
v 1.180280 1.039180 -9.415440
|
||||
v 0.042220 -1.967150 -9.415440
|
||||
v -1.095840 -1.967150 -9.415440
|
||||
v -2.233900 0.276645 -9.415440
|
||||
v -3.371960 0.276645 -9.415440
|
||||
v -2.233900 1.039180 -9.415440
|
||||
v -1.095840 1.039180 -9.415440
|
||||
v -3.371960 1.039180 -9.415440
|
||||
v -6.786140 0.276645 -9.415440
|
||||
v -6.786140 1.039180 -9.415440
|
||||
v -7.786200 -1.967150 -9.415440
|
||||
v -7.786200 0.276645 -9.415440
|
||||
v -1.095840 0.156645 -12.044100
|
||||
v -1.095840 -4.601110 -9.415440
|
||||
v -1.095840 1.039181 -10.802900
|
||||
v -1.095840 2.868579 -10.802900
|
||||
v -1.095840 2.868580 -7.883420
|
||||
v -1.095840 3.746069 -12.034100
|
||||
v -1.095840 3.746070 -7.883420
|
||||
v -1.095840 0.156645 -14.294900
|
||||
v -1.095840 -4.601110 -14.284900
|
||||
v 0.042220 -4.601110 -14.284900
|
||||
v 0.042220 -4.601110 -9.415440
|
||||
v 0.042220 1.039181 -10.802900
|
||||
v 0.042220 0.156645 -12.044100
|
||||
v 0.042220 2.868579 -10.802900
|
||||
v 0.042220 0.156645 -14.294900
|
||||
v 0.042220 3.746069 -12.034100
|
||||
v 0.042220 3.746070 -7.883420
|
||||
v 0.042220 2.868580 -7.883420
|
||||
v -1.096322 -3.033999 -9.415440
|
||||
v 0.044046 -3.035397 -9.415440
|
||||
vt 1.000000 0.187500
|
||||
vt -1.000000 0.312500
|
||||
vt 1.000000 0.312500
|
||||
vt 0.687500 1.000000
|
||||
vt 0.500000 0.875000
|
||||
vt 0.500000 0.625000
|
||||
vt -1.000000 0.062500
|
||||
vt 1.000000 0.062500
|
||||
vt 1.000000 -0.000000
|
||||
vt -1.000000 0.125000
|
||||
vt 1.000000 0.125000
|
||||
vt 0.437500 0.125000
|
||||
vt 0.312500 0.500000
|
||||
vt 0.312500 0.125000
|
||||
vt 1.000000 0.625000
|
||||
vt -1.000000 0.500000
|
||||
vt 1.000000 0.500000
|
||||
vt 0.187500 0.687500
|
||||
vt -0.187500 0.687500
|
||||
vt -0.187500 0.312500
|
||||
vt 1.000000 0.812500
|
||||
vt -1.000000 0.937500
|
||||
vt -1.000000 0.812500
|
||||
vt 0.812500 0.687500
|
||||
vt 1.187500 0.687500
|
||||
vt 0.812500 0.312500
|
||||
vt 1.000000 0.562500
|
||||
vt 0.312500 0.437500
|
||||
vt 1.000000 0.437500
|
||||
vt 1.000000 0.750000
|
||||
vt -1.000000 0.875000
|
||||
vt -1.000000 0.750000
|
||||
vt -1.000000 1.000000
|
||||
vt 1.000000 1.000000
|
||||
vt 0.437500 0.625000
|
||||
vt 0.562500 0.437500
|
||||
vt 0.562500 0.625000
|
||||
vt -1.000000 0.437500
|
||||
vt -1.000000 0.000000
|
||||
vt 0.500000 0.062500
|
||||
vt 0.375000 0.750000
|
||||
vt 0.500000 0.750000
|
||||
vt -1.000000 0.250000
|
||||
vt -1.000000 0.687500
|
||||
vt 1.000000 0.687500
|
||||
vt 0.625000 0.375000
|
||||
vt 1.000000 0.375000
|
||||
vt 1.000000 0.250000
|
||||
vt 1.000000 0.937500
|
||||
vt 0.437500 0.812500
|
||||
vt 0.312500 0.312500
|
||||
vt 0.312500 0.812500
|
||||
vt 0.437500 0.312500
|
||||
vt 0.437500 0.437500
|
||||
vt 0.687500 0.812500
|
||||
vt 0.000000 0.687500
|
||||
vt 0.000000 0.812500
|
||||
vt -1.000000 0.562500
|
||||
vt 0.875000 0.812500
|
||||
vt 0.875000 0.687500
|
||||
vt 0.250000 0.312500
|
||||
vt 0.562500 0.187500
|
||||
vt 0.250000 0.187500
|
||||
vt -1.000000 0.187500
|
||||
vt 0.312500 0.625000
|
||||
vt 0.312500 0.187500
|
||||
vt 0.312500 -0.187500
|
||||
vt 1.000000 -0.187500
|
||||
vt 0.687500 0.500000
|
||||
vt -0.000000 1.000000
|
||||
vt 0.000000 0.875000
|
||||
vt 0.437500 0.500000
|
||||
vt -1.000000 0.625000
|
||||
vt 0.812500 0.187500
|
||||
vt 1.187500 0.187500
|
||||
vt 1.187500 0.312500
|
||||
vt 1.312500 0.312500
|
||||
vt 1.312500 0.687500
|
||||
vt 0.687500 0.187500
|
||||
vt 0.687500 0.312500
|
||||
vt 1.187500 0.812500
|
||||
vt 0.812500 0.812500
|
||||
vt 0.187500 0.312500
|
||||
vt 0.312500 0.687500
|
||||
vt 0.687500 0.687500
|
||||
vt -0.187500 0.187500
|
||||
vt 0.187500 0.187500
|
||||
vt -0.312500 0.687500
|
||||
vt -0.312500 0.312500
|
||||
vt 0.187500 0.812500
|
||||
vt -0.187500 0.812500
|
||||
vt 0.437500 0.687500
|
||||
vt 0.437500 0.187500
|
||||
vt 0.562500 0.812500
|
||||
vt 0.562500 0.687500
|
||||
vt 0.312500 0.562500
|
||||
vt 1.000000 0.875000
|
||||
vt 0.375000 0.062500
|
||||
vt -1.000000 0.375000
|
||||
vt 0.625000 0.500000
|
||||
vt 0.875000 0.562500
|
||||
vt 0.937500 0.812500
|
||||
vt 0.937500 0.687500
|
||||
vt 0.875000 0.937500
|
||||
vt 0.562500 0.312500
|
||||
vn -1.000000 0.000000 0.000000
|
||||
vn 1.000000 0.000000 0.000000
|
||||
vn 0.000000 0.000000 1.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.002100 -1.000000
|
||||
vn 0.001200 -1.000000 0.000000
|
||||
vn 0.000000 0.002800 -1.000000
|
||||
vn -0.001200 -1.000000 0.000200
|
||||
g boats_boat_boats_boat_None
|
||||
usemtl None
|
||||
s off
|
||||
f 41/1/1 27/2/1 43/3/1
|
||||
f 76/4/2 74/5/2 72/6/2
|
||||
f 8/7/2 6/1/2 5/8/2
|
||||
f 15/9/1 13/10/1 16/11/1
|
||||
f 51/12/3 71/13/3 50/14/3
|
||||
f 56/15/2 32/16/2 53/17/2
|
||||
f 15/18/3 8/19/3 23/20/3
|
||||
f 22/21/2 40/22/2 39/23/2
|
||||
f 19/24/4 2/25/4 53/26/4
|
||||
f 70/27/5 62/28/5 69/29/5
|
||||
f 11/30/5 19/31/5 10/32/5
|
||||
f 4/15/5 20/33/5 17/34/5
|
||||
f 72/35/3 64/36/3 63/37/3
|
||||
f 13/8/5 7/38/5 16/7/5
|
||||
f 23/39/6 47/11/6 44/9/6
|
||||
f 68/40/7 70/41/7 69/42/7
|
||||
f 80/43/8 40/10/8 30/11/8
|
||||
f 3/15/1 1/32/1 4/30/1
|
||||
f 20/44/2 18/27/2 17/45/2
|
||||
f 74/17/5 65/46/5 64/47/5
|
||||
f 31/43/1 54/47/1 52/48/1
|
||||
f 22/47/5 14/43/5 15/48/5
|
||||
f 46/1/2 23/7/2 44/8/2
|
||||
f 57/21/1 38/22/1 58/49/1
|
||||
f 61/50/9 76/51/9 73/52/9
|
||||
f 37/45/5 2/23/5 3/21/5
|
||||
f 78/28/3 67/53/3 65/54/3
|
||||
f 64/5/1 66/4/1 63/6/1
|
||||
f 76/55/6 67/56/6 77/57/6
|
||||
f 47/17/2 26/10/2 45/11/2
|
||||
f 5/16/5 26/47/5 8/17/5
|
||||
f 33/58/6 48/59/6 55/60/6
|
||||
f 29/38/2 42/3/2 49/29/2
|
||||
f 32/44/6 52/21/6 53/45/6
|
||||
f 58/15/6 34/33/6 56/34/6
|
||||
f 27/7/6 46/29/6 43/8/6
|
||||
f 73/61/6 68/62/6 61/63/6
|
||||
f 21/58/6 42/29/6 28/38/6
|
||||
f 11/29/1 9/58/1 12/27/1
|
||||
f 59/45/1 36/2/1 60/3/1
|
||||
f 60/9/6 35/10/6 57/11/6
|
||||
f 41/1/1 21/64/1 27/2/1
|
||||
f 72/6/2 48/65/2 50/66/2
|
||||
f 50/66/2 71/67/2 70/68/2
|
||||
f 70/68/2 75/17/2 73/69/2
|
||||
f 76/4/2 77/70/2 74/5/2
|
||||
f 77/70/2 78/71/2 74/5/2
|
||||
f 50/66/2 70/68/2 73/69/2
|
||||
f 73/69/2 76/4/2 72/6/2
|
||||
f 72/6/2 50/66/2 73/69/2
|
||||
f 8/7/2 7/64/2 6/1/2
|
||||
f 15/9/1 14/39/1 13/10/1
|
||||
f 51/12/3 62/72/3 71/13/3
|
||||
f 56/15/2 34/73/2 32/16/2
|
||||
f 32/26/3 34/74/3 38/75/3
|
||||
f 35/76/3 36/77/3 37/78/3
|
||||
f 32/26/3 38/75/3 35/76/3
|
||||
f 29/66/3 33/79/3 31/80/3
|
||||
f 32/26/3 35/76/3 3/25/3
|
||||
f 28/51/3 29/66/3 31/80/3
|
||||
f 31/80/3 32/26/3 18/24/3
|
||||
f 3/25/3 4/81/3 17/82/3
|
||||
f 35/76/3 37/78/3 3/25/3
|
||||
f 21/83/3 28/51/3 22/84/3
|
||||
f 3/25/3 17/82/3 18/24/3
|
||||
f 11/85/3 12/55/3 30/52/3
|
||||
f 32/26/3 3/25/3 18/24/3
|
||||
f 11/85/3 30/52/3 22/84/3
|
||||
f 31/80/3 18/24/3 11/85/3
|
||||
f 24/86/3 27/87/3 21/83/3
|
||||
f 28/51/3 31/80/3 11/85/3
|
||||
f 11/85/3 22/84/3 28/51/3
|
||||
f 24/86/3 21/83/3 23/20/3
|
||||
f 26/88/3 25/89/3 23/20/3
|
||||
f 23/20/3 21/83/3 15/18/3
|
||||
f 15/18/3 16/90/3 7/91/3
|
||||
f 21/83/3 22/84/3 15/18/3
|
||||
f 8/19/3 26/88/3 23/20/3
|
||||
f 15/18/3 7/91/3 8/19/3
|
||||
f 22/21/2 30/49/2 40/22/2
|
||||
f 47/89/4 45/88/4 5/19/4
|
||||
f 5/19/4 6/91/4 13/90/4
|
||||
f 5/19/4 13/90/4 14/18/4
|
||||
f 44/20/4 47/89/4 5/19/4
|
||||
f 43/87/4 46/86/4 44/20/4
|
||||
f 41/83/4 43/87/4 44/20/4
|
||||
f 44/20/4 5/19/4 14/18/4
|
||||
f 39/84/4 40/52/4 80/50/4
|
||||
f 44/20/4 14/18/4 41/83/4
|
||||
f 42/51/4 41/83/4 39/84/4
|
||||
f 39/84/4 80/50/4 50/92/4
|
||||
f 41/83/4 14/18/4 39/84/4
|
||||
f 48/93/4 49/66/4 42/51/4
|
||||
f 50/92/4 48/93/4 42/51/4
|
||||
f 80/50/4 79/94/4 50/92/4
|
||||
f 50/92/4 42/51/4 39/84/4
|
||||
f 54/79/4 55/62/4 52/80/4
|
||||
f 50/92/4 79/94/4 51/95/4
|
||||
f 52/80/4 55/62/4 51/95/4
|
||||
f 51/95/4 79/94/4 10/85/4
|
||||
f 79/94/4 9/55/4 10/85/4
|
||||
f 53/26/4 52/80/4 10/85/4
|
||||
f 58/75/4 56/74/4 53/26/4
|
||||
f 59/78/4 60/77/4 57/76/4
|
||||
f 57/76/4 58/75/4 53/26/4
|
||||
f 52/80/4 51/95/4 10/85/4
|
||||
f 19/24/4 20/82/4 1/81/4
|
||||
f 53/26/4 10/85/4 19/24/4
|
||||
f 59/78/4 57/76/4 2/25/4
|
||||
f 19/24/4 1/81/4 2/25/4
|
||||
f 2/25/4 57/76/4 53/26/4
|
||||
f 70/27/5 71/96/5 62/28/5
|
||||
f 11/30/5 18/97/5 19/31/5
|
||||
f 4/15/5 1/73/5 20/33/5
|
||||
f 72/35/3 74/54/3 64/36/3
|
||||
f 13/8/5 6/29/5 7/38/5
|
||||
f 23/39/6 25/10/6 47/11/6
|
||||
f 68/40/7 75/98/7 70/41/7
|
||||
f 30/11/5 12/17/5 79/99/5
|
||||
f 79/99/10 80/43/10 30/11/10
|
||||
f 12/17/5 9/16/5 79/99/5
|
||||
f 3/15/1 2/73/1 1/32/1
|
||||
f 20/44/2 19/58/2 18/27/2
|
||||
f 74/17/5 78/100/5 65/46/5
|
||||
f 31/43/1 33/99/1 54/47/1
|
||||
f 22/47/5 39/99/5 14/43/5
|
||||
f 46/1/2 24/64/2 23/7/2
|
||||
f 57/21/1 35/23/1 38/22/1
|
||||
f 61/50/9 66/53/9 76/51/9
|
||||
f 37/45/5 59/44/5 2/23/5
|
||||
f 78/28/3 77/51/3 67/53/3
|
||||
f 62/67/1 51/66/1 69/68/1
|
||||
f 51/66/1 55/65/1 63/6/1
|
||||
f 68/17/1 69/68/1 61/69/1
|
||||
f 61/69/1 69/68/1 51/66/1
|
||||
f 61/69/1 51/66/1 63/6/1
|
||||
f 65/71/1 67/70/1 64/5/1
|
||||
f 61/69/1 63/6/1 66/4/1
|
||||
f 64/5/1 67/70/1 66/4/1
|
||||
f 76/55/6 66/85/6 67/56/6
|
||||
f 47/17/2 25/16/2 26/10/2
|
||||
f 5/16/5 45/99/5 26/47/5
|
||||
f 55/60/6 54/101/6 33/58/6
|
||||
f 33/58/6 29/22/6 48/59/6
|
||||
f 48/59/6 72/102/6 63/103/6
|
||||
f 29/22/6 49/104/6 48/59/6
|
||||
f 48/59/6 63/103/6 55/60/6
|
||||
f 29/38/2 28/2/2 42/3/2
|
||||
f 32/44/6 31/23/6 52/21/6
|
||||
f 58/15/6 38/73/6 34/33/6
|
||||
f 27/7/6 24/38/6 46/29/6
|
||||
f 73/61/6 75/105/6 68/62/6
|
||||
f 21/58/6 41/27/6 42/29/6
|
||||
f 11/29/1 10/38/1 9/58/1
|
||||
f 59/45/1 37/44/1 36/2/1
|
||||
f 60/9/6 36/39/6 35/10/6
|
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 3.2 KiB |
|
@ -0,0 +1,30 @@
|
|||
Minetest 0.4 mod: bucket
|
||||
=========================
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
Copyright (C) 2011-2012 Kahrl <kahrl@gmx.net>
|
||||
Copyright (C) 2011-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
|
||||
License of media (textures and sounds)
|
||||
--------------------------------------
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
Authors of media files
|
||||
-----------------------
|
||||
Everything not listed in here:
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
Gambit (CC BY-SA 4.0):
|
||||
bucket.png
|
||||
bucket_lava.png
|
||||
bucket_water.png
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
default
|
||||
|
|
@ -0,0 +1,167 @@
|
|||
-- Minetest 0.4 mod: bucket
|
||||
-- See README.txt for licensing and other information.
|
||||
|
||||
minetest.register_alias("bucket", "bucket:bucket_empty")
|
||||
minetest.register_alias("bucket_water", "bucket:bucket_water")
|
||||
minetest.register_alias("bucket_lava", "bucket:bucket_lava")
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'bucket:bucket_empty 1',
|
||||
recipe = {
|
||||
{'group:metal_ingot', '', 'group:metal_ingot'},
|
||||
{'', 'group:metal_ingot', ''},
|
||||
}
|
||||
})
|
||||
|
||||
bucket = {}
|
||||
bucket.liquids = {}
|
||||
|
||||
local function check_protection(pos, name, text)
|
||||
if minetest.is_protected(pos, name) then
|
||||
minetest.log("action", (name ~= "" and name or "A mod")
|
||||
.. " tried to " .. text
|
||||
.. " at protected position "
|
||||
.. minetest.pos_to_string(pos)
|
||||
.. " with a bucket")
|
||||
minetest.record_protection_violation(pos, name)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Register a new liquid
|
||||
-- source = name of the source node
|
||||
-- flowing = name of the flowing node
|
||||
-- itemname = name of the new bucket item (or nil if liquid is not takeable)
|
||||
-- inventory_image = texture of the new bucket item (ignored if itemname == nil)
|
||||
-- This function can be called from any mod (that depends on bucket).
|
||||
function bucket.register_liquid(source, flowing, itemname, inventory_image, name)
|
||||
bucket.liquids[source] = {
|
||||
source = source,
|
||||
flowing = flowing,
|
||||
itemname = itemname,
|
||||
}
|
||||
bucket.liquids[flowing] = bucket.liquids[source]
|
||||
if not itemname then return end
|
||||
|
||||
minetest.register_craftitem(itemname, {
|
||||
description = name,
|
||||
inventory_image = inventory_image,
|
||||
stack_max = 1,
|
||||
liquids_pointable = true,
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
-- Must be pointing to node
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
|
||||
local node = minetest.get_node_or_nil(pointed_thing.under)
|
||||
local ndef
|
||||
if node then
|
||||
ndef = minetest.registered_nodes[node.name]
|
||||
end
|
||||
-- Call on_rightclick if the pointed node defines it
|
||||
if ndef and ndef.on_rightclick and
|
||||
user and not user:get_player_control().sneak then
|
||||
return ndef.on_rightclick(
|
||||
pointed_thing.under,
|
||||
node, user,
|
||||
itemstack) or itemstack
|
||||
end
|
||||
|
||||
local place_liquid = function(pos, node, source, flowing)
|
||||
if check_protection(pos,
|
||||
user and user:get_player_name() or "",
|
||||
"place "..source) then
|
||||
return
|
||||
end
|
||||
minetest.add_node(pos, {name=source})
|
||||
end
|
||||
|
||||
-- Check if pointing to a buildable node
|
||||
if ndef and ndef.buildable_to then
|
||||
-- Buildable; replace the node
|
||||
place_liquid(pointed_thing.under, node, source, flowing)
|
||||
else
|
||||
-- Not buildable to; place the liquid above
|
||||
-- Check if the node above can be replaced
|
||||
local node = minetest.get_node_or_nil(pointed_thing.above)
|
||||
if node and minetest.registered_nodes[node.name].buildable_to then
|
||||
place_liquid(pointed_thing.above, node, source, flowing)
|
||||
else
|
||||
-- Do not remove the bucket with the liquid
|
||||
return
|
||||
end
|
||||
end
|
||||
return {name="bucket:bucket_empty"}
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_craftitem("bucket:bucket_empty", {
|
||||
description = "Empty Bucket",
|
||||
inventory_image = "bucket.png",
|
||||
liquids_pointable = true,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
-- Must be pointing to node
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
-- Check if pointing to a liquid source
|
||||
local node = minetest.get_node(pointed_thing.under)
|
||||
local liquiddef = bucket.liquids[node.name]
|
||||
if liquiddef ~= nil and liquiddef.itemname ~= nil and
|
||||
node.name == liquiddef.source then
|
||||
if check_protection(pointed_thing.under,
|
||||
user:get_player_name(),
|
||||
"take ".. node.name) then
|
||||
return
|
||||
end
|
||||
|
||||
-- Only one bucket: replace
|
||||
local count = itemstack:get_count()
|
||||
if count == 1 then
|
||||
minetest.add_node(pointed_thing.under, {name="air"})
|
||||
return ItemStack({name = liquiddef.itemname,
|
||||
metadata = tostring(node.param2)})
|
||||
end
|
||||
|
||||
-- Staked buckets: add a filled bucket, replace stack
|
||||
local inv = user:get_inventory()
|
||||
if inv:room_for_item("main", liquiddef.itemname) then
|
||||
minetest.add_node(pointed_thing.under, {name="air"})
|
||||
count = count - 1
|
||||
itemstack:set_count(count)
|
||||
bucket_liquid = ItemStack(liquiddef.itemname)
|
||||
inv:add_item("main", bucket_liquid)
|
||||
return itemstack
|
||||
else
|
||||
minetest.chat_send_player(user:get_player_name(), "Your inventory is full.")
|
||||
end
|
||||
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
bucket.register_liquid(
|
||||
"default:water_source",
|
||||
"default:water_flowing",
|
||||
"bucket:bucket_water",
|
||||
"bucket_water.png",
|
||||
"Water Bucket"
|
||||
)
|
||||
|
||||
bucket.register_liquid(
|
||||
"default:lava_source",
|
||||
"default:lava_flowing",
|
||||
"bucket:bucket_lava",
|
||||
"bucket_lava.png",
|
||||
"Lava Bucket"
|
||||
)
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "bucket:bucket_lava",
|
||||
burntime = 60,
|
||||
replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}},
|
||||
})
|
After Width: | Height: | Size: 475 B |
After Width: | Height: | Size: 320 B |
After Width: | Height: | Size: 526 B |
|
@ -0,0 +1,29 @@
|
|||
Conifer
|
||||
=======
|
||||
|
||||
Rewrite of Cisouns original mod "Conifers".
|
||||
https://forum.minetest.net/viewtopic.php?pid=17541
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
|
||||
License of media (textures and sounds)
|
||||
--------------------------------------
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
Authors of media files
|
||||
-----------------------
|
||||
|
||||
Cisoun (CC BY-SA 4.0):
|
||||
nodetest_coniferleaves_1.png
|
||||
nodetest_coniferleaves_2.png
|
||||
nodetest_conifersapling.png
|
||||
nodetest_conifertree.png
|
||||
nodetest_conifertree_top.png
|
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -0,0 +1,165 @@
|
|||
conifer = {}
|
||||
|
||||
minetest.register_alias("mapgen_pine_tree", "conifer:tree")
|
||||
minetest.register_alias("mapgen_pine_needles", "conifer:leaves_1")
|
||||
|
||||
--
|
||||
-- Nodes
|
||||
--
|
||||
|
||||
minetest.register_node("conifer:sapling", {
|
||||
description = "Conifer Sapling",
|
||||
drawtype = "plantlike",
|
||||
visual_scale = 1.0,
|
||||
tiles = {"conifer_sapling.png"},
|
||||
inventory_image = "conifer_sapling.png",
|
||||
wield_image = "conifer_sapling.png",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
floodable = true,
|
||||
waving = 1,
|
||||
on_timer = function(pos)
|
||||
local below = {x=pos.x, y=pos.y-1, z=pos.z}
|
||||
local name = minetest.get_node(below).name
|
||||
if minetest.get_item_group(name, "soil") ~= 0 then
|
||||
conifer.grow_conifersapling(pos)
|
||||
end
|
||||
end,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
|
||||
},
|
||||
groups = {snappy=2, sapling=1, flammable=2, attached_node = 1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(math.random(300, 4800))
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_alias("conifers:sapling", "conifer:sapling")
|
||||
minetest.register_alias("nodetest:conifersapling", "conifer:sapling")
|
||||
|
||||
minetest.register_node("conifer:tree", {
|
||||
description = "Conifer Tree",
|
||||
tiles = {"conifer_tree_top.png", "conifer_tree_top.png", "conifer_tree.png"},
|
||||
groups = {tree=1, choppy=2, flammable=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
paramtype2 = "facedir",
|
||||
on_place = minetest.rotate_node
|
||||
})
|
||||
|
||||
minetest.register_alias("conifers:trunk", "conifer:tree")
|
||||
minetest.register_alias("nodetest:conifertree", "conifer:tree")
|
||||
|
||||
for i=1,2 do
|
||||
minetest.register_node("conifer:leaves_"..i, {
|
||||
description = "Conifer Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
visual_scale = 1.3,
|
||||
tiles = {"conifer_leaves_"..i..".png"},
|
||||
paramtype = "light",
|
||||
waving = 1,
|
||||
trunk = "conifer:tree",
|
||||
groups = {
|
||||
snappy=3,
|
||||
leafdecay=4,
|
||||
flammable=2,
|
||||
leaves=1,
|
||||
fall_damage_add_percent=default.COUSHION
|
||||
},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
-- player will get sapling with 1/rarity chance
|
||||
items = {'conifer:sapling'},
|
||||
rarity = 40,
|
||||
},
|
||||
{
|
||||
-- player will get leaves only if he get no saplings,
|
||||
-- this is because max_items is 1
|
||||
items = {"conifer:leaves_"..i..""},
|
||||
}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("conifer:pine_cone_leaves_"..i, {
|
||||
description = "Conifer Cone Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
visual_scale = 1.3,
|
||||
tiles = {"conifer_leaves_"..i..".png^conifer_pine_cone_leaves.png"},
|
||||
paramtype = "light",
|
||||
waving = 1,
|
||||
groups = {
|
||||
snappy=3,
|
||||
leafdecay=4,
|
||||
flammable=2,
|
||||
leaves=1,
|
||||
fall_damage_add_percent=default.COUSHION
|
||||
},
|
||||
drop = "conifer:pine_cone",
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
minetest.register_alias("nodetest:coniferleaves_"..i, "conifer:leaves_"..i)
|
||||
end
|
||||
|
||||
minetest.register_node("conifer:pine_cone", {
|
||||
description = "Conifer Cone",
|
||||
drawtype = "plantlike",
|
||||
visual_scale = 1.0,
|
||||
tiles = {"conifer_pine_cone.png"},
|
||||
inventory_image = "conifer_pine_cone.png",
|
||||
wield_image = "conifer_pine_cone.png",
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
is_ground_content = false,
|
||||
buildable_to = true,
|
||||
floodable = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
|
||||
},
|
||||
groups = {fleshy=3, dig_immediate=3, flammable=2, attached_node=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("conifer:cooked_pine_cone", {
|
||||
description = "Cooked Conifer Cone",
|
||||
drawtype = "plantlike",
|
||||
visual_scale = 1.0,
|
||||
tiles = {"conifer_cooked_pine_cone.png"},
|
||||
inventory_image = "conifer_cooked_pine_cone.png",
|
||||
wield_image = "conifer_cooked_pine_cone.png",
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
is_ground_content = false,
|
||||
buildable_to = true,
|
||||
floodable = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
|
||||
},
|
||||
groups = {fleshy=3, dig_immediate=3, flammable=2, attached_node=1},
|
||||
on_use = minetest.item_eat(1),
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "conifer:cooked_pine_cone",
|
||||
recipe = "conifer:pine_cone",
|
||||
})
|
||||
|
||||
--
|
||||
-- Crafting definition
|
||||
--
|
||||
|
||||
dofile(minetest.get_modpath("conifer").."/trees.lua")
|
After Width: | Height: | Size: 403 B |
After Width: | Height: | Size: 512 B |
After Width: | Height: | Size: 247 B |
After Width: | Height: | Size: 466 B |
After Width: | Height: | Size: 333 B |
After Width: | Height: | Size: 268 B |
After Width: | Height: | Size: 688 B |
After Width: | Height: | Size: 763 B |
|
@ -0,0 +1,110 @@
|
|||
local random = math.random
|
||||
|
||||
local c_air = minetest.get_content_id("air")
|
||||
local c_leaves_1 = minetest.get_content_id("conifer:leaves_1")
|
||||
local c_leaves_2 = minetest.get_content_id("conifer:leaves_2")
|
||||
local c_snow = minetest.get_content_id("default:snow")
|
||||
|
||||
local function add_trunk_and_leaves(data, a, pos, tree_cid, leaves_special, height, snow)
|
||||
local x, y, z = pos.x, pos.y, pos.z
|
||||
local leaves_cid = c_leaves_1
|
||||
if leaves_special then leaves_cid = c_leaves_2 else end
|
||||
|
||||
-- Trunk
|
||||
for y_dist = 0, height - 1 do
|
||||
local vi = a:index(x, y + y_dist, z)
|
||||
if y_dist == 0 or data[vi] == c_air or data[vi] == c_leaves_1 or data[vi] == c_leaves_2 then
|
||||
data[vi] = tree_cid
|
||||
end
|
||||
end
|
||||
|
||||
-- Add rings of leaves randomly
|
||||
local d = 0
|
||||
for yi = height+1, 4 + random(0, 2), -1 do
|
||||
for xi = -d, d do
|
||||
for zi = -d, d do
|
||||
if math.abs(xi) + math.abs(zi) <= d or math.abs(zi) + math.abs(xi) <= d then
|
||||
local vi = a:index(x + xi, y + yi, z + zi)
|
||||
if data[vi] == c_air then
|
||||
if leaves_special then
|
||||
data[vi] = c_leaves_2
|
||||
else
|
||||
data[vi] = c_leaves_1
|
||||
end
|
||||
-- Cover in snow
|
||||
if snow and random(1, 2) == 1 then
|
||||
local vi_snow = a:index(x + xi, y + yi + 1, z + zi)
|
||||
if data[vi_snow] == c_air then
|
||||
data[vi_snow] = c_snow
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
d = d + 1
|
||||
if d > random(2,4) then d = 1 end
|
||||
end
|
||||
end
|
||||
|
||||
local c_tree = minetest.get_content_id("conifer:tree")
|
||||
|
||||
function conifer.grow_tree(pos, leaves_special, snow)
|
||||
local x, y, z = pos.x, pos.y, pos.z
|
||||
local height = random(12, 24)
|
||||
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local minp, maxp = vm:read_from_map(
|
||||
{x = pos.x - 3, y = pos.y - 1, z = pos.z - 3},
|
||||
{x = pos.x + 3, y = pos.y + height + 1, z = pos.z + 3}
|
||||
)
|
||||
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
|
||||
local data = vm:get_data()
|
||||
|
||||
add_trunk_and_leaves(data, a, pos, c_tree, leaves_special, height, snow)
|
||||
|
||||
-- Roots
|
||||
for xi = -1, 1 do
|
||||
local vi_1 = a:index(x+xi, y, z)
|
||||
local vi_2 = a:index(x+xi, y-1, z)
|
||||
if data[vi_2] == c_air then
|
||||
data[vi_2] = c_tree
|
||||
elseif data[vi_1] == c_air then
|
||||
data[vi_1] = c_tree
|
||||
end
|
||||
end
|
||||
for zi = -1, 1 do
|
||||
local vi_1 = a:index(x, y, z+zi)
|
||||
local vi_2 = a:index(x, y-1, z+zi)
|
||||
if data[vi_2] == c_air then
|
||||
data[vi_2] = c_tree
|
||||
elseif data[vi_1] == c_air then
|
||||
data[vi_1] = c_tree
|
||||
end
|
||||
end
|
||||
|
||||
vm:set_data(data)
|
||||
vm:write_to_map()
|
||||
vm:update_map()
|
||||
end
|
||||
|
||||
function conifer.grow_conifersapling(pos)
|
||||
if not default.can_grow(pos) then return true end
|
||||
if minetest.find_node_near(pos, 3, {"group:tree", "group:sapling"}) then
|
||||
minetest.set_node(pos, {name="default:grass_"..math.random(1, 5)})
|
||||
return
|
||||
end
|
||||
if not default.enough_light(pos) then
|
||||
minetest.get_node_timer(pos):start(math.random(60, 960))
|
||||
return
|
||||
end
|
||||
conifer.grow_tree(pos, random(1, 4) == 1)
|
||||
end
|
||||
|
||||
minetest.register_lbm({
|
||||
name = "conifer:convert_saplings_to_node_timer",
|
||||
nodenames = {"conifer:sapling"},
|
||||
action = function(pos)
|
||||
minetest.get_node_timer(pos):start(random(600, 4800))
|
||||
end
|
||||
})
|
|
@ -0,0 +1,9 @@
|
|||
« Copyright © 2015-2017, Jean-Patrick Guerrero <jeanpatrick.guerrero@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
The Software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders X be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software.
|
||||
|
||||
Except as contained in this notice, the name of the <copyright holders> shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the <copyright holders>. »
|
|
@ -0,0 +1 @@
|
|||
sfinv_buttons?
|
|
@ -0,0 +1,406 @@
|
|||
local craftguide, datas, minetest = {}, {}, minetest
|
||||
local progressive_mode = minetest.setting_getbool("craftguide_progressive_mode")
|
||||
local get_recipe, get_recipes = minetest.get_craft_recipe, minetest.get_all_craft_recipes
|
||||
local get_result, show_formspec = minetest.get_craft_result, minetest.show_formspec
|
||||
local reg_items = minetest.registered_items
|
||||
|
||||
-- Lua 5.3 removed `table.maxn`, use this alternative in case of breakage:
|
||||
-- https://github.com/kilbith/xdecor/blob/master/handlers/helpers.lua#L1
|
||||
local remove, maxn, sort = table.remove, table.maxn, table.sort
|
||||
local min, max, floor, ceil = math.min, math.max, math.floor, math.ceil
|
||||
|
||||
local group_stereotypes = {
|
||||
wool = "wool:white",
|
||||
dye = "dye:white",
|
||||
water_bucket = "bucket:bucket_water",
|
||||
coal = "default:coal_lump",
|
||||
flower = "flowers:dandelion_yellow",
|
||||
}
|
||||
|
||||
function craftguide:group_to_item(item)
|
||||
if item:sub(1,6) == "group:" then
|
||||
local itemsub = item:sub(7)
|
||||
if group_stereotypes[itemsub] then
|
||||
item = group_stereotypes[itemsub]
|
||||
elseif reg_items["default:" .. itemsub] then
|
||||
item = item:gsub("group:", "default:")
|
||||
else
|
||||
for name, def in pairs(reg_items) do
|
||||
if def.groups[item:match("[^,:]+$")] then
|
||||
item = name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return item:sub(1,6) == "group:" and "" or item
|
||||
end
|
||||
|
||||
local function extract_groups(str)
|
||||
if str:sub(1,6) ~= "group:" then return end
|
||||
return str:sub(7):split(",")
|
||||
end
|
||||
|
||||
local function colorize(str)
|
||||
-- If client <= 0.4.14, don't colorize for compatibility.
|
||||
return minetest.colorize and minetest.colorize("#FFFF00", str) or str
|
||||
end
|
||||
|
||||
local function get_fueltime(item)
|
||||
return get_result({method = "fuel", width = 1, items = {item}}).time
|
||||
end
|
||||
|
||||
function craftguide:get_tooltip(item, recipe_type, cooktime, groups)
|
||||
local tooltip, item_desc = "tooltip[" .. item .. ";", ""
|
||||
local fueltime = get_fueltime(item)
|
||||
local has_extras = groups or recipe_type == "cooking" or fueltime > 0
|
||||
|
||||
if reg_items[item] then
|
||||
if not groups then
|
||||
item_desc = reg_items[item].description
|
||||
end
|
||||
else
|
||||
return tooltip .. "Unknown Item (" .. item .. ")]"
|
||||
end
|
||||
|
||||
if groups then
|
||||
local groupstr = "Any item belonging to the "
|
||||
for i=1, #groups do
|
||||
groupstr = groupstr .. colorize(groups[i]) ..
|
||||
(groups[i + 1] and " and " or "")
|
||||
end
|
||||
tooltip = tooltip .. groupstr .. " group(s)"
|
||||
end
|
||||
|
||||
if recipe_type == "cooking" then
|
||||
tooltip = tooltip .. item_desc .. "\nCooking time: " .. colorize(cooktime)
|
||||
end
|
||||
|
||||
if fueltime > 0 then
|
||||
tooltip = tooltip .. item_desc .. "\nBurning time: " .. colorize(fueltime)
|
||||
end
|
||||
|
||||
return has_extras and tooltip .. "]" or ""
|
||||
end
|
||||
|
||||
function craftguide:get_recipe(iY, xoffset, tooltip, item, recipe_num, recipes)
|
||||
local formspec, recipes_total = "", #recipes
|
||||
if recipes_total > 1 then
|
||||
formspec = formspec ..
|
||||
"button[6,0.81;3,1;alternate;Alternate (Recipe "..recipe_num .." of "..recipes_total..")]"
|
||||
end
|
||||
|
||||
local recipe_type = recipes[recipe_num].type
|
||||
local items = recipes[recipe_num].items
|
||||
local width = recipes[recipe_num].width
|
||||
|
||||
if recipe_type == "cooking" or (recipe_type == "normal" and width == 0) then
|
||||
local icon = recipe_type == "cooking" and "furnace" or "shapeless"
|
||||
formspec = formspec ..
|
||||
"image[9,2.81;1,1;craftguide_" .. icon .. ".png]"
|
||||
else
|
||||
formspec = formspec ..
|
||||
"image[9,2.81;1,1;craftguide_arrow.png]"
|
||||
end
|
||||
|
||||
if width == 0 then width = min(3, #items) end
|
||||
local rows = ceil(maxn(items) / width)
|
||||
local btn_size, craftgrid_limit = 1, 5
|
||||
|
||||
if recipe_type == "normal" and
|
||||
width > craftgrid_limit or rows > craftgrid_limit then
|
||||
else
|
||||
for i, v in pairs(items) do
|
||||
local X = (i - 1) % width + 6
|
||||
local Y = ceil(i / width + (iY + 2) - min(2, rows)) - 3.17
|
||||
|
||||
if recipe_type == "normal" and width > 3 or rows > 3 then
|
||||
btn_size = width > 3 and 3 / width or 3 / rows
|
||||
X = btn_size * (i % width) + 6
|
||||
Y = btn_size * floor((i - 1) / width) + (iY + 3) - min(2, rows) - 3.17
|
||||
end
|
||||
|
||||
local groups = extract_groups(v)
|
||||
local label = groups and "\nG" or ""
|
||||
local item_r = self:group_to_item(v)
|
||||
local tltip = self:get_tooltip(item_r, recipe_type, width, groups)
|
||||
|
||||
formspec = formspec ..
|
||||
"item_image_button["..X..","..Y..";"..btn_size..","..btn_size..";"..item_r..";"..item_r..";"..label.."]"..tltip
|
||||
end
|
||||
end
|
||||
local output = recipes[recipe_num].output
|
||||
return formspec ..
|
||||
"item_image_button[10,2.81;1,1;"..output..";"..item..";]"..tooltip
|
||||
end
|
||||
|
||||
function craftguide:get_formspec(player_name, is_fuel)
|
||||
local data = datas[player_name]
|
||||
local iY = data.iX - 5
|
||||
|
||||
if not data.items then
|
||||
data.items = datas.init_items
|
||||
end
|
||||
data.pagemax = max(1, ceil(#data.items / (6*4)))
|
||||
|
||||
local formspec = "size[13.3,7.3]"..
|
||||
--"image[-0.3,-0.315;16.9,9.15;craftguide_bg.png]"..
|
||||
"image_button[3.28,-0.01;1.05,0.85;;clear;Clear]"..
|
||||
"image_button[2.4,-0.01;1.05,0.85;;search;Search]"..
|
||||
"image_button[0.28,6.83;1.64,0.7;;prev;<<]"..
|
||||
"image_button[2.7,6.83;1.64,0.7;;next;>>]"..
|
||||
"label[2.0,6.88;"..tostring(data.pagenum).."/"..tostring(data.pagemax).."]"..
|
||||
"field[0.58,0.23;2.27,1;filter;;"..minetest.formspec_escape(data.filter).."]"..
|
||||
"field_close_on_enter[filter;false]"
|
||||
|
||||
local even_num = data.iX % 2 == 0
|
||||
local xoffset = data.iX / 2 + (even_num and 0.5 or 0)
|
||||
|
||||
if not next(data.items) then end
|
||||
|
||||
local first_item = (data.pagenum - 1) * (6*4)
|
||||
for i = first_item, first_item + (6*4) - 1 do
|
||||
local name = data.items[i + 1]
|
||||
if not name then break end
|
||||
local X = i % 4 + 0.3
|
||||
local Y = ((i % (6*4) - X) / data.iX * 2.22) + 0.91
|
||||
|
||||
-- local pagenum = math.floor(start_i / (6*4) + 1)
|
||||
-- local pagemax = math.ceil(inv.size / (6*4))
|
||||
|
||||
formspec = formspec ..
|
||||
"item_image_button["..X..","..Y..";1,1;"..name..";"..name.."_inv;]"
|
||||
end
|
||||
|
||||
if data.item and reg_items[data.item] then
|
||||
local tooltip = self:get_tooltip(data.item)
|
||||
if not data.recipes_item or (is_fuel and not get_recipe(data.item).items) then
|
||||
formspec = formspec ..
|
||||
"image[10,2.81;1,1;craftguide_scorched_stuff.png]"..
|
||||
"image[9,2.81;1,1;default_furnace_fire_fg.png]"..
|
||||
"item_image_button[8,2.81;1,1;"..data.item..";"..data.item..";]".. tooltip
|
||||
else
|
||||
formspec = formspec ..
|
||||
self:get_recipe(iY, xoffset, tooltip, data.item,
|
||||
data.recipe_num, data.recipes_item)
|
||||
end
|
||||
end
|
||||
|
||||
data.formspec = formspec
|
||||
show_formspec(player_name, "craftguide", formspec)
|
||||
end
|
||||
|
||||
local function player_has_item(T)
|
||||
for i = 1, #T do
|
||||
if T[i] then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function group_to_items(group)
|
||||
local items_with_group, counter = {}, 0
|
||||
for name, def in pairs(reg_items) do
|
||||
if def.groups[group:sub(7)] then
|
||||
counter = counter + 1
|
||||
items_with_group[counter] = name
|
||||
end
|
||||
end
|
||||
|
||||
return items_with_group
|
||||
end
|
||||
|
||||
local function item_in_inv(inv, item)
|
||||
return inv:contains_item("main", item)
|
||||
end
|
||||
|
||||
function craftguide:recipe_in_inv(inv, item_name, recipes_f)
|
||||
local recipes = recipes_f or get_recipes(item_name) or {}
|
||||
local show_item_recipes = {}
|
||||
|
||||
for i=1, #recipes do
|
||||
show_item_recipes[i] = true
|
||||
for _, item in pairs(recipes[i].items) do
|
||||
local group_in_inv = false
|
||||
if item:sub(1,6) == "group:" then
|
||||
local groups = group_to_items(item)
|
||||
for j = 1, #groups do
|
||||
if item_in_inv(inv, groups[j]) then
|
||||
group_in_inv = true
|
||||
end
|
||||
end
|
||||
end
|
||||
if not group_in_inv and not item_in_inv(inv, item) then
|
||||
show_item_recipes[i] = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for i = #show_item_recipes, 1, -1 do
|
||||
if not show_item_recipes[i] then
|
||||
remove(recipes, i)
|
||||
end
|
||||
end
|
||||
|
||||
return recipes, player_has_item(show_item_recipes)
|
||||
end
|
||||
|
||||
function craftguide:get_init_items()
|
||||
local items_list, counter = {}, 0
|
||||
for name, def in pairs(reg_items) do
|
||||
local is_fuel = get_fueltime(name) > 0
|
||||
if not (def.groups.not_in_creative_inventory == 1 or def.groups.not_in_craftguide == 1) and
|
||||
(get_recipe(name).items or is_fuel) and
|
||||
def.description and def.description ~= "" then
|
||||
|
||||
counter = counter + 1
|
||||
items_list[counter] = name
|
||||
end
|
||||
end
|
||||
|
||||
sort(items_list)
|
||||
datas.init_items = items_list
|
||||
end
|
||||
|
||||
function craftguide:get_filter_items(data, player)
|
||||
local filter = data.filter
|
||||
local items_list = progressive_mode and data.init_filter_items or datas.init_items
|
||||
local inv = player:get_inventory()
|
||||
local filtered_list, counter = {}, 0
|
||||
|
||||
for i=1, #items_list do
|
||||
local item = items_list[i]
|
||||
local item_desc = reg_items[item].description:lower()
|
||||
|
||||
if filter ~= "" then
|
||||
if item:find(filter, 1, true) or item_desc:find(filter, 1, true) then
|
||||
counter = counter + 1
|
||||
filtered_list[counter] = item
|
||||
end
|
||||
elseif progressive_mode then
|
||||
local _, has_item = self:recipe_in_inv(inv, item)
|
||||
if has_item then
|
||||
counter = counter + 1
|
||||
filtered_list[counter] = item
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if progressive_mode and not data.items then
|
||||
data.init_filter_items = filtered_list
|
||||
end
|
||||
data.items = filtered_list
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= "craftguide" then return end
|
||||
local player_name = player:get_player_name()
|
||||
local data = datas[player_name]
|
||||
|
||||
if fields.clear then
|
||||
data.filter, data.item, data.pagenum, data.recipe_num = "", nil, 1, 1
|
||||
data.items = progressive_mode and data.init_filter_items or datas.init_items
|
||||
craftguide:get_formspec(player_name)
|
||||
|
||||
elseif fields.alternate then
|
||||
local recipe = data.recipes_item[data.recipe_num + 1]
|
||||
data.recipe_num = recipe and data.recipe_num + 1 or 1
|
||||
craftguide:get_formspec(player_name)
|
||||
|
||||
elseif (fields.key_enter_field == "filter" or fields.search) and
|
||||
fields.filter ~= "" then
|
||||
data.filter = fields.filter:lower()
|
||||
data.pagenum = 1
|
||||
craftguide:get_filter_items(data, player)
|
||||
craftguide:get_formspec(player_name)
|
||||
|
||||
elseif fields.prev or fields.next then
|
||||
data.pagenum = data.pagenum - (fields.prev and 1 or -1)
|
||||
if data.pagenum > data.pagemax then
|
||||
data.pagenum = 1
|
||||
elseif data.pagenum == 0 then
|
||||
data.pagenum = data.pagemax
|
||||
end
|
||||
craftguide:get_formspec(player_name)
|
||||
|
||||
elseif (fields.size_inc and data.iX < 12) or
|
||||
(fields.size_dec and data.iX > 8) then
|
||||
data.pagenum = 1
|
||||
data.iX = data.iX - (fields.size_dec and 1 or -1)
|
||||
craftguide:get_formspec(player_name)
|
||||
|
||||
else for item in pairs(fields) do
|
||||
if item:find(":") then
|
||||
if item:sub(-4) == "_inv" then
|
||||
item = item:sub(1,-5)
|
||||
end
|
||||
|
||||
local is_fuel = get_fueltime(item) > 0
|
||||
local recipes = get_recipes(item)
|
||||
if not recipes and not is_fuel then return end
|
||||
|
||||
if item == data.item then
|
||||
if data.recipes_item and #data.recipes_item >= 2 then
|
||||
local recipe = data.recipes_item[data.recipe_num + 1]
|
||||
data.recipe_num = recipe and data.recipe_num + 1 or 1
|
||||
craftguide:get_formspec(player_name)
|
||||
end
|
||||
else
|
||||
if progressive_mode then
|
||||
local inv = player:get_inventory()
|
||||
local _, has_item = craftguide:recipe_in_inv(inv, item)
|
||||
|
||||
if not has_item then return end
|
||||
recipes = craftguide:recipe_in_inv(inv, item, recipes)
|
||||
end
|
||||
|
||||
data.item = item
|
||||
data.recipe_num = 1
|
||||
data.recipes_item = recipes
|
||||
craftguide:get_formspec(player_name, is_fuel)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
function craftguide:on_use(itemstack, user)
|
||||
if not datas.init_items then
|
||||
craftguide:get_init_items()
|
||||
end
|
||||
|
||||
local player_name = user:get_player_name()
|
||||
local data = datas[player_name]
|
||||
|
||||
if progressive_mode or not data then
|
||||
datas[player_name] = {filter = "", pagenum = 1, iX = 9}
|
||||
if progressive_mode then
|
||||
craftguide:get_filter_items(datas[player_name], user)
|
||||
end
|
||||
craftguide:get_formspec(player_name)
|
||||
else
|
||||
show_formspec(player_name, "craftguide", data.formspec)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_craftitem("craftguide:book", {
|
||||
description = "Crafting Guide",
|
||||
inventory_image = "craftguide_book.png",
|
||||
wield_image = "craftguide_book.png",
|
||||
stack_max = 1,
|
||||
groups = {book = 1},
|
||||
on_use = function(itemstack, user)
|
||||
craftguide:on_use(itemstack, user)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "craftguide:book",
|
||||
type = "shapeless",
|
||||
recipe = {"default:book"}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "craftguide:book",
|
||||
burntime = 3
|
||||
})
|
After Width: | Height: | Size: 308 B |
After Width: | Height: | Size: 215 KiB |
After Width: | Height: | Size: 617 B |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 780 B |
After Width: | Height: | Size: 685 B |
After Width: | Height: | Size: 356 B |
|
@ -0,0 +1,17 @@
|
|||
Minetest Game mod: creative
|
||||
===========================
|
||||
See license.txt for license information.
|
||||
|
||||
Authors of source code
|
||||
----------------------
|
||||
Originally by Perttu Ahola (celeron55) <celeron55@gmail.com> (MIT)
|
||||
Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com> (MIT)
|
||||
|
||||
Author of media (textures)
|
||||
--------------------------
|
||||
paramat (CC BY-SA 3.0):
|
||||
* creative_prev_icon.png
|
||||
* creative_next_icon.png
|
||||
* creative_search_icon.png
|
||||
* creative_clear_icon.png
|
||||
* creative_trash_icon.png derived from a texture by kilbith (CC BY-SA 3.0)
|
|
@ -0,0 +1,2 @@
|
|||
default
|
||||
sfinv
|
|
@ -0,0 +1,70 @@
|
|||
creative = {}
|
||||
|
||||
minetest.register_privilege("creative", {
|
||||
description = "Allow player to use creative inventory",
|
||||
give_to_singleplayer = false,
|
||||
give_to_admin = false
|
||||
})
|
||||
|
||||
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
|
||||
|
||||
function creative.is_enabled_for(name)
|
||||
return creative_mode_cache or
|
||||
minetest.check_player_privs(name, {creative = true})
|
||||
end
|
||||
|
||||
dofile(minetest.get_modpath("creative") .. "/inventory.lua")
|
||||
|
||||
if creative_mode_cache then
|
||||
-- Dig time is modified according to difference (leveldiff) between tool
|
||||
-- 'maxlevel' and node 'level'. Digtime is divided by the larger of
|
||||
-- leveldiff and 1.
|
||||
-- To speed up digging in creative, hand 'maxlevel' and 'digtime' have been
|
||||
-- increased such that nodes of differing levels have an insignificant
|
||||
-- effect on digtime.
|
||||
local digtime = 42
|
||||
local caps = {times = {digtime, digtime, digtime}, uses = 0, maxlevel = 256}
|
||||
|
||||
minetest.register_item(":", {
|
||||
type = "none",
|
||||
wield_image = "wieldhand.png",
|
||||
wield_scale = {x = 1, y = 1, z = 2.5},
|
||||
range = 10,
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.5,
|
||||
max_drop_level = 3,
|
||||
groupcaps = {
|
||||
crumbly = caps,
|
||||
cracky = caps,
|
||||
snappy = caps,
|
||||
choppy = caps,
|
||||
oddly_breakable_by_hand = caps,
|
||||
},
|
||||
damage_groups = {fleshy = 10},
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
-- Unlimited node placement
|
||||
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
|
||||
if placer and placer:is_player() then
|
||||
return creative.is_enabled_for(placer:get_player_name())
|
||||
end
|
||||
end)
|
||||
|
||||
-- Don't pick up if the item is already in the inventory
|
||||
local old_handle_node_drops = minetest.handle_node_drops
|
||||
function minetest.handle_node_drops(pos, drops, digger)
|
||||
if not digger or not digger:is_player() or
|
||||
not creative.is_enabled_for(digger:get_player_name()) then
|
||||
return old_handle_node_drops(pos, drops, digger)
|
||||
end
|
||||
local inv = digger:get_inventory()
|
||||
if inv then
|
||||
for _, item in ipairs(drops) do
|
||||
if not inv:contains_item("main", item, true) then
|
||||
inv:add_item("main", item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,190 @@
|
|||
local player_inventory = {}
|
||||
local inventory_cache = {}
|
||||
|
||||
local function init_creative_cache(items)
|
||||
inventory_cache[items] = {}
|
||||
local i_cache = inventory_cache[items]
|
||||
|
||||
for name, def in pairs(items) do
|
||||
if def.groups.not_in_creative_inventory ~= 1 and
|
||||
def.description and def.description ~= "" then
|
||||
i_cache[name] = def
|
||||
end
|
||||
end
|
||||
table.sort(i_cache)
|
||||
return i_cache
|
||||
end
|
||||
|
||||
function creative.init_creative_inventory(player)
|
||||
local player_name = player:get_player_name()
|
||||
player_inventory[player_name] = {
|
||||
size = 0,
|
||||
filter = "",
|
||||
start_i = 0
|
||||
}
|
||||
|
||||
minetest.create_detached_inventory("creative_" .. player_name, {
|
||||
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player2)
|
||||
local name = player2 and player2:get_player_name() or ""
|
||||
if not creative.is_enabled_for(name) or
|
||||
to_list == "main" then
|
||||
return 0
|
||||
end
|
||||
return count
|
||||
end,
|
||||
allow_put = function(inv, listname, index, stack, player2)
|
||||
return 0
|
||||
end,
|
||||
allow_take = function(inv, listname, index, stack, player2)
|
||||
local name = player2 and player2:get_player_name() or ""
|
||||
if not creative.is_enabled_for(name) then
|
||||
return 0
|
||||
end
|
||||
return -1
|
||||
end,
|
||||
on_move = function(inv, from_list, from_index, to_list, to_index, count, player2)
|
||||
end,
|
||||
on_take = function(inv, listname, index, stack, player2)
|
||||
if stack and stack:get_count() > 0 then
|
||||
minetest.log("action", player_name .. " takes " .. stack:get_name().. " from creative inventory")
|
||||
end
|
||||
end,
|
||||
}, player_name)
|
||||
|
||||
return player_inventory[player_name]
|
||||
end
|
||||
|
||||
function creative.update_creative_inventory(player_name, tab_content)
|
||||
local creative_list = {}
|
||||
local inv = player_inventory[player_name] or
|
||||
creative.init_creative_inventory(minetest.get_player_by_name(player_name))
|
||||
local player_inv = minetest.get_inventory({type = "detached", name = "creative_" .. player_name})
|
||||
|
||||
local items = inventory_cache[tab_content] or init_creative_cache(tab_content)
|
||||
|
||||
for name, def in pairs(items) do
|
||||
if def.name:find(inv.filter, 1, true) or
|
||||
def.description:lower():find(inv.filter, 1, true) then
|
||||
creative_list[#creative_list+1] = name
|
||||
end
|
||||
end
|
||||
|
||||
table.sort(creative_list)
|
||||
player_inv:set_size("main", #creative_list)
|
||||
player_inv:set_list("main", creative_list)
|
||||
inv.size = #creative_list
|
||||
end
|
||||
|
||||
-- Create the trash field
|
||||
local trash = minetest.create_detached_inventory("creative_trash", {
|
||||
-- Allow the stack to be placed and remove it in on_put()
|
||||
-- This allows the creative inventory to restore the stack
|
||||
allow_put = function(inv, listname, index, stack, player)
|
||||
return stack:get_count()
|
||||
end,
|
||||
on_put = function(inv, listname)
|
||||
inv:set_list(listname, {})
|
||||
end,
|
||||
})
|
||||
trash:set_size("main", 1)
|
||||
|
||||
creative.formspec_add = ""
|
||||
|
||||
function creative.register_tab(name, title, items)
|
||||
sfinv.register_page("creative:" .. name, {
|
||||
title = title,
|
||||
is_in_nav = function(self, player, context)
|
||||
return creative.is_enabled_for(player:get_player_name())
|
||||
end,
|
||||
get = function(self, player, context)
|
||||
local player_name = player:get_player_name()
|
||||
creative.update_creative_inventory(player_name, items)
|
||||
local inv = player_inventory[player_name]
|
||||
local start_i = inv.start_i or 0
|
||||
local pagenum = math.floor(start_i / (6*4) + 1)
|
||||
local pagemax = math.ceil(inv.size / (6*4))
|
||||
return sfinv.make_formspec(player, context,
|
||||
"size[13.3,7.3]"..
|
||||
--"image[6,0.6;1,2;player.png]"..
|
||||
"list[current_player;main;5,3.5;8,4;]"..
|
||||
"list[current_player;craft;8,0;3,3;]"..
|
||||
"list[current_player;craftpreview;12,1;1,1;]"..
|
||||
"image[11,1;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
|
||||
"list[detached:creative_"..player_name..";main;0.3,0.82;4,6;"..tostring(start_i).."]"..
|
||||
"label[2.0,6.88;"..tostring(pagenum).."/"..tostring(pagemax).."]"..
|
||||
"image_button[0.28,6.83;1.64,0.7;;creative_prev;<<]"..
|
||||
"image_button[2.7,6.83;1.64,0.7;;creative_next;>>]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[detached:creative_trash;main]"..
|
||||
"listring[current_player;craft]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[detached:creative_"..player_name..";main]" ..
|
||||
"label[5,1.5;Trash:]"..
|
||||
"list[detached:creative_trash;main;5,2;1,1;]"..
|
||||
"field[0.58,0.23;2.27,1;creative_filter;;"..minetest.formspec_escape(inv.filter).."]"..
|
||||
"image_button[3.28,-0.01;1.05,0.85;;creative_clear;Clear]"..
|
||||
"image_button[2.4,-0.01;1.05,0.85;;creative_search;Search]"..
|
||||
"field_close_on_enter[creative_filter;false]"..
|
||||
creative.formspec_add, false)
|
||||
end,
|
||||
on_enter = function(self, player, context)
|
||||
local player_name = player:get_player_name()
|
||||
local inv = player_inventory[player_name]
|
||||
if inv then
|
||||
inv.start_i = 0
|
||||
end
|
||||
end,
|
||||
on_player_receive_fields = function(self, player, context, fields)
|
||||
local player_name = player:get_player_name()
|
||||
local inv = player_inventory[player_name]
|
||||
assert(inv)
|
||||
|
||||
if fields.creative_clear then
|
||||
inv.start_i = 0
|
||||
inv.filter = ""
|
||||
creative.update_creative_inventory(player_name, items)
|
||||
sfinv.set_player_inventory_formspec(player, context)
|
||||
elseif fields.creative_search or
|
||||
fields.key_enter_field == "creative_filter" then
|
||||
inv.start_i = 0
|
||||
inv.filter = fields.creative_filter:lower()
|
||||
creative.update_creative_inventory(player_name, items)
|
||||
sfinv.set_player_inventory_formspec(player, context)
|
||||
elseif not fields.quit then
|
||||
local start_i = inv.start_i or 0
|
||||
|
||||
if fields.creative_prev then
|
||||
start_i = start_i - 3*8
|
||||
if start_i < 0 then
|
||||
start_i = inv.size - (inv.size % (3*8))
|
||||
if inv.size == start_i then
|
||||
start_i = math.max(0, inv.size - (3*8))
|
||||
end
|
||||
end
|
||||
elseif fields.creative_next then
|
||||
start_i = start_i + 3*8
|
||||
if start_i >= inv.size then
|
||||
start_i = 0
|
||||
end
|
||||
end
|
||||
|
||||
inv.start_i = start_i
|
||||
sfinv.set_player_inventory_formspec(player, context)
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
creative.register_tab("all", "All", minetest.registered_items)
|
||||
creative.register_tab("nodes", "Nodes", minetest.registered_nodes)
|
||||
creative.register_tab("tools", "Tools", minetest.registered_tools)
|
||||
creative.register_tab("craftitems", "Items", minetest.registered_craftitems)
|
||||
|
||||
local old_homepage_name = sfinv.get_homepage_name
|
||||
function sfinv.get_homepage_name(player)
|
||||
if creative.is_enabled_for(player:get_player_name()) then
|
||||
return "creative:all"
|
||||
else
|
||||
return old_homepage_name(player)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,61 @@
|
|||
License of source code
|
||||
----------------------
|
||||
|
||||
The MIT License (MIT)
|
||||
Copyright (C) 2012-2016 Perttu Ahola (celeron55) <celeron55@gmail.com>
|
||||
Copyright (C) 2015-2016 Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
software and associated documentation files (the "Software"), to deal in the Software
|
||||
without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more details:
|
||||
https://opensource.org/licenses/MIT
|
||||
|
||||
|
||||
Licenses of media (textures)
|
||||
----------------------------
|
||||
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
Copyright (C) 2016 Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com>
|
||||
Copyright (C) 2018 paramat
|
||||
|
||||
You are free to:
|
||||
Share — copy and redistribute the material in any medium or format.
|
||||
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
|
||||
The licensor cannot revoke these freedoms as long as you follow the license terms.
|
||||
|
||||
Under the following terms:
|
||||
|
||||
Attribution — You must give appropriate credit, provide a link to the license, and
|
||||
indicate if changes were made. You may do so in any reasonable manner, but not in any way
|
||||
that suggests the licensor endorses you or your use.
|
||||
|
||||
ShareAlike — If you remix, transform, or build upon the material, you must distribute
|
||||
your contributions under the same license as the original.
|
||||
|
||||
No additional restrictions — You may not apply legal terms or technological measures that
|
||||
legally restrict others from doing anything the license permits.
|
||||
|
||||
Notices:
|
||||
|
||||
You do not have to comply with the license for elements of the material in the public
|
||||
domain or where your use is permitted by an applicable exception or limitation.
|
||||
No warranties are given. The license may not give you all of the permissions necessary
|
||||
for your intended use. For example, other rights such as publicity, privacy, or moral
|
||||
rights may limit how you use the material.
|
||||
|
||||
For more details:
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|