Initial commit (version 0.1-test)
1
LICENSE.TXT
Normal file
@ -0,0 +1 @@
|
|||||||
|
Please see the LICENSE.TXT file in each mod (every directory in the "mods" directory) for copyright information
|
2
README.TXT
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Submission to the 2022 Minetest Game Jam
|
||||||
|
Themes used: "Secrets", "Space" and "Story"
|
3
game.conf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
title = Insane Protestor
|
||||||
|
author = MCL
|
||||||
|
description = A game about a man who protests his country's government in a violent and somewhat unreasonable way.
|
BIN
menu/background.png
Normal file
After Width: | Height: | Size: 51 KiB |
BIN
menu/background.xcf
Normal file
BIN
menu/header.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
menu/icon.png
Normal file
After Width: | Height: | Size: 10 KiB |
30
mods/beds/README.txt
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
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)
|
||||||
|
All textures unless otherwise noted
|
||||||
|
|
||||||
|
TumeniNodes (CC BY-SA 3.0)
|
||||||
|
beds_bed_under.png
|
||||||
|
|
||||||
|
This mod adds a bed to Minetest which allows players to skip the night.
|
||||||
|
To sleep, right click on 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 half 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.
|
184
mods/beds/api.lua
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
|
||||||
|
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)
|
||||||
|
beds.remove_spawns_at(pos)
|
||||||
|
beds.remove_spawns_at(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,
|
||||||
|
use_texture_alpha = "clip",
|
||||||
|
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 minetest.is_creative_enabled(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, _, 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 new_param2 % 32 > 3 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,
|
||||||
|
can_dig = function(pos, player)
|
||||||
|
return beds.can_dig(pos)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node(name .. "_top", {
|
||||||
|
drawtype = "nodebox",
|
||||||
|
tiles = def.tiles.top,
|
||||||
|
use_texture_alpha = "clip",
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
is_ground_content = false,
|
||||||
|
pointable = false,
|
||||||
|
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 2,
|
||||||
|
not_in_creative_inventory = 1},
|
||||||
|
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,
|
||||||
|
can_dig = function(pos, player)
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
local dir = minetest.facedir_to_dir(node.param2)
|
||||||
|
local p = vector.add(pos, dir)
|
||||||
|
return beds.can_dig(p)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_alias(name, name .. "_bottom")
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = name,
|
||||||
|
recipe = def.recipe
|
||||||
|
})
|
||||||
|
end
|
109
mods/beds/beds.lua
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
-- beds/beds.lua
|
||||||
|
|
||||||
|
-- support for MT game translation.
|
||||||
|
local S = beds.get_translator
|
||||||
|
|
||||||
|
-- Fancy shaped bed
|
||||||
|
|
||||||
|
beds.register_bed("beds:fancy_bed", {
|
||||||
|
description = S("Fancy Bed"),
|
||||||
|
inventory_image = "beds_bed_fancy.png",
|
||||||
|
wield_image = "beds_bed_fancy.png",
|
||||||
|
tiles = {
|
||||||
|
bottom = {
|
||||||
|
"beds_bed_top1.png",
|
||||||
|
"beds_bed_under.png",
|
||||||
|
"beds_bed_side1.png",
|
||||||
|
"beds_bed_side1.png^[transformFX",
|
||||||
|
"beds_bed_foot.png",
|
||||||
|
"beds_bed_foot.png",
|
||||||
|
},
|
||||||
|
top = {
|
||||||
|
"beds_bed_top2.png",
|
||||||
|
"beds_bed_under.png",
|
||||||
|
"beds_bed_side2.png",
|
||||||
|
"beds_bed_side2.png^[transformFX",
|
||||||
|
"beds_bed_head.png",
|
||||||
|
"beds_bed_head.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:white", "wool:white", "wool:white"},
|
||||||
|
{"group:wood", "group:wood", "group:wood"},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Simple shaped bed
|
||||||
|
|
||||||
|
beds.register_bed("beds:bed", {
|
||||||
|
description = S("Simple Bed"),
|
||||||
|
inventory_image = "beds_bed.png",
|
||||||
|
wield_image = "beds_bed.png",
|
||||||
|
tiles = {
|
||||||
|
bottom = {
|
||||||
|
"beds_bed_top_bottom.png^[transformR90",
|
||||||
|
"beds_bed_under.png",
|
||||||
|
"beds_bed_side_bottom_r.png",
|
||||||
|
"beds_bed_side_bottom_r.png^[transformfx",
|
||||||
|
"beds_transparent.png",
|
||||||
|
"beds_bed_side_bottom.png"
|
||||||
|
},
|
||||||
|
top = {
|
||||||
|
"beds_bed_top_top.png^[transformR90",
|
||||||
|
"beds_bed_under.png",
|
||||||
|
"beds_bed_side_top_r.png",
|
||||||
|
"beds_bed_side_top_r.png^[transformfx",
|
||||||
|
"beds_bed_side_top.png",
|
||||||
|
"beds_transparent.png",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
nodebox = {
|
||||||
|
bottom = {-0.5, -0.5, -0.5, 0.5, 0.0625, 0.5},
|
||||||
|
top = {-0.5, -0.5, -0.5, 0.5, 0.0625, 0.5},
|
||||||
|
},
|
||||||
|
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.0625, 1.5},
|
||||||
|
recipe = {
|
||||||
|
{"wool:white", "wool:white", "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,
|
||||||
|
})
|
300
mods/beds/functions.lua
Normal file
@ -0,0 +1,300 @@
|
|||||||
|
local pi = math.pi
|
||||||
|
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
|
||||||
|
|
||||||
|
-- support for MT game translation.
|
||||||
|
local S = beds.get_translator
|
||||||
|
|
||||||
|
-- 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
|
||||||
|
if not beds.player[name] then
|
||||||
|
-- player not in bed, do nothing
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
beds.bed_position[name] = nil
|
||||||
|
-- skip here to prevent sending player specific changes (used for leaving players)
|
||||||
|
if skip then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
player:set_pos(beds.pos[name])
|
||||||
|
|
||||||
|
-- physics, eye_offset, etc
|
||||||
|
local physics_override = beds.player[name].physics_override
|
||||||
|
beds.player[name] = nil
|
||||||
|
player:set_physics_override({
|
||||||
|
speed = physics_override.speed,
|
||||||
|
jump = physics_override.jump,
|
||||||
|
gravity = physics_override.gravity
|
||||||
|
})
|
||||||
|
player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
||||||
|
player:set_look_horizontal(math.random(1, 180) / 100)
|
||||||
|
player_api.player_attached[name] = false
|
||||||
|
hud_flags.wielditem = true
|
||||||
|
player_api.set_animation(player, "stand" , 30)
|
||||||
|
|
||||||
|
-- lay down
|
||||||
|
else
|
||||||
|
|
||||||
|
-- Check if bed is occupied
|
||||||
|
for _, other_pos in pairs(beds.bed_position) do
|
||||||
|
if vector.distance(bed_pos, other_pos) < 0.1 then
|
||||||
|
minetest.chat_send_player(name, S("This bed is already occupied!"))
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if player is moving
|
||||||
|
if vector.length(player:get_velocity()) > 0.001 then
|
||||||
|
minetest.chat_send_player(name, S("You have to stop moving before going to bed!"))
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if player is attached to an object
|
||||||
|
if player:get_attach() then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if beds.player[name] then
|
||||||
|
-- player already in bed, do nothing
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
beds.pos[name] = pos
|
||||||
|
beds.bed_position[name] = bed_pos
|
||||||
|
beds.player[name] = {physics_override = player:get_physics_override()}
|
||||||
|
|
||||||
|
local yaw, param2 = get_look_yaw(bed_pos)
|
||||||
|
player:set_look_horizontal(yaw)
|
||||||
|
local dir = minetest.facedir_to_dir(param2)
|
||||||
|
-- p.y is just above the nodebox height of the 'Simple Bed' (the highest bed),
|
||||||
|
-- to avoid sinking down through the bed.
|
||||||
|
local p = {
|
||||||
|
x = bed_pos.x + dir.x / 2,
|
||||||
|
y = bed_pos.y + 0.07,
|
||||||
|
z = bed_pos.z + dir.z / 2
|
||||||
|
}
|
||||||
|
player:set_physics_override({speed = 0, jump = 0, gravity = 0})
|
||||||
|
player:set_pos(p)
|
||||||
|
player_api.player_attached[name] = true
|
||||||
|
hud_flags.wielditem = false
|
||||||
|
player_api.set_animation(player, "lay" , 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
player:hud_set_flags(hud_flags)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_player_in_bed_count()
|
||||||
|
local c = 0
|
||||||
|
for _, _ in pairs(beds.player) do
|
||||||
|
c = c + 1
|
||||||
|
end
|
||||||
|
return c
|
||||||
|
end
|
||||||
|
|
||||||
|
local function update_formspecs(finished)
|
||||||
|
local ges = #minetest.get_connected_players()
|
||||||
|
local player_in_bed = get_player_in_bed_count()
|
||||||
|
local is_majority = (ges / 2) < player_in_bed
|
||||||
|
|
||||||
|
local form_n
|
||||||
|
local esc = minetest.formspec_escape
|
||||||
|
if finished then
|
||||||
|
form_n = beds.formspec .. "label[2.7,9;" .. esc(S("Good morning.")) .. "]"
|
||||||
|
else
|
||||||
|
form_n = beds.formspec .. "label[2.2,9;" ..
|
||||||
|
esc(S("@1 of @2 players are in bed", player_in_bed, ges)) .. "]"
|
||||||
|
if is_majority and is_night_skip_enabled() then
|
||||||
|
form_n = form_n .. "button_exit[2,6;4,0.75;force;" ..
|
||||||
|
esc(S("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:get_pos()
|
||||||
|
local tod = minetest.get_timeofday()
|
||||||
|
|
||||||
|
if tod > 0.2 and tod < 0.805 then
|
||||||
|
if beds.player[name] then
|
||||||
|
lay_down(player, nil, nil, false)
|
||||||
|
end
|
||||||
|
minetest.chat_send_player(name, S("You can only sleep at night."))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 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(2, function()
|
||||||
|
if not is_sp then
|
||||||
|
update_formspecs(is_night_skip_enabled())
|
||||||
|
end
|
||||||
|
if is_night_skip_enabled() then
|
||||||
|
beds.skip_night()
|
||||||
|
beds.kick_players()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function beds.can_dig(bed_pos)
|
||||||
|
-- Check all players in bed which one is at the expected position
|
||||||
|
for _, player_bed_pos in pairs(beds.bed_position) do
|
||||||
|
if vector.equals(bed_pos, player_bed_pos) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
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:set_pos(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_dieplayer(function(player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local in_bed = beds.player
|
||||||
|
local pos = player:get_pos()
|
||||||
|
local yaw = get_look_yaw(pos)
|
||||||
|
|
||||||
|
if in_bed[name] then
|
||||||
|
lay_down(player, nil, pos, false)
|
||||||
|
player:set_look_horizontal(yaw)
|
||||||
|
player:set_pos(pos)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
if formname ~= "beds_form" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Because "Force night skip" button is a button_exit, it will set fields.quit
|
||||||
|
-- and lay_down call will change value of player_in_bed, so it must be taken
|
||||||
|
-- earlier.
|
||||||
|
local last_player_in_bed = get_player_in_bed_count()
|
||||||
|
|
||||||
|
if fields.quit or fields.leave then
|
||||||
|
lay_down(player, nil, nil, false)
|
||||||
|
update_formspecs(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
if fields.force then
|
||||||
|
local is_majority = (#minetest.get_connected_players() / 2) < last_player_in_bed
|
||||||
|
if is_majority and is_night_skip_enabled() then
|
||||||
|
update_formspecs(true)
|
||||||
|
beds.skip_night()
|
||||||
|
beds.kick_players()
|
||||||
|
else
|
||||||
|
update_formspecs(false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
26
mods/beds/init.lua
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
-- beds/init.lua
|
||||||
|
|
||||||
|
-- Load support for MT game translation.
|
||||||
|
local S = minetest.get_translator("beds")
|
||||||
|
local esc = minetest.formspec_escape
|
||||||
|
|
||||||
|
beds = {}
|
||||||
|
beds.player = {}
|
||||||
|
beds.bed_position = {}
|
||||||
|
beds.pos = {}
|
||||||
|
beds.spawn = {}
|
||||||
|
beds.get_translator = S
|
||||||
|
|
||||||
|
beds.formspec = "size[8,11;true]" ..
|
||||||
|
"no_prepend[]" ..
|
||||||
|
"bgcolor[#080808BB;true]" ..
|
||||||
|
"button_exit[2,10;4,0.75;leave;" .. esc(S("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")
|
61
mods/beds/license.txt
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
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
|
||||||
|
Copyright (C) 2018 TumeniNodes
|
||||||
|
|
||||||
|
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/
|
10
mods/beds/locale/beds.de.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: beds
|
||||||
|
Fancy Bed=Schickes Bett
|
||||||
|
Simple Bed=Schlichtes Bett
|
||||||
|
This bed is already occupied!=Dieses Bett ist bereits belegt!
|
||||||
|
You have to stop moving before going to bed!=Sie müssen stehen bleiben, bevor Sie zu Bett gehen können!
|
||||||
|
Good morning.=Guten Morgen.
|
||||||
|
@1 of @2 players are in bed=@1 von @2 Spielern sind im Bett
|
||||||
|
Force night skip=Überspringen der Nacht erzwingen
|
||||||
|
You can only sleep at night.=Sie können nur nachts schlafen.
|
||||||
|
Leave Bed=Bett verlassen
|
10
mods/beds/locale/beds.eo.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: beds
|
||||||
|
Fancy Bed=Luksa Lito
|
||||||
|
Simple Bed=Simpla Lito
|
||||||
|
This bed is already occupied!=Tiu lito jam estas okupata!
|
||||||
|
You have to stop moving before going to bed!=Vi ĉesu moviĝi por enlitiĝi!
|
||||||
|
Good morning.=Bonan matenon.
|
||||||
|
@1 of @2 players are in bed=@1 el @2 ludantoj estas en lito
|
||||||
|
Force night skip=Devigi noktan salton
|
||||||
|
You can only sleep at night.=Vi povas dormi nur nokte.
|
||||||
|
Leave Bed=Ellitiĝi
|
10
mods/beds/locale/beds.es.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: beds
|
||||||
|
Fancy Bed=Cama de lujo
|
||||||
|
Simple Bed=Cama sencilla
|
||||||
|
This bed is already occupied!=Esta cama esta ocupada
|
||||||
|
You have to stop moving before going to bed!=Deja de moverte o no podras acostarte
|
||||||
|
Good morning.=Buenos días.
|
||||||
|
@1 of @2 players are in bed=@1 de @2 jugadores están durmiendo
|
||||||
|
Force night skip=Forzar hacer de dia
|
||||||
|
You can only sleep at night.=Sólo puedes dormir por la noche.
|
||||||
|
Leave Bed=Levantarse
|
10
mods/beds/locale/beds.fr.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: beds
|
||||||
|
Fancy Bed=Lit chic
|
||||||
|
Simple Bed=Lit simple
|
||||||
|
This bed is already occupied!=Ce lit est déjà occupé !
|
||||||
|
You have to stop moving before going to bed!=Vous devez arrêter de bouger avant de vous coucher !
|
||||||
|
Good morning.=Bonjour.
|
||||||
|
@1 of @2 players are in bed=@1 joueur(s) sur @2 sont au lit
|
||||||
|
Force night skip=Forcer le passage de la nuit
|
||||||
|
You can only sleep at night.=Vous ne pouvez dormir que la nuit.
|
||||||
|
Leave Bed=Se lever du lit
|
10
mods/beds/locale/beds.id.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: beds
|
||||||
|
Fancy Bed=Ranjang Mewah
|
||||||
|
Simple Bed=Ranjang Sederhana
|
||||||
|
This bed is already occupied!=
|
||||||
|
You have to stop moving before going to bed!=
|
||||||
|
Good morning.=Selamat pagi.
|
||||||
|
@1 of @2 players are in bed=@1 dari @2 pemain sedang tidur
|
||||||
|
Force night skip=Paksa lewati malam
|
||||||
|
You can only sleep at night.=Anda hanya dapat tidur pada waktu malam.
|
||||||
|
Leave Bed=Tinggalkan Ranjang
|
10
mods/beds/locale/beds.it.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: beds
|
||||||
|
Fancy Bed=Letto decorato
|
||||||
|
Simple Bed=Letto semplice
|
||||||
|
This bed is already occupied!=
|
||||||
|
You have to stop moving before going to bed!=
|
||||||
|
Good morning.=
|
||||||
|
@1 of @2 players are in bed=
|
||||||
|
Force night skip=
|
||||||
|
You can only sleep at night.=
|
||||||
|
Leave Bed=Alzati dal letto
|
10
mods/beds/locale/beds.ja.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: beds
|
||||||
|
Fancy Bed=ファンシーなベッド
|
||||||
|
Simple Bed=シンプルなベッド
|
||||||
|
This bed is already occupied!=ベッドはすでに使われています!
|
||||||
|
You have to stop moving before going to bed!=寝るときは動かないでください!
|
||||||
|
Good morning.=おはようございます。
|
||||||
|
@1 of @2 players are in bed=ベッドに@1 / @2人います
|
||||||
|
Force night skip=強制的に夜をスキップします
|
||||||
|
You can only sleep at night.=夜しか寝れません。
|
||||||
|
Leave Bed=ベッドから出ます
|
10
mods/beds/locale/beds.jbo.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: beds
|
||||||
|
Fancy Bed=lo selja'i ckana
|
||||||
|
Simple Bed=lo sampu ckana
|
||||||
|
This bed is already occupied!=.i lo ti ckana cu canlu
|
||||||
|
You have to stop moving before going to bed!=lo nu do cando cu sarcu lo nu do sipna
|
||||||
|
Good morning.=.i .uise'inai cerni
|
||||||
|
@1 of @2 players are in bed=.i @1 cmima be lu'i @2 le pilno cu vreta lo ckana
|
||||||
|
Force night skip=bapli le nu co'u nicte
|
||||||
|
You can only sleep at night.=.i steci le ka nicte kei fa le ka do kakne le ka sipna ca pa ckaji be ce'u
|
||||||
|
Leave Bed=cliva lo ckana
|
10
mods/beds/locale/beds.ms.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: beds
|
||||||
|
Fancy Bed=Katil Beragam
|
||||||
|
Simple Bed=Katil Biasa
|
||||||
|
This bed is already occupied!=
|
||||||
|
You have to stop moving before going to bed!=
|
||||||
|
Good morning.=Selamat pagi.
|
||||||
|
@1 of @2 players are in bed=@1 daripada @2 pemain sedang tidur
|
||||||
|
Force night skip=Paksa langkau malam
|
||||||
|
You can only sleep at night.=Anda hanya boleh tidur pada waktu malam.
|
||||||
|
Leave Bed=Bangun
|
10
mods/beds/locale/beds.pl.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: beds
|
||||||
|
Fancy Bed=Fantazyjne łóżko
|
||||||
|
Simple Bed=Proste łóżko
|
||||||
|
This bed is already occupied!=To łóżko jest już zajęte!
|
||||||
|
You have to stop moving before going to bed!=Musisz się zatrzymać aby wejść do łóżka
|
||||||
|
Good morning.=Dzień dobry.
|
||||||
|
@1 of @2 players are in bed=@1 z @2 graczy śpią
|
||||||
|
Force night skip=Wymuś pominięcie nocy
|
||||||
|
You can only sleep at night.=Możesz spać tylko w nocy.
|
||||||
|
Leave Bed=Opuść łóżko
|
10
mods/beds/locale/beds.pt_BR.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: beds
|
||||||
|
Fancy Bed=Cama Bonita
|
||||||
|
Simple Bed=Cama Simples
|
||||||
|
This bed is already occupied!=Esta cama já está ocupada!
|
||||||
|
You have to stop moving before going to bed!=Você precisa parar de se mover antes de ir para cama!
|
||||||
|
Good morning.=Bom dia.
|
||||||
|
@1 of @2 players are in bed=@1 de @2 jogadores estão na cama
|
||||||
|
Force night skip=Forçar o amanhecer
|
||||||
|
You can only sleep at night.=Você só pode dormir à noite
|
||||||
|
Leave Bed=Sair da Cama
|
10
mods/beds/locale/beds.ru.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: beds
|
||||||
|
Fancy Bed=Детализированная Кровать
|
||||||
|
Simple Bed=Обычная Кровать
|
||||||
|
This bed is already occupied!=Эта кровать уже занята!
|
||||||
|
You have to stop moving before going to bed!=Нельзя воспользоваться кроватью на ходу!
|
||||||
|
Good morning.=Доброе утро.
|
||||||
|
@1 of @2 players are in bed=@1 из @2 игроков в кровати
|
||||||
|
Force night skip=Пропустить ночь
|
||||||
|
You can only sleep at night.=Вы можете спать только ночью.
|
||||||
|
Leave Bed=Встать с кровати
|
10
mods/beds/locale/beds.sk.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: beds
|
||||||
|
Fancy Bed=Pekná posteľ
|
||||||
|
Simple Bed=Jednoduchá posteľ
|
||||||
|
This bed is already occupied!=Táto posteľ je už obsadená
|
||||||
|
You have to stop moving before going to bed!=Predtým ako si ľahneš do postele, sa musíš prestať pohybovať!
|
||||||
|
Good morning.=Dobré ráno.
|
||||||
|
@1 of @2 players are in bed=@1 z @2 hráčov sú v posteli
|
||||||
|
Force night skip=Nútene preskočiť noc
|
||||||
|
You can only sleep at night.=Môžeš spať len v noci.
|
||||||
|
Leave Bed=Opusti posteľ
|
10
mods/beds/locale/beds.sv.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: beds
|
||||||
|
Fancy Bed=Fin säng
|
||||||
|
Simple Bed=Enkel säng
|
||||||
|
This bed is already occupied!=Den här sängen används redan!
|
||||||
|
You have to stop moving before going to bed!=Du måste stanna innan du kan lägga dig!
|
||||||
|
Good morning.=God morgon.
|
||||||
|
@1 of @2 players are in bed=@1 av @2 spelare försöker sova.
|
||||||
|
Force night skip=Tvinga att hoppa över natt
|
||||||
|
You can only sleep at night.=Du kan bara sova på natten.
|
||||||
|
Leave Bed=Lämna säng
|
10
mods/beds/locale/beds.uk.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: beds
|
||||||
|
Fancy Bed=Деталізована Постіль
|
||||||
|
Simple Bed=Звичайна Постіль
|
||||||
|
This bed is already occupied!=Ця постіль вже зайнята!
|
||||||
|
You have to stop moving before going to bed!=Не можна скористатись постіллю на ходу!
|
||||||
|
Good morning.=Доброго ранку.
|
||||||
|
@1 of @2 players are in bed=@1 з @2 гравців в ліжку
|
||||||
|
Force night skip=Пропустити ніч
|
||||||
|
You can only sleep at night.=Ви можете спати тільки вночі.
|
||||||
|
Leave Bed=Встати з ліжка
|
10
mods/beds/locale/beds.zh_CN.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: beds
|
||||||
|
Fancy Bed=花式床
|
||||||
|
Simple Bed=简易床
|
||||||
|
This bed is already occupied!=床上已有人!
|
||||||
|
You have to stop moving before going to bed!=上床前要停止移动!
|
||||||
|
Good morning.=早安!
|
||||||
|
@1 of @2 players are in bed=@2位玩家中的@1位在床上
|
||||||
|
Force night skip=强制跳过夜晚
|
||||||
|
You can only sleep at night.=你只能在晚上睡觉。
|
||||||
|
Leave Bed=离开床
|
10
mods/beds/locale/beds.zh_TW.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: beds
|
||||||
|
Fancy Bed=花式床
|
||||||
|
Simple Bed=簡易床
|
||||||
|
This bed is already occupied!=
|
||||||
|
You have to stop moving before going to bed!=
|
||||||
|
Good morning.=早安!
|
||||||
|
@1 of @2 players are in bed=@2位玩家中的@1位在床上
|
||||||
|
Force night skip=強制跳過夜晚
|
||||||
|
You can only sleep at night.=你只能在晚上睡覺。
|
||||||
|
Leave Bed=離開床
|
10
mods/beds/locale/template.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: beds
|
||||||
|
Fancy Bed=
|
||||||
|
Simple Bed=
|
||||||
|
This bed is already occupied!=
|
||||||
|
You have to stop moving before going to bed!=
|
||||||
|
Good morning.=
|
||||||
|
@1 of @2 players are in bed=
|
||||||
|
Force night skip=
|
||||||
|
You can only sleep at night.=
|
||||||
|
Leave Bed=
|
3
mods/beds/mod.conf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = beds
|
||||||
|
description = Minetest Game mod: beds
|
||||||
|
depends = sounds
|
72
mods/beds/spawns.lua
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
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:get_pos()
|
||||||
|
-- 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
|
||||||
|
|
||||||
|
function beds.remove_spawns_at(pos)
|
||||||
|
for name, p in pairs(beds.spawn) do
|
||||||
|
if vector.equals(vector.round(p), pos) then
|
||||||
|
beds.spawn[name] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
beds.save_spawns()
|
||||||
|
end
|
BIN
mods/beds/textures/beds_bed.png
Normal file
After Width: | Height: | Size: 490 B |
BIN
mods/beds/textures/beds_bed_fancy.png
Normal file
After Width: | Height: | Size: 486 B |
BIN
mods/beds/textures/beds_bed_foot.png
Normal file
After Width: | Height: | Size: 340 B |
BIN
mods/beds/textures/beds_bed_head.png
Normal file
After Width: | Height: | Size: 343 B |
BIN
mods/beds/textures/beds_bed_side1.png
Normal file
After Width: | Height: | Size: 248 B |
BIN
mods/beds/textures/beds_bed_side2.png
Normal file
After Width: | Height: | Size: 265 B |
BIN
mods/beds/textures/beds_bed_side_bottom.png
Normal file
After Width: | Height: | Size: 431 B |
BIN
mods/beds/textures/beds_bed_side_bottom_r.png
Normal file
After Width: | Height: | Size: 427 B |
BIN
mods/beds/textures/beds_bed_side_top.png
Normal file
After Width: | Height: | Size: 464 B |
BIN
mods/beds/textures/beds_bed_side_top_r.png
Normal file
After Width: | Height: | Size: 446 B |
BIN
mods/beds/textures/beds_bed_top1.png
Normal file
After Width: | Height: | Size: 474 B |
BIN
mods/beds/textures/beds_bed_top2.png
Normal file
After Width: | Height: | Size: 547 B |
BIN
mods/beds/textures/beds_bed_top_bottom.png
Normal file
After Width: | Height: | Size: 425 B |
BIN
mods/beds/textures/beds_bed_top_top.png
Normal file
After Width: | Height: | Size: 490 B |
BIN
mods/beds/textures/beds_bed_under.png
Normal file
After Width: | Height: | Size: 251 B |
BIN
mods/beds/textures/beds_transparent.png
Normal file
After Width: | Height: | Size: 83 B |
13
mods/bucket/README.txt
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
Minetest Game mod: bucket
|
||||||
|
=========================
|
||||||
|
See license.txt for license information.
|
||||||
|
|
||||||
|
Authors of source code
|
||||||
|
----------------------
|
||||||
|
Kahrl <kahrl@gmx.net> (LGPLv2.1+)
|
||||||
|
celeron55, Perttu Ahola <celeron55@gmail.com> (LGPLv2.1+)
|
||||||
|
Various Minetest developers and contributors (LGPLv2.1+)
|
||||||
|
|
||||||
|
Authors of media (textures)
|
||||||
|
---------------------------
|
||||||
|
ElementW (CC BY-SA 3.0)
|
240
mods/bucket/init.lua
Normal file
@ -0,0 +1,240 @@
|
|||||||
|
-- Minetest 0.4 mod: bucket
|
||||||
|
-- See README.txt for licensing and other information.
|
||||||
|
|
||||||
|
-- Load support for MT game translation.
|
||||||
|
local S = minetest.get_translator("bucket")
|
||||||
|
|
||||||
|
|
||||||
|
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 = {
|
||||||
|
{"default:steel_ingot", "", "default:steel_ingot"},
|
||||||
|
{"", "default:steel_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)
|
||||||
|
-- name = text description of the bucket item
|
||||||
|
-- groups = (optional) groups of the bucket item, for example {water_bucket = 1}
|
||||||
|
-- force_renew = (optional) bool. Force the liquid source to renew if it has a
|
||||||
|
-- source neighbour, even if defined as 'liquid_renewable = false'.
|
||||||
|
-- Needed to avoid creating holes in sloping rivers.
|
||||||
|
-- This function can be called from any mod (that depends on bucket).
|
||||||
|
function bucket.register_liquid(source, flowing, itemname, inventory_image, name,
|
||||||
|
groups, force_renew)
|
||||||
|
bucket.liquids[source] = {
|
||||||
|
source = source,
|
||||||
|
flowing = flowing,
|
||||||
|
itemname = itemname,
|
||||||
|
force_renew = force_renew,
|
||||||
|
}
|
||||||
|
bucket.liquids[flowing] = bucket.liquids[source]
|
||||||
|
|
||||||
|
if itemname ~= nil then
|
||||||
|
minetest.register_craftitem(itemname, {
|
||||||
|
description = name,
|
||||||
|
inventory_image = inventory_image,
|
||||||
|
stack_max = 1,
|
||||||
|
liquids_pointable = true,
|
||||||
|
groups = groups,
|
||||||
|
|
||||||
|
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 = node and minetest.registered_nodes[node.name]
|
||||||
|
|
||||||
|
-- Call on_rightclick if the pointed node defines it
|
||||||
|
if ndef and ndef.on_rightclick and
|
||||||
|
not (user and user:is_player() and
|
||||||
|
user:get_player_control().sneak) then
|
||||||
|
return ndef.on_rightclick(
|
||||||
|
pointed_thing.under,
|
||||||
|
node, user,
|
||||||
|
itemstack)
|
||||||
|
end
|
||||||
|
|
||||||
|
local lpos
|
||||||
|
|
||||||
|
-- Check if pointing to a buildable node
|
||||||
|
if ndef and ndef.buildable_to then
|
||||||
|
-- buildable; replace the node
|
||||||
|
lpos = pointed_thing.under
|
||||||
|
else
|
||||||
|
-- not buildable to; place the liquid above
|
||||||
|
-- check if the node above can be replaced
|
||||||
|
|
||||||
|
lpos = pointed_thing.above
|
||||||
|
node = minetest.get_node_or_nil(lpos)
|
||||||
|
local above_ndef = node and minetest.registered_nodes[node.name]
|
||||||
|
|
||||||
|
if not above_ndef or not above_ndef.buildable_to then
|
||||||
|
-- do not remove the bucket with the liquid
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if check_protection(lpos, user
|
||||||
|
and user:get_player_name()
|
||||||
|
or "", "place "..source) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.set_node(lpos, {name = source})
|
||||||
|
return ItemStack("bucket:bucket_empty")
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_craftitem("bucket:bucket_empty", {
|
||||||
|
description = S("Empty Bucket"),
|
||||||
|
inventory_image = "bucket.png",
|
||||||
|
groups = {tool = 1},
|
||||||
|
liquids_pointable = true,
|
||||||
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
if pointed_thing.type == "object" then
|
||||||
|
pointed_thing.ref:punch(user, 1.0, { full_punch_interval=1.0 }, nil)
|
||||||
|
return user:get_wielded_item()
|
||||||
|
elseif pointed_thing.type ~= "node" then
|
||||||
|
-- do nothing if it's neither object nor node
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- Check if pointing to a liquid source
|
||||||
|
local node = minetest.get_node(pointed_thing.under)
|
||||||
|
local liquiddef = bucket.liquids[node.name]
|
||||||
|
local item_count = user:get_wielded_item():get_count()
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
-- default set to return filled bucket
|
||||||
|
local giving_back = liquiddef.itemname
|
||||||
|
|
||||||
|
-- check if holding more than 1 empty bucket
|
||||||
|
if item_count > 1 then
|
||||||
|
|
||||||
|
-- if space in inventory add filled bucked, otherwise drop as item
|
||||||
|
local inv = user:get_inventory()
|
||||||
|
if inv:room_for_item("main", {name=liquiddef.itemname}) then
|
||||||
|
inv:add_item("main", liquiddef.itemname)
|
||||||
|
else
|
||||||
|
local pos = user:get_pos()
|
||||||
|
pos.y = math.floor(pos.y + 0.5)
|
||||||
|
minetest.add_item(pos, liquiddef.itemname)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- set to return empty buckets minus 1
|
||||||
|
giving_back = "bucket:bucket_empty "..tostring(item_count-1)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- force_renew requires a source neighbour
|
||||||
|
local source_neighbor = false
|
||||||
|
if liquiddef.force_renew then
|
||||||
|
source_neighbor =
|
||||||
|
minetest.find_node_near(pointed_thing.under, 1, liquiddef.source)
|
||||||
|
end
|
||||||
|
if not (source_neighbor and liquiddef.force_renew) then
|
||||||
|
minetest.add_node(pointed_thing.under, {name = "air"})
|
||||||
|
end
|
||||||
|
|
||||||
|
return ItemStack(giving_back)
|
||||||
|
else
|
||||||
|
-- non-liquid nodes will have their on_punch triggered
|
||||||
|
local node_def = minetest.registered_nodes[node.name]
|
||||||
|
if node_def then
|
||||||
|
node_def.on_punch(pointed_thing.under, node, user, pointed_thing)
|
||||||
|
end
|
||||||
|
return user:get_wielded_item()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
bucket.register_liquid(
|
||||||
|
"default:water_source",
|
||||||
|
"default:water_flowing",
|
||||||
|
"bucket:bucket_water",
|
||||||
|
"bucket_water.png",
|
||||||
|
S("Water Bucket"),
|
||||||
|
{tool = 1, water_bucket = 1}
|
||||||
|
)
|
||||||
|
|
||||||
|
-- River water source is 'liquid_renewable = false' to avoid horizontal spread
|
||||||
|
-- of water sources in sloping rivers that can cause water to overflow
|
||||||
|
-- riverbanks and cause floods.
|
||||||
|
-- River water source is instead made renewable by the 'force renew' option
|
||||||
|
-- used here.
|
||||||
|
|
||||||
|
bucket.register_liquid(
|
||||||
|
"default:river_water_source",
|
||||||
|
"default:river_water_flowing",
|
||||||
|
"bucket:bucket_river_water",
|
||||||
|
"bucket_river_water.png",
|
||||||
|
S("River Water Bucket"),
|
||||||
|
{tool = 1, water_bucket = 1},
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
|
bucket.register_liquid(
|
||||||
|
"default:lava_source",
|
||||||
|
"default:lava_flowing",
|
||||||
|
"bucket:bucket_lava",
|
||||||
|
"bucket_lava.png",
|
||||||
|
S("Lava Bucket"),
|
||||||
|
{tool = 1}
|
||||||
|
)
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
type = "fuel",
|
||||||
|
recipe = "bucket:bucket_lava",
|
||||||
|
burntime = 60,
|
||||||
|
replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Register buckets as dungeon loot
|
||||||
|
if minetest.global_exists("dungeon_loot") then
|
||||||
|
dungeon_loot.register({
|
||||||
|
{name = "bucket:bucket_empty", chance = 0.55},
|
||||||
|
-- water in deserts/ice or above ground, lava otherwise
|
||||||
|
{name = "bucket:bucket_water", chance = 0.45,
|
||||||
|
types = {"sandstone", "desert", "ice"}},
|
||||||
|
{name = "bucket:bucket_water", chance = 0.45, y = {0, 32768},
|
||||||
|
types = {"normal"}},
|
||||||
|
{name = "bucket:bucket_lava", chance = 0.45, y = {-32768, -1},
|
||||||
|
types = {"normal"}},
|
||||||
|
})
|
||||||
|
end
|
51
mods/bucket/license.txt
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
License of source code
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
GNU Lesser General Public License, version 2.1
|
||||||
|
Copyright (C) 2011-2016 Kahrl <kahrl@gmx.net>
|
||||||
|
Copyright (C) 2011-2016 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||||
|
Copyright (C) 2011-2016 Various Minetest developers and contributors
|
||||||
|
|
||||||
|
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.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Lesser General Public License for more details:
|
||||||
|
https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
|
||||||
|
|
||||||
|
|
||||||
|
Licenses of media (textures)
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||||
|
Copyright (C) 2015-2016 ElementW
|
||||||
|
|
||||||
|
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/
|
5
mods/bucket/locale/bucket.de.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: bucket
|
||||||
|
Empty Bucket=Leerer Eimer
|
||||||
|
Water Bucket=Wassereimer
|
||||||
|
River Water Bucket=Flusswassereimer
|
||||||
|
Lava Bucket=Lavaeimer
|
5
mods/bucket/locale/bucket.eo.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: bucket
|
||||||
|
Empty Bucket=Malplena Sitelo
|
||||||
|
Water Bucket=Sitelo da Akvo
|
||||||
|
River Water Bucket=Sitelo da Rivera Akvo
|
||||||
|
Lava Bucket=Sitelo da Lafo
|
5
mods/bucket/locale/bucket.es.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: bucket
|
||||||
|
Empty Bucket=Cubo vacío
|
||||||
|
Water Bucket=Cubo con agua
|
||||||
|
River Water Bucket=Cubo con agua de río
|
||||||
|
Lava Bucket=Cubo con lava
|
5
mods/bucket/locale/bucket.fr.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: bucket
|
||||||
|
Empty Bucket=Seau vide
|
||||||
|
Water Bucket=Seau d'eau
|
||||||
|
River Water Bucket=Seau d'eau de rivière
|
||||||
|
Lava Bucket=Seau de lave
|
5
mods/bucket/locale/bucket.id.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: bucket
|
||||||
|
Empty Bucket=Ember Kosong
|
||||||
|
Water Bucket=Ember Air
|
||||||
|
River Water Bucket=Ember Air Sungai
|
||||||
|
Lava Bucket=Ember Lava
|
5
mods/bucket/locale/bucket.it.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: bucket
|
||||||
|
Empty Bucket=Secchio vuoto
|
||||||
|
Water Bucket=Secchio d'acqua
|
||||||
|
River Water Bucket=Secchio d'acqua di fiume
|
||||||
|
Lava Bucket=Secchio di lava
|
5
mods/bucket/locale/bucket.ja.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: bucket
|
||||||
|
Empty Bucket=空のバケツ
|
||||||
|
Water Bucket=水入りバケツ
|
||||||
|
River Water Bucket=川の水入りバケツ
|
||||||
|
Lava Bucket=溶岩入りバケツ
|
5
mods/bucket/locale/bucket.jbo.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: bucket
|
||||||
|
Empty Bucket=lo baktu be no da
|
||||||
|
Water Bucket=lo baktu be lo djacu
|
||||||
|
River Water Bucket=lo baktu be lo rirxe djacu
|
||||||
|
Lava Bucket=lo baktu be lo likro'i
|
5
mods/bucket/locale/bucket.ms.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: bucket
|
||||||
|
Empty Bucket=Baldi Kosong
|
||||||
|
Water Bucket=Baldi Air
|
||||||
|
River Water Bucket=Baldi Air Sungai
|
||||||
|
Lava Bucket=Baldi Lava
|
5
mods/bucket/locale/bucket.pl.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: bucket
|
||||||
|
Empty Bucket=Puste wiadro
|
||||||
|
Water Bucket=Wiadro z wodą
|
||||||
|
River Water Bucket=Wiadro z rzeczną wodą
|
||||||
|
Lava Bucket=Wiadro z lawą
|
5
mods/bucket/locale/bucket.pt_BR.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: bucket
|
||||||
|
Empty Bucket=Balde Vazio
|
||||||
|
Water Bucket=Balde de Água
|
||||||
|
River Water Bucket=Balde de Água do Rio
|
||||||
|
Lava Bucket=Balde de Lava
|
5
mods/bucket/locale/bucket.ru.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: bucket
|
||||||
|
Empty Bucket=Пустое Ведро
|
||||||
|
Water Bucket=Ведро с Водой
|
||||||
|
River Water Bucket=Ведро с Речной Водой
|
||||||
|
Lava Bucket=Ведро с Лавой
|
5
mods/bucket/locale/bucket.sk.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: bucket
|
||||||
|
Empty Bucket=Prázdne vedro
|
||||||
|
Water Bucket=Vedro s vodou
|
||||||
|
River Water Bucket=Vedro s vodou z rieky
|
||||||
|
Lava Bucket=Vedro s lávou
|
5
mods/bucket/locale/bucket.sv.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: bucket
|
||||||
|
Empty Bucket=Tom hink
|
||||||
|
Water Bucket=Vattenhink
|
||||||
|
River Water Bucket=Flodvattenshink
|
||||||
|
Lava Bucket=Lavahink
|
5
mods/bucket/locale/bucket.uk.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: bucket
|
||||||
|
Empty Bucket=Пусте Відро
|
||||||
|
Water Bucket=Відро З Водою
|
||||||
|
River Water Bucket=Відро З Річною Водою
|
||||||
|
Lava Bucket=Відро З Лавою
|
5
mods/bucket/locale/bucket.zh_CN.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: bucket
|
||||||
|
Empty Bucket=空桶
|
||||||
|
Water Bucket=水桶
|
||||||
|
River Water Bucket=河水桶
|
||||||
|
Lava Bucket=岩浆桶
|
5
mods/bucket/locale/bucket.zh_TW.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: bucket
|
||||||
|
Empty Bucket=空桶
|
||||||
|
Water Bucket=水桶
|
||||||
|
River Water Bucket=河水桶
|
||||||
|
Lava Bucket=岩漿桶
|
5
mods/bucket/locale/template.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: bucket
|
||||||
|
Empty Bucket=
|
||||||
|
Water Bucket=
|
||||||
|
River Water Bucket=
|
||||||
|
Lava Bucket=
|
4
mods/bucket/mod.conf
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
name = bucket
|
||||||
|
description = Minetest Game mod: bucket
|
||||||
|
depends = default
|
||||||
|
optional_depends = dungeon_loot
|
BIN
mods/bucket/textures/bucket.png
Normal file
After Width: | Height: | Size: 205 B |
BIN
mods/bucket/textures/bucket_lava.png
Normal file
After Width: | Height: | Size: 221 B |
BIN
mods/bucket/textures/bucket_river_water.png
Normal file
After Width: | Height: | Size: 221 B |
BIN
mods/bucket/textures/bucket_water.png
Normal file
After Width: | Height: | Size: 221 B |
194
mods/cops/init.lua
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
-- Pig spawner
|
||||||
|
minetest.register_node("cops:pig_spawner", {
|
||||||
|
walkable = false;
|
||||||
|
--[[on_timer = function(pos)
|
||||||
|
minetest.add_entity(pos, "cops:cop_regular_female")
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_construct = function(pos)
|
||||||
|
minetest.get_node_timer(pos):start(20)
|
||||||
|
end,]]
|
||||||
|
})
|
||||||
|
|
||||||
|
--[[
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"cops:pig_spawner"},
|
||||||
|
--neighbors = {"default:water_source", "default:water_flowing"},
|
||||||
|
interval = 30, -- Run every 10 seconds
|
||||||
|
chance = 5, -- One node has a chance of 1 in 50 to get selected
|
||||||
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
minetest.add_entity(pos, "cops:cop_regular_female")
|
||||||
|
end
|
||||||
|
})]]
|
||||||
|
|
||||||
|
-- Cops
|
||||||
|
mobs:register_mob("cops:cop_regular_female", {
|
||||||
|
type = "monster",
|
||||||
|
passive = false,
|
||||||
|
attack_type = "dogfight",
|
||||||
|
pathfinding = true,
|
||||||
|
reach = 2,
|
||||||
|
damage = 3,
|
||||||
|
hp_min = 16,
|
||||||
|
hp_max = 25,
|
||||||
|
armor = 100,
|
||||||
|
collisionbox =
|
||||||
|
{
|
||||||
|
-.4, 0, -.4, .4, 2, .4
|
||||||
|
},
|
||||||
|
pushable = true,
|
||||||
|
visual = "mesh",
|
||||||
|
mesh = "character.b3d",
|
||||||
|
textures =
|
||||||
|
{
|
||||||
|
{"cop_regular_female.png"},
|
||||||
|
},
|
||||||
|
|
||||||
|
makes_footstep_sound = true,
|
||||||
|
sounds =
|
||||||
|
{
|
||||||
|
random = "female_noise",
|
||||||
|
},
|
||||||
|
|
||||||
|
walk_velocity = 2,
|
||||||
|
run_velocity = 8,
|
||||||
|
jump_height = 1,
|
||||||
|
stepheight = 0,
|
||||||
|
floats = 0,
|
||||||
|
view_range = 45,
|
||||||
|
fall_damage = true,
|
||||||
|
drops =
|
||||||
|
{
|
||||||
|
{name = "cops:badge", chance = 4, min = 0, max = 1},
|
||||||
|
{name = "cops:handcuffs", chance = 3, min = 0, max = 1},
|
||||||
|
{name = "cops:electric_weapon_broken", chance = 3, min = 0, max = 1}
|
||||||
|
},
|
||||||
|
|
||||||
|
animation =
|
||||||
|
{
|
||||||
|
speed_normal = 30,
|
||||||
|
speed_run = 50,
|
||||||
|
stand_start = 0,
|
||||||
|
stand_end = 79,
|
||||||
|
walk_start = 168,
|
||||||
|
walk_end = 187,
|
||||||
|
run_start = 168,
|
||||||
|
run_end = 187,
|
||||||
|
punch_start = 200,
|
||||||
|
punch_end = 219
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
mobs:register_mob("cops:cop_regular_male", {
|
||||||
|
type = "monster",
|
||||||
|
passive = false,
|
||||||
|
attack_type = "dogfight",
|
||||||
|
pathfinding = true,
|
||||||
|
reach = 2,
|
||||||
|
damage = 3,
|
||||||
|
hp_min = 21,
|
||||||
|
hp_max = 25,
|
||||||
|
armor = 100,
|
||||||
|
collisionbox =
|
||||||
|
{
|
||||||
|
-.4, 0, -.4, .4, 2, .4
|
||||||
|
},
|
||||||
|
pushable = true,
|
||||||
|
visual = "mesh",
|
||||||
|
mesh = "character.b3d",
|
||||||
|
textures =
|
||||||
|
{
|
||||||
|
{"cop_regular_male.png"},
|
||||||
|
},
|
||||||
|
|
||||||
|
makes_footstep_sound = true,
|
||||||
|
sounds =
|
||||||
|
{
|
||||||
|
random = "male_noise",
|
||||||
|
},
|
||||||
|
|
||||||
|
walk_velocity = 2,
|
||||||
|
run_velocity = 8,
|
||||||
|
jump_height = 1,
|
||||||
|
stepheight = 0,
|
||||||
|
floats = 0,
|
||||||
|
view_range = 45,
|
||||||
|
fall_damage = true,
|
||||||
|
drops =
|
||||||
|
{
|
||||||
|
{name = "cops:badge", chance = 4, min = 0, max = 1},
|
||||||
|
{name = "cops:handcuffs", chance = 3, min = 0, max = 1},
|
||||||
|
{name = "cops:electric_weapon_broken", chance = 3, min = 0, max = 1}
|
||||||
|
},
|
||||||
|
|
||||||
|
animation =
|
||||||
|
{
|
||||||
|
speed_normal = 30,
|
||||||
|
speed_run = 50,
|
||||||
|
stand_start = 0,
|
||||||
|
stand_end = 79,
|
||||||
|
walk_start = 168,
|
||||||
|
walk_end = 187,
|
||||||
|
run_start = 168,
|
||||||
|
run_end = 187,
|
||||||
|
punch_start = 200,
|
||||||
|
punch_end = 219
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
mobs:register_mob("cops:cop_armedthug", {
|
||||||
|
type = "monster",
|
||||||
|
passive = false,
|
||||||
|
attack_type = "dogfight",
|
||||||
|
pathfinding = true,
|
||||||
|
reach = 3,
|
||||||
|
damage = 5,
|
||||||
|
hp_min = 46,
|
||||||
|
hp_max = 50,
|
||||||
|
armor = 100,
|
||||||
|
collisionbox =
|
||||||
|
{
|
||||||
|
-.4, 0, -.4, .4, 2, .4
|
||||||
|
},
|
||||||
|
pushable = true,
|
||||||
|
visual = "mesh",
|
||||||
|
mesh = "character.b3d",
|
||||||
|
textures =
|
||||||
|
{
|
||||||
|
{"cop_armedthug.png"},
|
||||||
|
},
|
||||||
|
|
||||||
|
makes_footstep_sound = true,
|
||||||
|
sounds =
|
||||||
|
{
|
||||||
|
random = "male_noise",
|
||||||
|
},
|
||||||
|
|
||||||
|
walk_velocity = 2,
|
||||||
|
run_velocity = 8,
|
||||||
|
jump_height = 1,
|
||||||
|
stepheight = 0,
|
||||||
|
floats = 0,
|
||||||
|
view_range = 45,
|
||||||
|
fall_damage = true,
|
||||||
|
drops =
|
||||||
|
{
|
||||||
|
{name = "cops:badge", chance = 3, min = 0, max = 1},
|
||||||
|
{name = "cops:handcuffs", chance = 4, min = 1, max = 2},
|
||||||
|
},
|
||||||
|
|
||||||
|
animation =
|
||||||
|
{
|
||||||
|
speed_normal = 30,
|
||||||
|
speed_run = 50,
|
||||||
|
stand_start = 0,
|
||||||
|
stand_end = 79,
|
||||||
|
walk_start = 168,
|
||||||
|
walk_end = 187,
|
||||||
|
run_start = 168,
|
||||||
|
run_end = 187,
|
||||||
|
punch_start = 200,
|
||||||
|
punch_end = 219
|
||||||
|
},
|
||||||
|
})
|
2
mods/cops/mod.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
name = cops
|
||||||
|
depends = mobs
|
BIN
mods/cops/textures/cop_armedthug.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
mods/cops/textures/cop_regular_female.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
mods/cops/textures/cop_regular_male.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
mods/cops/textures/cops_badge.png
Normal file
After Width: | Height: | Size: 310 B |
BIN
mods/cops/textures/cops_baton.png
Normal file
After Width: | Height: | Size: 304 B |
BIN
mods/cops/textures/cops_electric_weapon_broken.png
Normal file
After Width: | Height: | Size: 350 B |
BIN
mods/cops/textures/cops_handcuffs.png
Normal file
After Width: | Height: | Size: 256 B |
17
mods/creative/README.txt
Normal file
@ -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)
|
101
mods/creative/init.lua
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
-- creative/init.lua
|
||||||
|
|
||||||
|
-- Load support for MT game translation.
|
||||||
|
local S = minetest.get_translator("creative")
|
||||||
|
|
||||||
|
creative = {}
|
||||||
|
creative.get_translator = S
|
||||||
|
|
||||||
|
local function update_sfinv(name)
|
||||||
|
minetest.after(0, function()
|
||||||
|
local player = minetest.get_player_by_name(name)
|
||||||
|
if player then
|
||||||
|
if sfinv.get_page(player):sub(1, 9) == "creative:" then
|
||||||
|
sfinv.set_page(player, sfinv.get_homepage_name(player))
|
||||||
|
else
|
||||||
|
sfinv.set_player_inventory_formspec(player)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_privilege("creative", {
|
||||||
|
description = S("Allow player to use creative inventory"),
|
||||||
|
give_to_singleplayer = false,
|
||||||
|
give_to_admin = false,
|
||||||
|
on_grant = update_sfinv,
|
||||||
|
on_revoke = update_sfinv,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Override the engine's creative mode function
|
||||||
|
local old_is_creative_enabled = minetest.is_creative_enabled
|
||||||
|
|
||||||
|
function minetest.is_creative_enabled(name)
|
||||||
|
if name == "" then
|
||||||
|
return old_is_creative_enabled(name)
|
||||||
|
end
|
||||||
|
return minetest.check_player_privs(name, {creative = true}) or
|
||||||
|
old_is_creative_enabled(name)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- For backwards compatibility:
|
||||||
|
function creative.is_enabled_for(name)
|
||||||
|
return minetest.is_creative_enabled(name)
|
||||||
|
end
|
||||||
|
|
||||||
|
dofile(minetest.get_modpath("creative") .. "/inventory.lua")
|
||||||
|
|
||||||
|
if minetest.is_creative_enabled("") 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}
|
||||||
|
|
||||||
|
-- Override the hand tool
|
||||||
|
minetest.override_item("", {
|
||||||
|
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,
|
||||||
|
-- dig_immediate group doesn't use value 1. Value 3 is instant dig
|
||||||
|
dig_immediate =
|
||||||
|
{times = {[2] = digtime, [3] = 0}, uses = 0, maxlevel = 256},
|
||||||
|
},
|
||||||
|
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 minetest.is_creative_enabled(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 minetest.is_creative_enabled(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
|
256
mods/creative/inventory.lua
Normal file
@ -0,0 +1,256 @@
|
|||||||
|
-- creative/inventory.lua
|
||||||
|
|
||||||
|
-- support for MT game translation.
|
||||||
|
local S = creative.get_translator
|
||||||
|
|
||||||
|
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,
|
||||||
|
old_filter = nil, -- use only for caching in update_creative_inventory
|
||||||
|
old_content = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
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 minetest.is_creative_enabled(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 minetest.is_creative_enabled(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
|
||||||
|
|
||||||
|
local NO_MATCH = 999
|
||||||
|
local function match(s, filter)
|
||||||
|
if filter == "" then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
if s:lower():find(filter, 1, true) then
|
||||||
|
return #s - #filter
|
||||||
|
end
|
||||||
|
return NO_MATCH
|
||||||
|
end
|
||||||
|
|
||||||
|
local function description(def, lang_code)
|
||||||
|
local s = def.description
|
||||||
|
if lang_code then
|
||||||
|
s = minetest.get_translated_string(lang_code, s)
|
||||||
|
end
|
||||||
|
return s:gsub("\n.*", "") -- First line only
|
||||||
|
end
|
||||||
|
|
||||||
|
function creative.update_creative_inventory(player_name, tab_content)
|
||||||
|
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})
|
||||||
|
|
||||||
|
if inv.filter == inv.old_filter and tab_content == inv.old_content then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
inv.old_filter = inv.filter
|
||||||
|
inv.old_content = tab_content
|
||||||
|
|
||||||
|
local items = inventory_cache[tab_content] or init_creative_cache(tab_content)
|
||||||
|
|
||||||
|
local lang
|
||||||
|
local player_info = minetest.get_player_information(player_name)
|
||||||
|
if player_info and player_info.lang_code ~= "" then
|
||||||
|
lang = player_info.lang_code
|
||||||
|
end
|
||||||
|
|
||||||
|
local creative_list = {}
|
||||||
|
local order = {}
|
||||||
|
for name, def in pairs(items) do
|
||||||
|
local m = match(description(def), inv.filter)
|
||||||
|
if m > 0 then
|
||||||
|
m = math.min(m, match(description(def, lang), inv.filter))
|
||||||
|
end
|
||||||
|
if m > 0 then
|
||||||
|
m = math.min(m, match(name, inv.filter))
|
||||||
|
end
|
||||||
|
|
||||||
|
if m < NO_MATCH then
|
||||||
|
creative_list[#creative_list+1] = name
|
||||||
|
-- Sort by match value first so closer matches appear earlier
|
||||||
|
order[name] = string.format("%02d", m) .. name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.sort(creative_list, function(a, b) return order[a] < order[b] end)
|
||||||
|
|
||||||
|
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("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 minetest.is_creative_enabled(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 pagenum = math.floor(inv.start_i / (4*8) + 1)
|
||||||
|
local pagemax = math.ceil(inv.size / (4*8))
|
||||||
|
local esc = minetest.formspec_escape
|
||||||
|
return sfinv.make_formspec(player, context,
|
||||||
|
"label[5.8,4.15;" .. minetest.colorize("#FFFF00", tostring(pagenum)) .. " / " .. tostring(pagemax) .. "]" ..
|
||||||
|
[[
|
||||||
|
image[4.08,4.2;0.8,0.8;creative_trash_icon.png]
|
||||||
|
listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]
|
||||||
|
list[detached:trash;main;4.02,4.1;1,1;]
|
||||||
|
listring[]
|
||||||
|
image_button[5,4.05;0.8,0.8;creative_prev_icon.png;creative_prev;]
|
||||||
|
image_button[7.2,4.05;0.8,0.8;creative_next_icon.png;creative_next;]
|
||||||
|
image_button[2.63,4.05;0.8,0.8;creative_search_icon.png;creative_search;]
|
||||||
|
image_button[3.25,4.05;0.8,0.8;creative_clear_icon.png;creative_clear;]
|
||||||
|
]] ..
|
||||||
|
"tooltip[creative_search;" .. esc(S("Search")) .. "]" ..
|
||||||
|
"tooltip[creative_clear;" .. esc(S("Reset")) .. "]" ..
|
||||||
|
"tooltip[creative_prev;" .. esc(S("Previous page")) .. "]" ..
|
||||||
|
"tooltip[creative_next;" .. esc(S("Next page")) .. "]" ..
|
||||||
|
"listring[current_player;main]" ..
|
||||||
|
"field_close_on_enter[creative_filter;false]" ..
|
||||||
|
"field[0.3,4.2;2.8,1.2;creative_filter;;" .. esc(inv.filter) .. "]" ..
|
||||||
|
"listring[detached:creative_" .. player_name .. ";main]" ..
|
||||||
|
"list[detached:creative_" .. player_name .. ";main;0,0;8,4;" .. tostring(inv.start_i) .. "]" ..
|
||||||
|
creative.formspec_add, true)
|
||||||
|
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 = ""
|
||||||
|
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()
|
||||||
|
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 - 4*8
|
||||||
|
if start_i < 0 then
|
||||||
|
start_i = inv.size - (inv.size % (4*8))
|
||||||
|
if inv.size == start_i then
|
||||||
|
start_i = math.max(0, inv.size - (4*8))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif fields.creative_next then
|
||||||
|
start_i = start_i + 4*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
|
||||||
|
|
||||||
|
-- Sort registered items
|
||||||
|
local registered_nodes = {}
|
||||||
|
local registered_tools = {}
|
||||||
|
local registered_craftitems = {}
|
||||||
|
|
||||||
|
minetest.register_on_mods_loaded(function()
|
||||||
|
for name, def in pairs(minetest.registered_items) do
|
||||||
|
local group = def.groups or {}
|
||||||
|
|
||||||
|
local nogroup = not (group.node or group.tool or group.craftitem)
|
||||||
|
if group.node or (nogroup and minetest.registered_nodes[name]) then
|
||||||
|
registered_nodes[name] = def
|
||||||
|
elseif group.tool or (nogroup and minetest.registered_tools[name]) then
|
||||||
|
registered_tools[name] = def
|
||||||
|
elseif group.craftitem or (nogroup and minetest.registered_craftitems[name]) then
|
||||||
|
registered_craftitems[name] = def
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
creative.register_tab("all", S("All"), minetest.registered_items)
|
||||||
|
creative.register_tab("nodes", S("Nodes"), registered_nodes)
|
||||||
|
creative.register_tab("tools", S("Tools"), registered_tools)
|
||||||
|
creative.register_tab("craftitems", S("Items"), registered_craftitems)
|
||||||
|
|
||||||
|
local old_homepage_name = sfinv.get_homepage_name
|
||||||
|
function sfinv.get_homepage_name(player)
|
||||||
|
if minetest.is_creative_enabled(player:get_player_name()) then
|
||||||
|
return "creative:all"
|
||||||
|
else
|
||||||
|
return old_homepage_name(player)
|
||||||
|
end
|
||||||
|
end
|
61
mods/creative/license.txt
Normal file
@ -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/
|
10
mods/creative/locale/creative.de.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: creative
|
||||||
|
Allow player to use creative inventory=Spieler erlauben, das Kreativinventar zu benutzen
|
||||||
|
Search=Suchen
|
||||||
|
Reset=Zurücksetzen
|
||||||
|
Previous page=Vorherige Seite
|
||||||
|
Next page=Nächste Seite
|
||||||
|
All=Alles
|
||||||
|
Nodes=Blöcke
|
||||||
|
Tools=Werkzeuge
|
||||||
|
Items=Gegenstände
|
10
mods/creative/locale/creative.eo.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: creative
|
||||||
|
Allow player to use creative inventory=Permesi ke la ludanto uzu la kreeman stokon
|
||||||
|
Search=Serĉi
|
||||||
|
Reset=Rekomencigi
|
||||||
|
Previous page=Antaŭa paĝo
|
||||||
|
Next page=Sekva paĝo
|
||||||
|
All=Ĉio
|
||||||
|
Nodes=Nodoj
|
||||||
|
Tools=Iloj
|
||||||
|
Items=Objektoj
|
10
mods/creative/locale/creative.es.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: creative
|
||||||
|
Allow player to use creative inventory=Permitir al jugador usar el inventario creativo
|
||||||
|
Search=Buscar
|
||||||
|
Reset=Resetear
|
||||||
|
Previous page=Pág. siguiente
|
||||||
|
Next page=Pág. anterior
|
||||||
|
All=Todos
|
||||||
|
Nodes=Nodos
|
||||||
|
Tools=Herramientas
|
||||||
|
Items=Objetos
|
10
mods/creative/locale/creative.fr.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: creative
|
||||||
|
Allow player to use creative inventory=Permettre aux joueurs d'utiliser l'inventaire du mode créatif
|
||||||
|
Search=Rechercher
|
||||||
|
Reset=Réinitialiser
|
||||||
|
Previous page=Page précédente
|
||||||
|
Next page=Page suivante
|
||||||
|
All=Tout
|
||||||
|
Nodes=Nœuds
|
||||||
|
Tools=Outils
|
||||||
|
Items=Article
|
10
mods/creative/locale/creative.id.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: creative
|
||||||
|
Allow player to use creative inventory=Bolehkan pemain memakai inventaris kreatif
|
||||||
|
Search=Cari
|
||||||
|
Reset=Atur ulang
|
||||||
|
Previous page=Halaman sebelumnya
|
||||||
|
Next page=Halaman selanjutnya
|
||||||
|
All=Semua
|
||||||
|
Nodes=Nodus
|
||||||
|
Tools=Perkakas
|
||||||
|
Items=Barang
|
10
mods/creative/locale/creative.it.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: creative
|
||||||
|
Allow player to use creative inventory=Permette al giocatore di usare l'inventario creativo
|
||||||
|
Search=Cerca
|
||||||
|
Reset=Azzera
|
||||||
|
Previous page=Pagina precedente
|
||||||
|
Next page=Pagina successiva
|
||||||
|
All=Tutto
|
||||||
|
Nodes=Nodi
|
||||||
|
Tools=Strumenti
|
||||||
|
Items=Oggetti
|
10
mods/creative/locale/creative.ja.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: creative
|
||||||
|
Allow player to use creative inventory=プレーヤーにクリエイティブ インベントリーの使用を許可する
|
||||||
|
Search=検索
|
||||||
|
Reset=リセット
|
||||||
|
Previous page=前のページ
|
||||||
|
Next page=次のページ
|
||||||
|
All=すべて
|
||||||
|
Nodes=ブロック
|
||||||
|
Tools=道具
|
||||||
|
Items=アイテム
|
10
mods/creative/locale/creative.jbo.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: creative
|
||||||
|
Allow player to use creative inventory=zifre le ka pilno le finti ke dacti liste
|
||||||
|
Search=sisku
|
||||||
|
Reset=kraga'igau
|
||||||
|
Previous page=lidne
|
||||||
|
Next page=selyli'e
|
||||||
|
All=ro dacti
|
||||||
|
Nodes=bliku
|
||||||
|
Tools=tutci
|
||||||
|
Items=dacti
|
10
mods/creative/locale/creative.ms.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: creative
|
||||||
|
Allow player to use creative inventory=Benarkan pemain menggunakan inventori kreatif
|
||||||
|
Search=Cari
|
||||||
|
Reset=Set semula
|
||||||
|
Previous page=Halaman sebelumnya
|
||||||
|
Next page=Halaman seterusnya
|
||||||
|
All=Semua
|
||||||
|
Nodes=Nod
|
||||||
|
Tools=Alatan
|
||||||
|
Items=Item
|
10
mods/creative/locale/creative.pl.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: creative
|
||||||
|
Allow player to use creative inventory=Zezwól graczom na używanie kreatywnego ekwipunku
|
||||||
|
Search=Wyszukaj
|
||||||
|
Reset=Zresetuj
|
||||||
|
Previous page=Poprzednia strona
|
||||||
|
Next page=Następna strona
|
||||||
|
All=Wszystko
|
||||||
|
Nodes=Bloki
|
||||||
|
Tools=Narzędzia
|
||||||
|
Items=Przedmioty
|
10
mods/creative/locale/creative.pt_BR.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: creative
|
||||||
|
Allow player to use creative inventory=Permitir o jogador usar o inventário criativo
|
||||||
|
Search=Pesquisar
|
||||||
|
Reset=Redefinir
|
||||||
|
Previous page=Página anterior
|
||||||
|
Next page=Próxima página
|
||||||
|
All=Todos
|
||||||
|
Nodes=Blocos
|
||||||
|
Tools=Ferramentas
|
||||||
|
Items=Itens
|
10
mods/creative/locale/creative.ru.tr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# textdomain: creative
|
||||||
|
Allow player to use creative inventory=Разрешить игроку использовать творческий инвентарь
|
||||||
|
Search=Поиск
|
||||||
|
Reset=Сброс
|
||||||
|
Previous page=Предыдущая страница
|
||||||
|
Next page=Следующая страница
|
||||||
|
All=Всё
|
||||||
|
Nodes=Ноды
|
||||||
|
Tools=Инструменты
|
||||||
|
Items=Предметы
|