Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
226ccd07b7 |
29
.gitignore
vendored
Normal file → Executable file
@ -1,9 +1,22 @@
|
||||
## Generic ignorable patterns and files
|
||||
*~
|
||||
.*.swp
|
||||
*bak*
|
||||
tags
|
||||
*.vim
|
||||
|
||||
## Files related to minetest development cycle
|
||||
*.patch
|
||||
/*.patch
|
||||
# GNU Patch reject file
|
||||
*.rej
|
||||
|
||||
## Editors and Development environments
|
||||
*~
|
||||
*.swp
|
||||
*.bak*
|
||||
*.orig
|
||||
# Vim
|
||||
*.vim
|
||||
# Kate
|
||||
.*.kate-swp
|
||||
.swp.*
|
||||
# Eclipse (LDT)
|
||||
.project
|
||||
.settings/
|
||||
.buildpath
|
||||
.metadata
|
||||
# Idea IDE
|
||||
.idea/*
|
||||
|
0
README.txt
Normal file → Executable file
2
game.conf
Normal file → Executable file
@ -1 +1 @@
|
||||
name = Minetest Game
|
||||
name = MinetestForFun Game
|
||||
|
73
game_api.txt
Normal file → Executable file
@ -12,22 +12,28 @@ Please note:
|
||||
|
||||
* [XYZ] refers to a section the Minetest API
|
||||
* [#ABC] refers to a section in this document
|
||||
* [pos] refers to a position table `{x = -5, y = 0, z = 200}`
|
||||
|
||||
Bucket API
|
||||
----------
|
||||
|
||||
The bucket API allows registering new types of buckets for non-default liquids.
|
||||
|
||||
|
||||
bucket.register_liquid(
|
||||
"default:lava_source", -- name of the source node
|
||||
"default:lava_flowing", -- name of the flowing node
|
||||
"bucket:bucket_lava", -- name of the new bucket item (or nil if liquid is not takeable)
|
||||
"bucket_lava.png", -- texture of the new bucket item (ignored if itemname == nil)
|
||||
"Lava Bucket", -- text description of the bucket item
|
||||
{lava_bucket = 1} -- groups of the bucket item, OPTIONAL
|
||||
{lava_bucket = 1}, -- groups of the bucket item, OPTIONAL
|
||||
false -- force-renew, OPTIONAL. 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.
|
||||
)
|
||||
|
||||
The filled bucket item is returned to the player that uses an empty bucket pointing to the given liquid source.
|
||||
When punching with an empty bucket pointing to an entity or a non-liquid node, the on_punch of the entity or node will be triggered.
|
||||
|
||||
Beds API
|
||||
--------
|
||||
|
||||
@ -61,6 +67,11 @@ Beds API
|
||||
}
|
||||
}
|
||||
|
||||
Creative API
|
||||
------------
|
||||
|
||||
A global string called `creative.formspec_add` was added which allows mods to add additional formspec elements onto the default creative inventory formspec to be drawn after each update.
|
||||
|
||||
Doors API
|
||||
---------
|
||||
|
||||
@ -177,6 +188,9 @@ The farming API allows you to easily register plants and hoes.
|
||||
`farming.register_plant(name, Plant definition)`
|
||||
* Register a new growing plant, see [#Plant definition]
|
||||
|
||||
`farming.registered_plants[name] = definition`
|
||||
* Table of registered plants, indexed by plant name
|
||||
|
||||
### Hoe Definition
|
||||
|
||||
|
||||
@ -213,6 +227,14 @@ New node def property:
|
||||
* Called when fire attempts to remove a burning node.
|
||||
* `pos` Position of the burning node.
|
||||
|
||||
`on_ignite(pos, igniter)`
|
||||
|
||||
* Called when Flint and steel (or a mod defined ignitor) is used on a node.
|
||||
Defining it may prevent the default action (spawning flames) from triggering.
|
||||
* `pos` Position of the ignited node.
|
||||
* `igniter` Player that used the tool, when available.
|
||||
|
||||
|
||||
Give Initial Stuff API
|
||||
----------------------
|
||||
|
||||
@ -244,6 +266,18 @@ Give Initial Stuff API
|
||||
^ str is a comma separated list of initial stuff
|
||||
^ Adds items to the list of items to be given
|
||||
|
||||
Nyancat API
|
||||
-----------
|
||||
|
||||
`nyancat.place(pos, facedir, length)`
|
||||
|
||||
^ Place a cat at `pos` facing `facedir` with tail length `length`
|
||||
Only accepts facedir 0-3, if facedir > 3 then it will be interpreted as facedir = 0
|
||||
|
||||
`nyancat.generate(minp, maxp, seed)`
|
||||
|
||||
^ Called by `minetest.register_on_generated`. To disable nyancat generation,
|
||||
you can redefine nyancat.generate() to be an empty function
|
||||
|
||||
TNT API
|
||||
----------
|
||||
@ -272,9 +306,9 @@ TNT API
|
||||
* `position` The center of explosion.
|
||||
* `definition` The TNT definion as passed to `tnt.register`
|
||||
|
||||
`tnt.burn(position)`
|
||||
`tnt.burn(position, [nodename])`
|
||||
|
||||
^ Ignite TNT at position
|
||||
^ Ignite TNT at position, nodename isn't required unless already known.
|
||||
|
||||
|
||||
To make dropping items from node inventories easier, you can use the
|
||||
@ -330,9 +364,33 @@ To use it, add the `on_screwdriver` function to the node definition.
|
||||
* `new_param2` the new value of param2 that would have been set if on_rotate wasn't there
|
||||
* return value: false to disallow rotation, nil to keep default behaviour, true to allow
|
||||
it but to indicate that changed have already been made (so the screwdriver will wear out)
|
||||
* use `on_rotate = screwdriver.disallow` to always disallow rotation
|
||||
* use `on_rotate = false` to always disallow rotation
|
||||
* use `on_rotate = screwdriver.rotate_simple` to allow only face rotation
|
||||
|
||||
|
||||
Sethome API
|
||||
-----------
|
||||
|
||||
The sethome API adds three global functions to allow mods to read a players home position,
|
||||
set a players home position and teleport a player to home position.
|
||||
|
||||
`sethome.get(name)`
|
||||
|
||||
* `name` Player who's home position you wish to get
|
||||
* return value: false if no player home coords exist, position table if true
|
||||
|
||||
`sethome.set(name, pos)`
|
||||
|
||||
* `name` Player who's home position you wish to set
|
||||
* `pos` Position table containing coords of home position
|
||||
* return value: false if unable to set and save new home position, otherwise true
|
||||
|
||||
`sethome.go(name)`
|
||||
|
||||
* `name` Player you wish to teleport to their home position
|
||||
* return value: false if player cannot be sent home, otherwise true
|
||||
|
||||
|
||||
Stairs API
|
||||
----------
|
||||
|
||||
@ -343,7 +401,7 @@ delivered with Minetest Game, to keep them compatible with other mods.
|
||||
|
||||
* Registers a stair.
|
||||
* `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname"
|
||||
* `recipeitem`: Item used in the craft recipe, e.g. "default:cobble"
|
||||
* `recipeitem`: Item used in the craft recipe, e.g. "default:cobble", may be `nil`
|
||||
* `groups`: see [Known damage and digging time defining groups]
|
||||
* `images`: see [Tile definition]
|
||||
* `description`: used for the description field in the stair's definition
|
||||
@ -379,7 +437,7 @@ Creates panes that automatically connect to each other
|
||||
### Pane definition
|
||||
|
||||
{
|
||||
textures = {"texture_Bottom_top", "texture_left_right", "texture_front_back"}, -- More tiles aren't supported
|
||||
textures = {"texture for sides", (unused), "texture for top and bottom"}, -- More tiles aren't supported
|
||||
groups = {group = rating}, -- Uses the known node groups, see [Known damage and digging time defining groups]
|
||||
sounds = SoundSpec, -- See [#Default sounds]
|
||||
recipe = {{"","","","","","","","",""}}, -- Recipe field only
|
||||
@ -416,6 +474,7 @@ Sounds inside the default table can be used within the sounds field of node defi
|
||||
* `default.node_sound_wood_defaults()`
|
||||
* `default.node_sound_leaves_defaults()`
|
||||
* `default.node_sound_glass_defaults()`
|
||||
* `default.node_sound_metal_defaults()`
|
||||
|
||||
Default constants
|
||||
-----------------
|
||||
|
BIN
menu/header.png
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 904 B |
0
menu/icon.png
Normal file → Executable file
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
3
minetest.conf
Normal file → Executable file
@ -0,0 +1,3 @@
|
||||
# Enable jungles on new worlds, disable biome blend and mud flow (faster, looks better).
|
||||
mgv6_spflags = jungles, nobiomeblend, nomudflow
|
||||
disable_fire = true
|
||||
|
12
minetest.conf.example
Normal file → Executable file
@ -5,6 +5,12 @@
|
||||
# Whether creative mode (fast digging of all blocks, unlimited resources) should be enabled
|
||||
#creative_mode = false
|
||||
|
||||
# Sets the behaviour of the inventory items when a player dies.
|
||||
# "bones": Store all items inside a bone node but drop items if inside protected area
|
||||
# "drop": Drop all items on the ground
|
||||
# "keep": Player keeps all items
|
||||
#bones_mode = "bones"
|
||||
|
||||
# The time in seconds after which the bones of a dead player can be looted by everyone
|
||||
# 0 to disable
|
||||
#share_bones_time = 1200
|
||||
@ -14,9 +20,9 @@
|
||||
# 0 to disable. By default it is "share_bones_time" divide by four.
|
||||
#share_bones_time_early = 300
|
||||
|
||||
# Whether standard fire should be disabled ('basic flame' nodes will disappear)
|
||||
# 'permanent flame' nodes will remain with either setting
|
||||
#disable_fire = false
|
||||
# Whether fire should be enabled. If disabled, 'basic flame' nodes will disappear.
|
||||
# 'permanent flame' nodes will remain with either setting.
|
||||
#enable_fire = true
|
||||
|
||||
# Whether the stuff in initial_stuff should be given to new players
|
||||
#give_initial_stuff = false
|
||||
|
9
mods/_misc_init/init.lua
Executable file
@ -0,0 +1,9 @@
|
||||
----------------------------------------
|
||||
-- Server Misc Mod - pre-default init --
|
||||
----------------------------------------
|
||||
|
||||
local cwd = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
-- Inventory refill function override
|
||||
-- see https://github.com/MinetestForFun/server-minetestforfun/issues/462
|
||||
dofile(cwd.."/inventory_rotate_node.lua")
|
22
mods/_misc_init/inventory_rotate_node.lua
Normal file
@ -0,0 +1,22 @@
|
||||
--rewrite function minetest.rotate_node(itemstack, placer, pointed_thing) to refill inventory
|
||||
local old_rotate_node = minetest.rotate_node
|
||||
function minetest.rotate_node(itemstack, placer, pointed_thing)
|
||||
local stack_name = itemstack:get_name()
|
||||
local ret = old_rotate_node(itemstack, placer, pointed_thing)
|
||||
if ret:get_count() == 0 and not minetest.setting_getbool("creative_mode") then
|
||||
local index = placer:get_wield_index()
|
||||
local inv = placer:get_inventory()
|
||||
if inv:get_list("main") then
|
||||
for i, stack in ipairs(inv:get_list("main")) do
|
||||
if i ~= index and stack:get_name() == stack_name then
|
||||
ret:add_item(stack)
|
||||
stack:clear()
|
||||
inv:set_stack("main", i, stack)
|
||||
minetest.log("action", "Inventory Tweaks: refilled stack("..stack_name..") of " .. placer:get_player_name())
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
0
mods/beds/README.txt
Normal file → Executable file
106
mods/beds/api.lua
Normal file → Executable file
@ -1,27 +1,3 @@
|
||||
|
||||
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)
|
||||
nodeupdate(other)
|
||||
else
|
||||
reverse = not reverse
|
||||
end
|
||||
end
|
||||
|
||||
function beds.register_bed(name, def)
|
||||
minetest.register_node(name .. "_bottom", {
|
||||
description = def.description,
|
||||
@ -43,58 +19,42 @@ function beds.register_bed(name, def)
|
||||
type = "fixed",
|
||||
fixed = def.selectionbox,
|
||||
},
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local under = pointed_thing.under
|
||||
local pos
|
||||
if minetest.registered_items[minetest.get_node(under).name].buildable_to then
|
||||
pos = under
|
||||
else
|
||||
pos = pointed_thing.above
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
local n = minetest.get_node_or_nil(pos)
|
||||
if not n or not n.param2 then
|
||||
minetest.remove_node(pos)
|
||||
return true
|
||||
end
|
||||
|
||||
if minetest.is_protected(pos, placer:get_player_name()) and
|
||||
not minetest.check_player_privs(placer, "protection_bypass") then
|
||||
minetest.record_protection_violation(pos, placer:get_player_name())
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local def = minetest.registered_nodes[minetest.get_node(pos).name]
|
||||
local dir = minetest.facedir_to_dir(n.param2)
|
||||
local p = vector.add(pos, dir)
|
||||
local n2 = minetest.get_node_or_nil(p)
|
||||
local def = n2 and minetest.registered_items[n2.name]
|
||||
if not def or not def.buildable_to then
|
||||
return itemstack
|
||||
minetest.remove_node(pos)
|
||||
return true
|
||||
end
|
||||
|
||||
local dir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
local botpos = vector.add(pos, minetest.facedir_to_dir(dir))
|
||||
|
||||
if minetest.is_protected(botpos, placer:get_player_name()) and
|
||||
not minetest.check_player_privs(placer, "protection_bypass") then
|
||||
minetest.record_protection_violation(botpos, placer:get_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.setting_getbool("creative_mode") then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
minetest.set_node(p, {name = n.name:gsub("%_bottom", "_top"), param2 = n.param2})
|
||||
return false
|
||||
end,
|
||||
|
||||
on_destruct = function(pos)
|
||||
destruct_bed(pos, 1)
|
||||
local n = minetest.get_node_or_nil(pos)
|
||||
if not n then return end
|
||||
local dir = minetest.facedir_to_dir(n.param2)
|
||||
local p = vector.add(pos, dir)
|
||||
local n2 = minetest.get_node(p)
|
||||
if minetest.get_item_group(n2.name, "bed") == 2 and n.param2 == n2.param2 then
|
||||
minetest.remove_node(p)
|
||||
end
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local name = digger:get_player_name()
|
||||
if not name or name == "" then return end
|
||||
beds.spawn[name] = nil
|
||||
beds.save_spawns()
|
||||
end,
|
||||
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
beds.on_rightclick(pos, clicker)
|
||||
end,
|
||||
|
||||
on_rotate = function(pos, node, user, mode, new_param2)
|
||||
local dir = minetest.facedir_to_dir(node.param2)
|
||||
local p = vector.add(pos, dir)
|
||||
@ -121,10 +81,9 @@ function beds.register_bed(name, def)
|
||||
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})
|
||||
minetest.swap_node(pos, node)
|
||||
minetest.remove_node(p)
|
||||
minetest.set_node(newp, {name = node.name:gsub("%_bottom", "_top"), param2 = new_param2})
|
||||
return true
|
||||
end,
|
||||
})
|
||||
@ -138,18 +97,15 @@ function beds.register_bed(name, def)
|
||||
pointable = false,
|
||||
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 2},
|
||||
sounds = 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")
|
||||
|
||||
-- register recipe
|
||||
minetest.register_craft({
|
||||
output = name,
|
||||
recipe = def.recipe
|
||||
|
66
mods/beds/beds.lua
Normal file → Executable file
@ -1,23 +1,22 @@
|
||||
-- Fancy shaped bed
|
||||
|
||||
beds.register_bed("beds:fancy_bed", {
|
||||
description = "Fancy Bed",
|
||||
inventory_image = "beds_bed_fancy.png",
|
||||
wield_image = "beds_bed_fancy.png",
|
||||
for _, colour in pairs({"red", "white", "black", "blue", "green"}) do-- fancy shaped bed
|
||||
beds.register_bed("beds:fancy_bed_" .. colour, {
|
||||
description = "Fancy Bed (" .. colour .. ")",
|
||||
inventory_image = "beds_bed_fancy_" .. colour .. ".png",
|
||||
wield_image = "beds_bed_fancy_" .. colour .. ".png",
|
||||
tiles = {
|
||||
bottom = {
|
||||
"beds_bed_top1.png",
|
||||
"beds_bed_top1_" .. colour .. ".png",
|
||||
"default_wood.png",
|
||||
"beds_bed_side1.png",
|
||||
"beds_bed_side1.png^[transformFX",
|
||||
"beds_bed_side1_" .. colour .. ".png",
|
||||
"beds_bed_side1_" .. colour .. ".png^[transformFX",
|
||||
"default_wood.png",
|
||||
"beds_bed_foot.png",
|
||||
"beds_bed_foot_" .. colour .. ".png",
|
||||
},
|
||||
top = {
|
||||
"beds_bed_top2.png",
|
||||
"beds_bed_top2_" .. colour .. ".png",
|
||||
"default_wood.png",
|
||||
"beds_bed_side2.png",
|
||||
"beds_bed_side2.png^[transformFX",
|
||||
"beds_bed_side2_" .. colour .. ".png",
|
||||
"beds_bed_side2_" .. colour .. ".png^[transformFX",
|
||||
"beds_bed_head.png",
|
||||
"default_wood.png",
|
||||
}
|
||||
@ -44,31 +43,30 @@ beds.register_bed("beds:fancy_bed", {
|
||||
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
|
||||
recipe = {
|
||||
{"", "", "group:stick"},
|
||||
{"wool:red", "wool:red", "wool:white"},
|
||||
{"wool:" .. colour, "wool:" .. colour, "wool:white"},
|
||||
{"group:wood", "group:wood", "group:wood"},
|
||||
},
|
||||
})
|
||||
|
||||
-- Simple shaped bed
|
||||
|
||||
beds.register_bed("beds:bed", {
|
||||
description = "Simple Bed",
|
||||
inventory_image = "beds_bed.png",
|
||||
wield_image = "beds_bed.png",
|
||||
-- simple shaped bed
|
||||
beds.register_bed("beds:bed_" .. colour, {
|
||||
description = "Simple Bed (" .. colour .. ")",
|
||||
inventory_image = "beds_bed_" .. colour .. ".png",
|
||||
wield_image = "beds_bed_" .. colour .. ".png",
|
||||
tiles = {
|
||||
bottom = {
|
||||
"beds_bed_top_bottom.png^[transformR90",
|
||||
"beds_bed_top_bottom_" .. colour .. ".png^[transformR90",
|
||||
"default_wood.png",
|
||||
"beds_bed_side_bottom_r.png",
|
||||
"beds_bed_side_bottom_r.png^[transformfx",
|
||||
"beds_bed_side_bottom_r_" .. colour .. ".png",
|
||||
"beds_bed_side_bottom_r_" .. colour .. ".png^[transformfx",
|
||||
"beds_transparent.png",
|
||||
"beds_bed_side_bottom.png"
|
||||
"beds_bed_side_bottom_" .. colour .. ".png"
|
||||
},
|
||||
top = {
|
||||
"beds_bed_top_top.png^[transformR90",
|
||||
"beds_bed_top_top_" .. colour .. ".png^[transformR90",
|
||||
"default_wood.png",
|
||||
"beds_bed_side_top_r.png",
|
||||
"beds_bed_side_top_r.png^[transformfx",
|
||||
"beds_bed_side_top_r_" .. colour .. ".png",
|
||||
"beds_bed_side_top_r_" .. colour .. ".png^[transformfx",
|
||||
"beds_bed_side_top.png",
|
||||
"beds_transparent.png",
|
||||
}
|
||||
@ -79,12 +77,16 @@ beds.register_bed("beds:bed", {
|
||||
},
|
||||
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
|
||||
recipe = {
|
||||
{"wool:red", "wool:red", "wool:white"},
|
||||
{"wool:" .. colour, "wool:" .. colour, "wool:white"},
|
||||
{"group:wood", "group:wood", "group:wood"}
|
||||
},
|
||||
|
||||
})
|
||||
end
|
||||
|
||||
-- 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")
|
||||
minetest.register_alias("beds:bed", "beds:bed_red")
|
||||
minetest.register_alias("beds:fancy_bed", "beds:fancy_bed_red")
|
||||
minetest.register_alias("beds:bed_bottom", "beds:bed_red_bottom")
|
||||
minetest.register_alias("beds:bed_top", "beds:bed_red_top")
|
||||
minetest.register_alias("beds:fancy_bed_top", "beds:fancy_bed_red_top")
|
||||
minetest.register_alias("beds:fancy_bed_bottom", "beds:fancy_bed_red_bottom")
|
||||
|
1
mods/beds/depends.txt
Normal file → Executable file
@ -1,2 +1,3 @@
|
||||
default
|
||||
wool
|
||||
areas
|
||||
|
66
mods/beds/functions.lua
Normal file → Executable file
@ -6,7 +6,8 @@ if enable_respawn == nil then
|
||||
enable_respawn = true
|
||||
end
|
||||
|
||||
-- Helper functions
|
||||
|
||||
-- helper functions
|
||||
|
||||
local function get_look_yaw(pos)
|
||||
local n = minetest.get_node(pos)
|
||||
@ -104,12 +105,14 @@ local function update_formspecs(finished)
|
||||
local is_majority = (ges/2) < player_in_bed
|
||||
|
||||
if finished then
|
||||
form_n = beds.formspec .. "label[2.7,11; Good morning.]"
|
||||
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]"
|
||||
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]"
|
||||
form_n = form_n ..
|
||||
"button_exit[2,8;4,0.75;force;Force night skip]"
|
||||
end
|
||||
end
|
||||
|
||||
@ -119,7 +122,7 @@ local function update_formspecs(finished)
|
||||
end
|
||||
|
||||
|
||||
-- Public functions
|
||||
-- public functions
|
||||
|
||||
function beds.kick_players()
|
||||
for name,_ in pairs(beds.player) do
|
||||
@ -172,14 +175,34 @@ function beds.on_rightclick(pos, player)
|
||||
end
|
||||
|
||||
|
||||
-- Callbacks
|
||||
|
||||
-- callbacks
|
||||
--[[ --MFF (Crabman) It's useless to read each join player, read only once at load. function moved/called in spawn.lua
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
beds.read_spawns()
|
||||
end)
|
||||
--]]
|
||||
|
||||
-- respawn player at bed if enabled and valid position is found
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
|
||||
local dead_players = {}
|
||||
local have_areas_mod = false
|
||||
if (minetest.get_modpath("areas") ~= nil) and areas.getSpawn then
|
||||
have_areas_mod = true
|
||||
end
|
||||
|
||||
|
||||
local function teleport_player(player, clear)
|
||||
local name = player:get_player_name()
|
||||
if not name or name == "" then return false end
|
||||
if have_areas_mod and dead_players[name] ~= nil then
|
||||
local pos = areas:getSpawn(dead_players[name])
|
||||
if clear then
|
||||
dead_players[name] = nil
|
||||
end
|
||||
if pos then
|
||||
player:setpos(pos)
|
||||
return true
|
||||
end
|
||||
end
|
||||
if not enable_respawn then
|
||||
return false
|
||||
end
|
||||
@ -189,8 +212,31 @@ minetest.register_on_respawnplayer(function(player)
|
||||
player:setpos(pos)
|
||||
return true
|
||||
end
|
||||
--if not areas or bed spawnpoint, tp to the spawn
|
||||
local spawn = minetest.string_to_pos(minetest.setting_get("static_spawnpoint") or "0,0,0")
|
||||
player:setpos(spawn)
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
if not name or name == "" then return end
|
||||
if have_areas_mod then
|
||||
local pos = player:getpos()
|
||||
if pos then
|
||||
dead_players[name] = pos
|
||||
end
|
||||
end
|
||||
minetest.after(0.20, teleport_player, player) -- tp after all others on_dieplayer callback otherwise their pos is wrong
|
||||
end)
|
||||
|
||||
-- respawn player at bed if enabled and valid position is found
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
return teleport_player(player, true)
|
||||
end)
|
||||
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
lay_down(player, nil, nil, false, true)
|
||||
|
3
mods/beds/init.lua
Normal file → Executable file
@ -9,8 +9,7 @@ beds.formspec = "size[8,15;true]" ..
|
||||
|
||||
local modpath = minetest.get_modpath("beds")
|
||||
|
||||
-- Load files
|
||||
|
||||
-- load files
|
||||
dofile(modpath.."/functions.lua")
|
||||
dofile(modpath.."/api.lua")
|
||||
dofile(modpath.."/beds.lua")
|
||||
|
160
mods/beds/models/fancy_bed.obj
Executable file
@ -0,0 +1,160 @@
|
||||
# Blender v2.69 (sub 0) OBJ File: ''
|
||||
# www.blender.org
|
||||
mtllib fancy_bed.mtl
|
||||
o mattress_Mattress_nodebox-6_none.001_fancy_bed.png.001
|
||||
v 0.437500 -0.312500 -0.437501
|
||||
v 0.437500 -0.062500 -0.437501
|
||||
v 0.437500 -0.062500 1.437499
|
||||
v 0.437500 -0.312500 1.437499
|
||||
v -0.437500 -0.312500 -0.437501
|
||||
v -0.437500 -0.312500 1.437499
|
||||
v -0.437500 -0.062500 1.437499
|
||||
v -0.437500 -0.062500 -0.437501
|
||||
v 0.437500 -0.176793 -0.437501
|
||||
v -0.437500 -0.176793 -0.437501
|
||||
vt 0.000171 0.499972
|
||||
vt 0.000161 0.000182
|
||||
vt 0.999791 0.000253
|
||||
vt 0.999873 0.500022
|
||||
vt 0.749576 0.000208
|
||||
vt 0.749876 0.499854
|
||||
vt 0.999848 0.999750
|
||||
vt 0.000152 0.999750
|
||||
vt 0.749276 0.130648
|
||||
vt 0.000112 0.130648
|
||||
g mattress_Mattress_nodebox-6_none.001_fancy_bed.png.001_none.001_fancy_bed.png.001
|
||||
usemtl none.001_fancy_bed.png.001
|
||||
s off
|
||||
f 1/1 2/2 3/3 4/4
|
||||
f 5/2 6/3 7/4 8/1
|
||||
f 4/5 3/2 7/1 6/6
|
||||
f 1/1 4/4 6/7 5/8
|
||||
f 2/1 8/2 7/3 3/4
|
||||
f 8/2 2/5 9/9 10/10
|
||||
o wood_structure_Wood_structure_nodebox-4.001_none.002
|
||||
v 0.374999 -0.375000 1.437499
|
||||
v 0.374999 -0.125000 1.437499
|
||||
v 0.374999 -0.125000 1.499999
|
||||
v 0.374999 -0.375000 1.499999
|
||||
v -0.374999 -0.375000 1.437499
|
||||
v -0.374999 -0.375000 1.499999
|
||||
v -0.374999 -0.125000 1.499999
|
||||
v -0.374999 -0.125000 1.437499
|
||||
v -0.375000 -0.500000 1.437499
|
||||
v -0.375000 0.187500 1.437499
|
||||
v -0.375000 0.187500 1.499999
|
||||
v -0.375000 -0.500000 1.499999
|
||||
v -0.500000 -0.500000 1.437499
|
||||
v -0.500000 -0.500000 1.499999
|
||||
v -0.500000 0.187500 1.499999
|
||||
v -0.500000 0.187500 1.437499
|
||||
v -0.437500 -0.375000 -0.437501
|
||||
v -0.437500 -0.125000 -0.437501
|
||||
v -0.437500 -0.125000 1.437498
|
||||
v -0.437500 -0.375000 1.437498
|
||||
v -0.500000 -0.375000 -0.437501
|
||||
v -0.500000 -0.375000 1.437498
|
||||
v -0.500000 -0.125000 1.437498
|
||||
v -0.500000 -0.125000 -0.437501
|
||||
v 0.375001 -0.000000 1.437499
|
||||
v 0.375001 0.125000 1.437499
|
||||
v 0.375001 0.125000 1.499999
|
||||
v 0.375001 -0.000000 1.499999
|
||||
v -0.375001 -0.000000 1.437499
|
||||
v -0.375001 -0.000000 1.499999
|
||||
v -0.375001 0.125000 1.499999
|
||||
v -0.375001 0.125000 1.437499
|
||||
v 0.500000 -0.500000 1.437499
|
||||
v 0.500000 0.187500 1.437499
|
||||
v 0.500000 0.187500 1.499999
|
||||
v 0.500000 -0.500000 1.499999
|
||||
v 0.375000 -0.500000 1.437499
|
||||
v 0.375000 -0.500000 1.499999
|
||||
v 0.375000 0.187500 1.499999
|
||||
v 0.375000 0.187500 1.437499
|
||||
v 0.500000 -0.375000 -0.437501
|
||||
v 0.500000 -0.125000 -0.437501
|
||||
v 0.500000 -0.125000 1.437499
|
||||
v 0.500000 -0.375000 1.437499
|
||||
v 0.437500 -0.375000 -0.437501
|
||||
v 0.437500 -0.375000 1.437499
|
||||
v 0.437500 -0.125000 1.437499
|
||||
v 0.437500 -0.125000 -0.437501
|
||||
v -0.375000 -0.500000 -0.500000
|
||||
v -0.375000 -0.065000 -0.500000
|
||||
v -0.375000 -0.065000 -0.437500
|
||||
v -0.375000 -0.500000 -0.437500
|
||||
v -0.500000 -0.500000 -0.500000
|
||||
v -0.500000 -0.500000 -0.437500
|
||||
v -0.500000 -0.065000 -0.437500
|
||||
v -0.500000 -0.065000 -0.500000
|
||||
v 0.375006 -0.375000 -0.500000
|
||||
v 0.375006 -0.125000 -0.500000
|
||||
v 0.375006 -0.125000 -0.437500
|
||||
v 0.375006 -0.375000 -0.437500
|
||||
v -0.375006 -0.375000 -0.500000
|
||||
v -0.375006 -0.375000 -0.437500
|
||||
v -0.375006 -0.125000 -0.437500
|
||||
v -0.375006 -0.125000 -0.500000
|
||||
v 0.500000 -0.500000 -0.500000
|
||||
v 0.500000 -0.065000 -0.500000
|
||||
v 0.500000 -0.065000 -0.437500
|
||||
v 0.500000 -0.500000 -0.437500
|
||||
v 0.375000 -0.500000 -0.500000
|
||||
v 0.375000 -0.500000 -0.437500
|
||||
v 0.375000 -0.065000 -0.437500
|
||||
v 0.375000 -0.065000 -0.500000
|
||||
vt 0.377610 0.378205
|
||||
vt 0.622484 0.378175
|
||||
vt 0.622515 0.623120
|
||||
vt 0.377671 0.623151
|
||||
g wood_structure_Wood_structure_nodebox-4.001_none.002_none.002
|
||||
usemtl none.002
|
||||
s off
|
||||
f 59/11 60/12 61/13 62/14
|
||||
f 63/14 64/11 65/12 66/13
|
||||
f 59/11 63/14 66/13 60/12
|
||||
f 62/14 61/13 65/12 64/11
|
||||
f 59/11 62/14 64/13 63/12
|
||||
f 60/12 66/11 65/14 61/13
|
||||
f 67/11 71/12 74/13 68/14
|
||||
f 70/14 69/11 73/12 72/13
|
||||
f 67/11 70/12 72/13 71/14
|
||||
f 68/11 74/12 73/13 69/14
|
||||
f 75/11 76/12 77/13 78/14
|
||||
f 79/14 80/11 81/12 82/13
|
||||
f 75/14 79/11 82/12 76/13
|
||||
f 78/11 77/12 81/13 80/14
|
||||
f 75/11 78/12 80/13 79/14
|
||||
f 76/11 82/12 81/13 77/14
|
||||
g wood_structure_Wood_structure_nodebox-4.001_none.002_none.003
|
||||
usemtl none.003
|
||||
f 15/11 16/12 17/13 18/14
|
||||
f 11/13 15/14 18/11 12/12
|
||||
f 14/14 13/11 17/12 16/13
|
||||
f 11/14 14/11 16/12 15/13
|
||||
f 12/11 18/12 17/13 13/14
|
||||
f 19/11 20/12 21/13 22/14
|
||||
f 23/14 24/11 25/12 26/13
|
||||
f 19/14 23/11 26/12 20/13
|
||||
f 22/11 21/12 25/13 24/14
|
||||
f 19/11 22/12 24/13 23/14
|
||||
f 20/11 26/12 25/13 21/14
|
||||
f 27/14 28/11 29/12 30/13
|
||||
f 31/11 32/12 33/13 34/14
|
||||
f 27/11 30/12 32/13 31/14
|
||||
f 28/14 34/11 33/12 29/13
|
||||
f 35/11 39/12 42/13 36/14
|
||||
f 38/14 37/11 41/12 40/13
|
||||
f 35/14 38/11 40/12 39/13
|
||||
f 36/11 42/12 41/13 37/14
|
||||
f 43/11 44/12 45/13 46/14
|
||||
f 47/14 48/11 49/12 50/13
|
||||
f 43/14 47/11 50/12 44/13
|
||||
f 46/11 45/12 49/13 48/14
|
||||
f 43/11 46/12 48/13 47/14
|
||||
f 44/11 50/12 49/13 45/14
|
||||
f 51/14 52/11 53/12 54/13
|
||||
f 55/13 56/14 57/11 58/12
|
||||
f 51/11 54/12 56/13 55/14
|
||||
f 52/14 58/11 57/12 53/13
|
32
mods/beds/models/simple_bed.obj
Executable file
@ -0,0 +1,32 @@
|
||||
# Blender v2.69 (sub 0) OBJ File: ''
|
||||
# www.blender.org
|
||||
mtllib simple_bed.mtl
|
||||
o Simple_Bed
|
||||
v 0.500000 -0.500000 -0.500000
|
||||
v 0.500000 0.060000 -0.500000
|
||||
v 0.500000 0.060000 1.500000
|
||||
v 0.500000 -0.500000 1.500000
|
||||
v -0.500000 -0.500000 -0.500000
|
||||
v -0.500000 -0.500000 1.500000
|
||||
v -0.500000 0.060000 1.500000
|
||||
v -0.500000 0.060000 -0.500000
|
||||
vt 0.000112 0.780442
|
||||
vt 0.000110 0.999969
|
||||
vt 0.780324 0.999889
|
||||
vt 0.780377 0.780471
|
||||
vt 0.780636 0.390284
|
||||
vt 0.999906 0.780382
|
||||
vt 0.999906 0.390284
|
||||
vt 0.780636 0.000047
|
||||
vt 0.999906 0.000094
|
||||
vt 0.390235 0.780320
|
||||
vt 0.390235 0.000071
|
||||
vt 0.000142 0.000142
|
||||
usemtl none.002
|
||||
s off
|
||||
f 1/1 2/2 3/3 4/4
|
||||
f 5/1 6/4 7/3 8/2
|
||||
f 1/5 5/4 8/6 2/7
|
||||
f 4/8 3/9 7/7 6/5
|
||||
f 1/8 4/4 6/10 5/11
|
||||
f 2/11 8/12 7/1 3/10
|
11
mods/beds/spawns.lua
Normal file → Executable file
@ -41,12 +41,10 @@ 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))
|
||||
for i, v in pairs(beds.spawn) do
|
||||
output:write(v.x.." "..v.y.." "..v.z.." "..i.."\n")
|
||||
end
|
||||
output:write(table.concat(data))
|
||||
io.close(output)
|
||||
end
|
||||
|
||||
@ -54,10 +52,9 @@ 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
|
||||
|
||||
beds.read_spawns()
|
||||
|
BIN
mods/beds/textures/beds_bed_black.png
Executable file
After Width: | Height: | Size: 429 B |
BIN
mods/beds/textures/beds_bed_blue.png
Executable file
After Width: | Height: | Size: 545 B |
BIN
mods/beds/textures/beds_bed_fancy_black.png
Executable file
After Width: | Height: | Size: 432 B |
BIN
mods/beds/textures/beds_bed_fancy_blue.png
Executable file
After Width: | Height: | Size: 545 B |
BIN
mods/beds/textures/beds_bed_fancy_green.png
Executable file
After Width: | Height: | Size: 521 B |
0
mods/beds/textures/beds_bed_fancy.png → mods/beds/textures/beds_bed_fancy_red.png
Normal file → Executable file
Before Width: | Height: | Size: 537 B After Width: | Height: | Size: 537 B |
BIN
mods/beds/textures/beds_bed_fancy_white.png
Executable file
After Width: | Height: | Size: 540 B |
BIN
mods/beds/textures/beds_bed_foot_black.png
Executable file
After Width: | Height: | Size: 366 B |
BIN
mods/beds/textures/beds_bed_foot_blue.png
Executable file
After Width: | Height: | Size: 416 B |
BIN
mods/beds/textures/beds_bed_foot_green.png
Executable file
After Width: | Height: | Size: 400 B |
0
mods/beds/textures/beds_bed_foot.png → mods/beds/textures/beds_bed_foot_red.png
Normal file → Executable file
Before Width: | Height: | Size: 390 B After Width: | Height: | Size: 390 B |
BIN
mods/beds/textures/beds_bed_foot_white.png
Executable file
After Width: | Height: | Size: 408 B |
BIN
mods/beds/textures/beds_bed_green.png
Executable file
After Width: | Height: | Size: 523 B |
BIN
mods/beds/textures/beds_bed_head.png
Normal file → Executable file
Before Width: | Height: | Size: 387 B After Width: | Height: | Size: 347 B |
0
mods/beds/textures/beds_bed.png → mods/beds/textures/beds_bed_red.png
Normal file → Executable file
Before Width: | Height: | Size: 540 B After Width: | Height: | Size: 540 B |
Before Width: | Height: | Size: 296 B |
BIN
mods/beds/textures/beds_bed_side1_black.png
Executable file
After Width: | Height: | Size: 274 B |
BIN
mods/beds/textures/beds_bed_side1_blue.png
Executable file
After Width: | Height: | Size: 308 B |
BIN
mods/beds/textures/beds_bed_side1_green.png
Executable file
After Width: | Height: | Size: 299 B |
BIN
mods/beds/textures/beds_bed_side1_red.png
Executable file
After Width: | Height: | Size: 271 B |
BIN
mods/beds/textures/beds_bed_side1_white.png
Executable file
After Width: | Height: | Size: 295 B |
Before Width: | Height: | Size: 316 B |
BIN
mods/beds/textures/beds_bed_side2_black.png
Executable file
After Width: | Height: | Size: 317 B |
BIN
mods/beds/textures/beds_bed_side2_blue.png
Executable file
After Width: | Height: | Size: 331 B |
BIN
mods/beds/textures/beds_bed_side2_green.png
Executable file
After Width: | Height: | Size: 326 B |
BIN
mods/beds/textures/beds_bed_side2_red.png
Executable file
After Width: | Height: | Size: 283 B |
BIN
mods/beds/textures/beds_bed_side2_white.png
Executable file
After Width: | Height: | Size: 326 B |
Before Width: | Height: | Size: 561 B |
BIN
mods/beds/textures/beds_bed_side_bottom_black.png
Executable file
After Width: | Height: | Size: 358 B |
BIN
mods/beds/textures/beds_bed_side_bottom_blue.png
Executable file
After Width: | Height: | Size: 456 B |
BIN
mods/beds/textures/beds_bed_side_bottom_green.png
Executable file
After Width: | Height: | Size: 427 B |
BIN
mods/beds/textures/beds_bed_side_bottom_r_black.png
Executable file
After Width: | Height: | Size: 343 B |
BIN
mods/beds/textures/beds_bed_side_bottom_r_blue.png
Executable file
After Width: | Height: | Size: 456 B |
BIN
mods/beds/textures/beds_bed_side_bottom_r_green.png
Executable file
After Width: | Height: | Size: 422 B |
0
mods/beds/textures/beds_bed_side_bottom_r.png → mods/beds/textures/beds_bed_side_bottom_r_red.png
Normal file → Executable file
Before Width: | Height: | Size: 537 B After Width: | Height: | Size: 537 B |
BIN
mods/beds/textures/beds_bed_side_bottom_r_white.png
Executable file
After Width: | Height: | Size: 434 B |
BIN
mods/beds/textures/beds_bed_side_bottom_red.png
Executable file
After Width: | Height: | Size: 523 B |
BIN
mods/beds/textures/beds_bed_side_bottom_white.png
Executable file
After Width: | Height: | Size: 439 B |
BIN
mods/beds/textures/beds_bed_side_top.png
Normal file → Executable file
Before Width: | Height: | Size: 611 B After Width: | Height: | Size: 574 B |
Before Width: | Height: | Size: 596 B |
BIN
mods/beds/textures/beds_bed_side_top_r_black.png
Executable file
After Width: | Height: | Size: 429 B |
BIN
mods/beds/textures/beds_bed_side_top_r_blue.png
Executable file
After Width: | Height: | Size: 478 B |
BIN
mods/beds/textures/beds_bed_side_top_r_green.png
Executable file
After Width: | Height: | Size: 463 B |
BIN
mods/beds/textures/beds_bed_side_top_r_red.png
Executable file
After Width: | Height: | Size: 560 B |
BIN
mods/beds/textures/beds_bed_side_top_r_white.png
Executable file
After Width: | Height: | Size: 460 B |
Before Width: | Height: | Size: 583 B |
BIN
mods/beds/textures/beds_bed_top1_black.png
Executable file
After Width: | Height: | Size: 241 B |
BIN
mods/beds/textures/beds_bed_top1_blue.png
Executable file
After Width: | Height: | Size: 494 B |
BIN
mods/beds/textures/beds_bed_top1_green.png
Executable file
After Width: | Height: | Size: 448 B |
BIN
mods/beds/textures/beds_bed_top1_red.png
Executable file
After Width: | Height: | Size: 548 B |
BIN
mods/beds/textures/beds_bed_top1_white.png
Executable file
After Width: | Height: | Size: 478 B |
BIN
mods/beds/textures/beds_bed_top2_black.png
Executable file
After Width: | Height: | Size: 465 B |
BIN
mods/beds/textures/beds_bed_top2_blue.png
Executable file
After Width: | Height: | Size: 609 B |
BIN
mods/beds/textures/beds_bed_top2_green.png
Executable file
After Width: | Height: | Size: 586 B |
0
mods/beds/textures/beds_bed_top2.png → mods/beds/textures/beds_bed_top2_red.png
Normal file → Executable file
Before Width: | Height: | Size: 616 B After Width: | Height: | Size: 616 B |
BIN
mods/beds/textures/beds_bed_top2_white.png
Executable file
After Width: | Height: | Size: 573 B |
BIN
mods/beds/textures/beds_bed_top_bottom_black.png
Executable file
After Width: | Height: | Size: 126 B |
BIN
mods/beds/textures/beds_bed_top_bottom_blue.png
Executable file
After Width: | Height: | Size: 434 B |
BIN
mods/beds/textures/beds_bed_top_bottom_green.png
Executable file
After Width: | Height: | Size: 343 B |
0
mods/beds/textures/beds_bed_top_bottom.png → mods/beds/textures/beds_bed_top_bottom_red.png
Normal file → Executable file
Before Width: | Height: | Size: 495 B After Width: | Height: | Size: 495 B |
BIN
mods/beds/textures/beds_bed_top_bottom_white.png
Executable file
After Width: | Height: | Size: 339 B |
BIN
mods/beds/textures/beds_bed_top_top_black.png
Executable file
After Width: | Height: | Size: 376 B |
BIN
mods/beds/textures/beds_bed_top_top_blue.png
Executable file
After Width: | Height: | Size: 568 B |
BIN
mods/beds/textures/beds_bed_top_top_green.png
Executable file
After Width: | Height: | Size: 525 B |
0
mods/beds/textures/beds_bed_top_top.png → mods/beds/textures/beds_bed_top_top_red.png
Normal file → Executable file
Before Width: | Height: | Size: 556 B After Width: | Height: | Size: 556 B |
BIN
mods/beds/textures/beds_bed_top_top_white.png
Executable file
After Width: | Height: | Size: 480 B |
BIN
mods/beds/textures/beds_bed_white.png
Executable file
After Width: | Height: | Size: 525 B |
BIN
mods/beds/textures/beds_transparent.png
Normal file → Executable file
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 96 B |
BIN
mods/beds/textures/fancy_bed_black.png
Executable file
After Width: | Height: | Size: 705 B |
BIN
mods/beds/textures/fancy_bed_blue.png
Executable file
After Width: | Height: | Size: 1.0 KiB |
BIN
mods/beds/textures/fancy_bed_green.png
Executable file
After Width: | Height: | Size: 969 B |
BIN
mods/beds/textures/fancy_bed_red.png
Executable file
After Width: | Height: | Size: 552 B |
BIN
mods/beds/textures/fancy_bed_white.png
Executable file
After Width: | Height: | Size: 1.0 KiB |
BIN
mods/beds/textures/simple_bed_black.png
Executable file
After Width: | Height: | Size: 1.7 KiB |
BIN
mods/beds/textures/simple_bed_blue.png
Executable file
After Width: | Height: | Size: 2.3 KiB |
BIN
mods/beds/textures/simple_bed_green.png
Executable file
After Width: | Height: | Size: 2.1 KiB |
BIN
mods/beds/textures/simple_bed_red.png
Executable file
After Width: | Height: | Size: 1.1 KiB |
BIN
mods/beds/textures/simple_bed_white.png
Executable file
After Width: | Height: | Size: 2.1 KiB |
0
mods/boats/README.txt
Normal file → Executable file
0
mods/boats/depends.txt
Normal file → Executable file
@ -2,13 +2,14 @@
|
||||
-- Helper functions
|
||||
--
|
||||
|
||||
local function is_water(pos)
|
||||
boats = {}
|
||||
|
||||
function boats.is_water(pos)
|
||||
local nn = minetest.get_node(pos).name
|
||||
return minetest.get_item_group(nn, "water") ~= 0
|
||||
end
|
||||
|
||||
|
||||
local function get_sign(i)
|
||||
function boats.get_sign(i)
|
||||
if i == 0 then
|
||||
return 0
|
||||
else
|
||||
@ -16,37 +17,17 @@ local function get_sign(i)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function get_velocity(v, yaw, y)
|
||||
function boats.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)
|
||||
function boats.get_v(v)
|
||||
return math.sqrt(v.x ^ 2 + v.z ^ 2)
|
||||
end
|
||||
|
||||
--
|
||||
-- Boat entity
|
||||
--
|
||||
|
||||
local boat = {
|
||||
physical = true,
|
||||
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)
|
||||
function boats.on_rightclick(self, clicker)
|
||||
if not clicker or not clicker:is_player() then
|
||||
return
|
||||
end
|
||||
@ -68,21 +49,20 @@ function boat.on_rightclick(self, clicker)
|
||||
if luaentity.driver then
|
||||
luaentity.driver = nil
|
||||
end
|
||||
end
|
||||
clicker:set_detach()
|
||||
end
|
||||
self.driver = clicker
|
||||
clicker:set_attach(self.object, "",
|
||||
{x = 0, y = 11, z = -3}, {x = 0, y = 0, z = 0})
|
||||
clicker:set_attach(self.object, "", {x = 0, y = 11, z = -3}, {x = 0, y = 0, z = 0})
|
||||
default.player_attached[name] = true
|
||||
minetest.after(0.2, function()
|
||||
default.player_set_animation(clicker, "sit" , 30)
|
||||
end)
|
||||
self.object:setyaw(clicker:get_look_yaw() - math.pi / 2)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function boat.on_activate(self, staticdata, dtime_s)
|
||||
function boats.on_activate(self, staticdata, dtime_s)
|
||||
self.object:set_armor_groups({immortal = 1})
|
||||
if staticdata then
|
||||
self.v = tonumber(staticdata)
|
||||
@ -91,12 +71,12 @@ function boat.on_activate(self, staticdata, dtime_s)
|
||||
end
|
||||
|
||||
|
||||
function boat.get_staticdata(self)
|
||||
function boats.get_staticdata(self)
|
||||
return tostring(self.v)
|
||||
end
|
||||
|
||||
|
||||
function boat.on_punch(self, puncher)
|
||||
function boats.on_punch(self, puncher)
|
||||
if not puncher or not puncher:is_player() or self.removed then
|
||||
return
|
||||
end
|
||||
@ -113,37 +93,36 @@ function boat.on_punch(self, puncher)
|
||||
end)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
local inv = puncher:get_inventory()
|
||||
if inv:room_for_item("main", "boats:boat") then
|
||||
inv:add_item("main", "boats:boat")
|
||||
if inv:room_for_item("main", "boats:" .. self.parameters.name) then
|
||||
inv:add_item("main", "boats:" .. self.parameters.name)
|
||||
else
|
||||
minetest.add_item(self.object:getpos(), "boats:boat")
|
||||
minetest.add_item(self.object:getpos(), "boats:" .. self.parameters.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function boat.on_step(self, dtime)
|
||||
self.v = get_v(self.object:getvelocity()) * get_sign(self.v)
|
||||
function boats.on_step(self, dtime)
|
||||
self.v = boats.get_v(self.object:getvelocity()) * boats.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
|
||||
self.v = self.v + self.parameters.controls.up or 0.1
|
||||
elseif ctrl.down then
|
||||
self.v = self.v - 0.1
|
||||
self.v = self.v - self.parameters.controls.down or 0.08
|
||||
end
|
||||
if ctrl.left then
|
||||
if self.v < 0 then
|
||||
self.object:setyaw(yaw - (1 + dtime) * 0.03)
|
||||
self.object:setyaw(yaw - (1 + dtime) * (0.03 * (self.parameters.controls.rotate or 1)))
|
||||
else
|
||||
self.object:setyaw(yaw + (1 + dtime) * 0.03)
|
||||
self.object:setyaw(yaw + (1 + dtime) * (0.03 * (self.parameters.controls.rotate or 1)))
|
||||
end
|
||||
elseif ctrl.right then
|
||||
if self.v < 0 then
|
||||
self.object:setyaw(yaw + (1 + dtime) * 0.03)
|
||||
self.object:setyaw(yaw + (1 + dtime) * (0.03 * (self.parameters.controls.rotate or 1)))
|
||||
else
|
||||
self.object:setyaw(yaw - (1 + dtime) * 0.03)
|
||||
self.object:setyaw(yaw - (1 + dtime) * (0.03 * (self.parameters.controls.rotate or 1)))
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -152,44 +131,44 @@ function boat.on_step(self, dtime)
|
||||
self.object:setpos(self.object:getpos())
|
||||
return
|
||||
end
|
||||
local s = get_sign(self.v)
|
||||
local s = boats.get_sign(self.v)
|
||||
self.v = self.v - 0.02 * s
|
||||
if s ~= get_sign(self.v) then
|
||||
if s ~= boats.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)
|
||||
if math.abs(self.v) > 4.5 then
|
||||
self.v = 4.5 * boats.get_sign(self.v)
|
||||
end
|
||||
|
||||
local p = self.object:getpos()
|
||||
p.y = p.y - 0.5
|
||||
local new_velo = {x = 0, y = 0, z = 0}
|
||||
local new_acce = {x = 0, y = 0, z = 0}
|
||||
if not is_water(p) then
|
||||
if not boats.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}
|
||||
new_acce = {x = 0, y = -9.8, z = 0} -- freefall in air -9.81
|
||||
end
|
||||
new_velo = get_velocity(self.v, self.object:getyaw(),
|
||||
new_velo = boats.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
|
||||
if boats.is_water(p) then
|
||||
local y = self.object:getvelocity().y
|
||||
if y >= 5 then
|
||||
y = 5
|
||||
if y >= 4.5 then
|
||||
y = 4.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)
|
||||
new_velo = boats.get_velocity(self.v, self.object:getyaw(), y)
|
||||
self.object:setpos(self.object:getpos())
|
||||
else
|
||||
new_acce = {x = 0, y = 0, z = 0}
|
||||
@ -197,9 +176,9 @@ function boat.on_step(self, dtime)
|
||||
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)
|
||||
new_velo = boats.get_velocity(self.v, self.object:getyaw(), 0)
|
||||
else
|
||||
new_velo = get_velocity(self.v, self.object:getyaw(),
|
||||
new_velo = boats.get_velocity(self.v, self.object:getyaw(),
|
||||
self.object:getvelocity().y)
|
||||
self.object:setpos(self.object:getpos())
|
||||
end
|
||||
@ -209,14 +188,31 @@ function boat.on_step(self, dtime)
|
||||
self.object:setacceleration(new_acce)
|
||||
end
|
||||
|
||||
boats.register_boat = function(parameters)
|
||||
minetest.register_entity("boats:" .. parameters.name, {
|
||||
physical = true,
|
||||
collisionbox = {-0.5, -0.35, -0.5, 0.5, 0.3, 0.5},
|
||||
visual = "mesh",
|
||||
mesh = "boat.obj",
|
||||
textures = {parameters.texture or "default_wood.png"},
|
||||
|
||||
minetest.register_entity("boats:boat", boat)
|
||||
parameters = parameters,
|
||||
driver = nil,
|
||||
v = 0,
|
||||
last_v = 0,
|
||||
removed = false,
|
||||
|
||||
on_rightclick = boats.on_rightclick,
|
||||
on_activate = boats.on_activate,
|
||||
get_staticdata = boats.get_staticdata,
|
||||
on_punch = boats.on_punch,
|
||||
on_step = boats.on_step
|
||||
})
|
||||
|
||||
minetest.register_craftitem("boats:boat", {
|
||||
description = "Boat",
|
||||
inventory_image = "boats_inventory.png",
|
||||
wield_image = "boats_wield.png",
|
||||
minetest.register_craftitem("boats:" .. parameters.name, {
|
||||
description = parameters.description or "Boat",
|
||||
inventory_image = "boats_" .. parameters.name .. "_inventory.png",
|
||||
wield_image = "boats_" .. parameters.name .. "_wield.png",
|
||||
wield_scale = {x = 2, y = 2, z = 1},
|
||||
liquids_pointable = true,
|
||||
|
||||
@ -224,17 +220,109 @@ minetest.register_craftitem("boats:boat", {
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
if not is_water(pointed_thing.under) then
|
||||
if not boats.is_water(pointed_thing.under) then
|
||||
return
|
||||
end
|
||||
pointed_thing.under.y = pointed_thing.under.y + 0.5
|
||||
minetest.add_entity(pointed_thing.under, "boats:boat")
|
||||
minetest.add_entity(pointed_thing.under, "boats:"..parameters.name)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
boats.register_boat({
|
||||
name = "boat",
|
||||
texture = "default_wood.png",
|
||||
controls = {
|
||||
up = 0.1,
|
||||
down = 0.08,
|
||||
rotate = 0.75
|
||||
},
|
||||
description = "Boat"
|
||||
})
|
||||
|
||||
boats.register_boat({
|
||||
name = "race",
|
||||
texture = "default_gravel.png",
|
||||
controls = {
|
||||
up = 0.2,
|
||||
down = 0.18,
|
||||
rotate = 1
|
||||
},
|
||||
description = "Race boat"
|
||||
})
|
||||
|
||||
boats.register_boat({
|
||||
name = "expert_race",
|
||||
texture = "default_desert_stone.png",
|
||||
controls = {
|
||||
up = 0.25,
|
||||
down = 0.25,
|
||||
rotate = 4
|
||||
},
|
||||
description = "Expert race boat"
|
||||
})
|
||||
|
||||
|
||||
boats.register_boat({
|
||||
name = "water",
|
||||
texture = "default_water.png",
|
||||
controls = {
|
||||
up = 0.3,
|
||||
down = 0.24,
|
||||
rotate = 4
|
||||
},
|
||||
description = "Water boat"
|
||||
})
|
||||
|
||||
boats.register_boat({
|
||||
name = "moon",
|
||||
texture = "boats_moon.png",
|
||||
controls = {
|
||||
up = 0.5,
|
||||
down = 0.1,
|
||||
rotate = 8
|
||||
},
|
||||
description = "Moon boat"
|
||||
})
|
||||
|
||||
-- Craft registrations
|
||||
|
||||
minetest.register_craft({
|
||||
output = "boats:moon",
|
||||
recipe = {
|
||||
{"default:obsidian", "", "default:obsidian"},
|
||||
{"default:dirt", "default:leaves", "default:dirt"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "boats:expert_race",
|
||||
recipe = {
|
||||
{"default:desert_stone", "", "default:desert_stone"},
|
||||
{"default:desert_stone", "default:mese", "default:desert_stone"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "boats:race",
|
||||
recipe = {
|
||||
{"default:gravel", "", "default:gravel"},
|
||||
{"default:gravel", "default:steelblock", "default:gravel"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "boats:water",
|
||||
recipe = {
|
||||
{"default:glass", "", "default:glass"},
|
||||
{"default:glass", "bucket:bucket_water", "default:glass"},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
|