1
0
mirror of https://github.com/minetest/minetest_game.git synced 2025-06-29 13:20:25 +02:00

1 Commits

Author SHA1 Message Date
226ccd07b7 Version MFF. 2018-09-09 11:39:53 +02:00
890 changed files with 14480 additions and 3780 deletions

29
.gitignore vendored Normal file → Executable file
View File

@ -1,9 +1,22 @@
## Generic ignorable patterns and files
*~
.*.swp
*bak*
tags
*.vim
## Files related to minetest development cycle ## 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
View File

2
game.conf Normal file → Executable file
View File

@ -1 +1 @@
name = Minetest Game name = MinetestForFun Game

73
game_api.txt Normal file → Executable file
View File

@ -12,22 +12,28 @@ Please note:
* [XYZ] refers to a section the Minetest API * [XYZ] refers to a section the Minetest API
* [#ABC] refers to a section in this document * [#ABC] refers to a section in this document
* [pos] refers to a position table `{x = -5, y = 0, z = 200}`
Bucket API Bucket API
---------- ----------
The bucket API allows registering new types of buckets for non-default liquids. The bucket API allows registering new types of buckets for non-default liquids.
bucket.register_liquid( bucket.register_liquid(
"default:lava_source", -- name of the source node "default:lava_source", -- name of the source node
"default:lava_flowing", -- name of the flowing 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: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) "bucket_lava.png", -- texture of the new bucket item (ignored if itemname == nil)
"Lava Bucket", -- text description of the bucket item "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 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 Doors API
--------- ---------
@ -177,6 +188,9 @@ The farming API allows you to easily register plants and hoes.
`farming.register_plant(name, Plant definition)` `farming.register_plant(name, Plant definition)`
* Register a new growing plant, see [#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 ### Hoe Definition
@ -213,6 +227,14 @@ New node def property:
* Called when fire attempts to remove a burning node. * Called when fire attempts to remove a burning node.
* `pos` Position of the 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 Give Initial Stuff API
---------------------- ----------------------
@ -244,6 +266,18 @@ Give Initial Stuff API
^ str is a comma separated list of initial stuff ^ str is a comma separated list of initial stuff
^ Adds items to the list of items to be given ^ 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 TNT API
---------- ----------
@ -272,9 +306,9 @@ TNT API
* `position` The center of explosion. * `position` The center of explosion.
* `definition` The TNT definion as passed to `tnt.register` * `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 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 * `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 * 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) 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 * 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 Stairs API
---------- ----------
@ -343,7 +401,7 @@ delivered with Minetest Game, to keep them compatible with other mods.
* Registers a stair. * Registers a stair.
* `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname" * `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] * `groups`: see [Known damage and digging time defining groups]
* `images`: see [Tile definition] * `images`: see [Tile definition]
* `description`: used for the description field in the stair's 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 ### 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] groups = {group = rating}, -- Uses the known node groups, see [Known damage and digging time defining groups]
sounds = SoundSpec, -- See [#Default sounds] sounds = SoundSpec, -- See [#Default sounds]
recipe = {{"","","","","","","","",""}}, -- Recipe field only 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_wood_defaults()`
* `default.node_sound_leaves_defaults()` * `default.node_sound_leaves_defaults()`
* `default.node_sound_glass_defaults()` * `default.node_sound_glass_defaults()`
* `default.node_sound_metal_defaults()`
Default constants Default constants
----------------- -----------------

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 904 B

0
menu/icon.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

3
minetest.conf Normal file → Executable file
View 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
View File

@ -5,6 +5,12 @@
# Whether creative mode (fast digging of all blocks, unlimited resources) should be enabled # Whether creative mode (fast digging of all blocks, unlimited resources) should be enabled
#creative_mode = false #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 # The time in seconds after which the bones of a dead player can be looted by everyone
# 0 to disable # 0 to disable
#share_bones_time = 1200 #share_bones_time = 1200
@ -14,9 +20,9 @@
# 0 to disable. By default it is "share_bones_time" divide by four. # 0 to disable. By default it is "share_bones_time" divide by four.
#share_bones_time_early = 300 #share_bones_time_early = 300
# Whether standard fire should be disabled ('basic flame' nodes will disappear) # Whether fire should be enabled. If disabled, 'basic flame' nodes will disappear.
# 'permanent flame' nodes will remain with either setting # 'permanent flame' nodes will remain with either setting.
#disable_fire = false #enable_fire = true
# Whether the stuff in initial_stuff should be given to new players # Whether the stuff in initial_stuff should be given to new players
#give_initial_stuff = false #give_initial_stuff = false

9
mods/_misc_init/init.lua Executable file
View 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")

View 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
View File

106
mods/beds/api.lua Normal file → Executable file
View 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) function beds.register_bed(name, def)
minetest.register_node(name .. "_bottom", { minetest.register_node(name .. "_bottom", {
description = def.description, description = def.description,
@ -43,58 +19,42 @@ function beds.register_bed(name, def)
type = "fixed", type = "fixed",
fixed = def.selectionbox, fixed = def.selectionbox,
}, },
after_place_node = function(pos, placer, itemstack)
on_place = function(itemstack, placer, pointed_thing) local n = minetest.get_node_or_nil(pos)
local under = pointed_thing.under if not n or not n.param2 then
local pos minetest.remove_node(pos)
if minetest.registered_items[minetest.get_node(under).name].buildable_to then return true
pos = under
else
pos = pointed_thing.above
end end
local dir = minetest.facedir_to_dir(n.param2)
if minetest.is_protected(pos, placer:get_player_name()) and local p = vector.add(pos, dir)
not minetest.check_player_privs(placer, "protection_bypass") then local n2 = minetest.get_node_or_nil(p)
minetest.record_protection_violation(pos, placer:get_player_name()) local def = n2 and minetest.registered_items[n2.name]
return itemstack
end
local def = minetest.registered_nodes[minetest.get_node(pos).name]
if not def or not def.buildable_to then if not def or not def.buildable_to then
return itemstack minetest.remove_node(pos)
return true
end end
minetest.set_node(p, {name = n.name:gsub("%_bottom", "_top"), param2 = n.param2})
local dir = minetest.dir_to_facedir(placer:get_look_dir()) return false
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
end, end,
on_destruct = function(pos) 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, end,
on_rightclick = function(pos, node, clicker) on_rightclick = function(pos, node, clicker)
beds.on_rightclick(pos, clicker) beds.on_rightclick(pos, clicker)
end, end,
on_rotate = function(pos, node, user, mode, new_param2) on_rotate = function(pos, node, user, mode, new_param2)
local dir = minetest.facedir_to_dir(node.param2) local dir = minetest.facedir_to_dir(node.param2)
local p = vector.add(pos, dir) local p = vector.add(pos, dir)
@ -121,10 +81,9 @@ function beds.register_bed(name, def)
return false return false
end end
node.param2 = new_param2 node.param2 = new_param2
-- do not remove_node here - it will trigger destroy_bed() minetest.swap_node(pos, node)
minetest.set_node(p, {name = "air"}) minetest.remove_node(p)
minetest.set_node(pos, node) minetest.set_node(newp, {name = node.name:gsub("%_bottom", "_top"), param2 = new_param2})
minetest.set_node(newp, {name = name .. "_top", param2 = new_param2})
return true return true
end, end,
}) })
@ -138,18 +97,15 @@ function beds.register_bed(name, def)
pointable = false, pointable = false,
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 2}, groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 2},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
drop = name .. "_bottom",
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = def.nodebox.top, fixed = def.nodebox.top,
}, },
on_destruct = function(pos)
destruct_bed(pos, 2)
end,
}) })
minetest.register_alias(name, name .. "_bottom") minetest.register_alias(name, name .. "_bottom")
-- register recipe
minetest.register_craft({ minetest.register_craft({
output = name, output = name,
recipe = def.recipe recipe = def.recipe

66
mods/beds/beds.lua Normal file → Executable file
View File

@ -1,23 +1,22 @@
-- Fancy shaped bed for _, colour in pairs({"red", "white", "black", "blue", "green"}) do-- fancy shaped bed
beds.register_bed("beds:fancy_bed_" .. colour, {
beds.register_bed("beds:fancy_bed", { description = "Fancy Bed (" .. colour .. ")",
description = "Fancy Bed", inventory_image = "beds_bed_fancy_" .. colour .. ".png",
inventory_image = "beds_bed_fancy.png", wield_image = "beds_bed_fancy_" .. colour .. ".png",
wield_image = "beds_bed_fancy.png",
tiles = { tiles = {
bottom = { bottom = {
"beds_bed_top1.png", "beds_bed_top1_" .. colour .. ".png",
"default_wood.png", "default_wood.png",
"beds_bed_side1.png", "beds_bed_side1_" .. colour .. ".png",
"beds_bed_side1.png^[transformFX", "beds_bed_side1_" .. colour .. ".png^[transformFX",
"default_wood.png", "default_wood.png",
"beds_bed_foot.png", "beds_bed_foot_" .. colour .. ".png",
}, },
top = { top = {
"beds_bed_top2.png", "beds_bed_top2_" .. colour .. ".png",
"default_wood.png", "default_wood.png",
"beds_bed_side2.png", "beds_bed_side2_" .. colour .. ".png",
"beds_bed_side2.png^[transformFX", "beds_bed_side2_" .. colour .. ".png^[transformFX",
"beds_bed_head.png", "beds_bed_head.png",
"default_wood.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}, selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
recipe = { recipe = {
{"", "", "group:stick"}, {"", "", "group:stick"},
{"wool:red", "wool:red", "wool:white"}, {"wool:" .. colour, "wool:" .. colour, "wool:white"},
{"group:wood", "group:wood", "group:wood"}, {"group:wood", "group:wood", "group:wood"},
}, },
}) })
-- Simple shaped bed -- simple shaped bed
beds.register_bed("beds:bed_" .. colour, {
beds.register_bed("beds:bed", { description = "Simple Bed (" .. colour .. ")",
description = "Simple Bed", inventory_image = "beds_bed_" .. colour .. ".png",
inventory_image = "beds_bed.png", wield_image = "beds_bed_" .. colour .. ".png",
wield_image = "beds_bed.png",
tiles = { tiles = {
bottom = { bottom = {
"beds_bed_top_bottom.png^[transformR90", "beds_bed_top_bottom_" .. colour .. ".png^[transformR90",
"default_wood.png", "default_wood.png",
"beds_bed_side_bottom_r.png", "beds_bed_side_bottom_r_" .. colour .. ".png",
"beds_bed_side_bottom_r.png^[transformfx", "beds_bed_side_bottom_r_" .. colour .. ".png^[transformfx",
"beds_transparent.png", "beds_transparent.png",
"beds_bed_side_bottom.png" "beds_bed_side_bottom_" .. colour .. ".png"
}, },
top = { top = {
"beds_bed_top_top.png^[transformR90", "beds_bed_top_top_" .. colour .. ".png^[transformR90",
"default_wood.png", "default_wood.png",
"beds_bed_side_top_r.png", "beds_bed_side_top_r_" .. colour .. ".png",
"beds_bed_side_top_r.png^[transformfx", "beds_bed_side_top_r_" .. colour .. ".png^[transformfx",
"beds_bed_side_top.png", "beds_bed_side_top.png",
"beds_transparent.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}, selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
recipe = { recipe = {
{"wool:red", "wool:red", "wool:white"}, {"wool:" .. colour, "wool:" .. colour, "wool:white"},
{"group:wood", "group:wood", "group:wood"} {"group:wood", "group:wood", "group:wood"}
}, },
}) })
end
-- Aliases for PilzAdam's beds mod minetest.register_alias("beds:bed", "beds:bed_red")
minetest.register_alias("beds:fancy_bed", "beds:fancy_bed_red")
minetest.register_alias("beds:bed_bottom_red", "beds:bed_bottom") minetest.register_alias("beds:bed_bottom", "beds:bed_red_bottom")
minetest.register_alias("beds:bed_top_red", "beds:bed_top") 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
View File

@ -1,2 +1,3 @@
default default
wool wool
areas

66
mods/beds/functions.lua Normal file → Executable file
View File

@ -6,7 +6,8 @@ if enable_respawn == nil then
enable_respawn = true enable_respawn = true
end end
-- Helper functions
-- helper functions
local function get_look_yaw(pos) local function get_look_yaw(pos)
local n = minetest.get_node(pos) local n = minetest.get_node(pos)
@ -104,12 +105,14 @@ local function update_formspecs(finished)
local is_majority = (ges/2) < player_in_bed local is_majority = (ges/2) < player_in_bed
if finished then if finished then
form_n = beds.formspec .. "label[2.7,11; Good morning.]" form_n = beds.formspec ..
"label[2.7,11; Good morning.]"
else else
form_n = beds.formspec .. "label[2.2,11;" .. tostring(player_in_bed) .. form_n = beds.formspec ..
" of " .. tostring(ges) .. " players are in bed]" "label[2.2,11;"..tostring(player_in_bed).." of "..tostring(ges).." players are in bed]"
if is_majority and is_night_skip_enabled() then 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
end end
@ -119,7 +122,7 @@ local function update_formspecs(finished)
end end
-- Public functions -- public functions
function beds.kick_players() function beds.kick_players()
for name,_ in pairs(beds.player) do for name,_ in pairs(beds.player) do
@ -172,14 +175,34 @@ function beds.on_rightclick(pos, player)
end 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) minetest.register_on_joinplayer(function(player)
beds.read_spawns() beds.read_spawns()
end) 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 if not enable_respawn then
return false return false
end end
@ -189,8 +212,31 @@ minetest.register_on_respawnplayer(function(player)
player:setpos(pos) player:setpos(pos)
return true return true
end 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) 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) minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name() local name = player:get_player_name()
lay_down(player, nil, nil, false, true) lay_down(player, nil, nil, false, true)

3
mods/beds/init.lua Normal file → Executable file
View File

@ -9,8 +9,7 @@ beds.formspec = "size[8,15;true]" ..
local modpath = minetest.get_modpath("beds") local modpath = minetest.get_modpath("beds")
-- Load files -- load files
dofile(modpath.."/functions.lua") dofile(modpath.."/functions.lua")
dofile(modpath.."/api.lua") dofile(modpath.."/api.lua")
dofile(modpath.."/beds.lua") dofile(modpath.."/beds.lua")

160
mods/beds/models/fancy_bed.obj Executable file
View 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
View 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
View File

@ -41,12 +41,10 @@ function beds.save_spawns()
if not beds.spawn then if not beds.spawn then
return return
end end
local data = {}
local output = io.open(org_file, "w") local output = io.open(org_file, "w")
for k, v in pairs(beds.spawn) do for i, v in pairs(beds.spawn) do
table.insert(data, string.format("%.1f %.1f %.1f %s\n", v.x, v.y, v.z, k)) output:write(v.x.." "..v.y.." "..v.z.." "..i.."\n")
end end
output:write(table.concat(data))
io.close(output) io.close(output)
end end
@ -54,10 +52,9 @@ function beds.set_spawns()
for name,_ in pairs(beds.player) do for name,_ in pairs(beds.player) do
local player = minetest.get_player_by_name(name) local player = minetest.get_player_by_name(name)
local p = player:getpos() 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 beds.spawn[name] = p
end end
end
beds.save_spawns() beds.save_spawns()
end end
beds.read_spawns()

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

View File

Before

Width:  |  Height:  |  Size: 537 B

After

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

View File

Before

Width:  |  Height:  |  Size: 390 B

After

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

BIN
mods/beds/textures/beds_bed_head.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 387 B

After

Width:  |  Height:  |  Size: 347 B

View File

Before

Width:  |  Height:  |  Size: 540 B

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 317 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 561 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 B

View File

Before

Width:  |  Height:  |  Size: 537 B

After

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

BIN
mods/beds/textures/beds_bed_side_top.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 611 B

After

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 583 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 548 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 609 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

View File

Before

Width:  |  Height:  |  Size: 616 B

After

Width:  |  Height:  |  Size: 616 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

View File

Before

Width:  |  Height:  |  Size: 495 B

After

Width:  |  Height:  |  Size: 495 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B

View File

Before

Width:  |  Height:  |  Size: 556 B

After

Width:  |  Height:  |  Size: 556 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B

BIN
mods/beds/textures/beds_transparent.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 B

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 705 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 969 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

0
mods/boats/README.txt Normal file → Executable file
View File

0
mods/boats/depends.txt Normal file → Executable file
View File

View File

@ -2,13 +2,14 @@
-- Helper functions -- Helper functions
-- --
local function is_water(pos) boats = {}
function boats.is_water(pos)
local nn = minetest.get_node(pos).name local nn = minetest.get_node(pos).name
return minetest.get_item_group(nn, "water") ~= 0 return minetest.get_item_group(nn, "water") ~= 0
end end
function boats.get_sign(i)
local function get_sign(i)
if i == 0 then if i == 0 then
return 0 return 0
else else
@ -16,37 +17,17 @@ local function get_sign(i)
end end
end end
function boats.get_velocity(v, yaw, y)
local function get_velocity(v, yaw, y)
local x = -math.sin(yaw) * v local x = -math.sin(yaw) * v
local z = math.cos(yaw) * v local z = math.cos(yaw) * v
return {x = x, y = y, z = z} return {x = x, y = y, z = z}
end end
function boats.get_v(v)
local function get_v(v)
return math.sqrt(v.x ^ 2 + v.z ^ 2) return math.sqrt(v.x ^ 2 + v.z ^ 2)
end end
-- function boats.on_rightclick(self, clicker)
-- 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)
if not clicker or not clicker:is_player() then if not clicker or not clicker:is_player() then
return return
end end
@ -68,21 +49,20 @@ function boat.on_rightclick(self, clicker)
if luaentity.driver then if luaentity.driver then
luaentity.driver = nil luaentity.driver = nil
end end
end
clicker:set_detach() clicker:set_detach()
end end
self.driver = clicker self.driver = clicker
clicker:set_attach(self.object, "", clicker:set_attach(self.object, "", {x = 0, y = 11, z = -3}, {x = 0, y = 0, z = 0})
{x = 0, y = 11, z = -3}, {x = 0, y = 0, z = 0})
default.player_attached[name] = true default.player_attached[name] = true
minetest.after(0.2, function() minetest.after(0.2, function()
default.player_set_animation(clicker, "sit" , 30) default.player_set_animation(clicker, "sit" , 30)
end) end)
self.object:setyaw(clicker:get_look_yaw() - math.pi / 2) self.object:setyaw(clicker:get_look_yaw() - math.pi / 2)
end 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}) self.object:set_armor_groups({immortal = 1})
if staticdata then if staticdata then
self.v = tonumber(staticdata) self.v = tonumber(staticdata)
@ -91,12 +71,12 @@ function boat.on_activate(self, staticdata, dtime_s)
end end
function boat.get_staticdata(self) function boats.get_staticdata(self)
return tostring(self.v) return tostring(self.v)
end 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 if not puncher or not puncher:is_player() or self.removed then
return return
end end
@ -113,37 +93,36 @@ function boat.on_punch(self, puncher)
end) end)
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
local inv = puncher:get_inventory() local inv = puncher:get_inventory()
if inv:room_for_item("main", "boats:boat") then if inv:room_for_item("main", "boats:" .. self.parameters.name) then
inv:add_item("main", "boats:boat") inv:add_item("main", "boats:" .. self.parameters.name)
else else
minetest.add_item(self.object:getpos(), "boats:boat") minetest.add_item(self.object:getpos(), "boats:" .. self.parameters.name)
end end
end end
end end
end end
function boats.on_step(self, dtime)
function boat.on_step(self, dtime) self.v = boats.get_v(self.object:getvelocity()) * boats.get_sign(self.v)
self.v = get_v(self.object:getvelocity()) * get_sign(self.v)
if self.driver then if self.driver then
local ctrl = self.driver:get_player_control() local ctrl = self.driver:get_player_control()
local yaw = self.object:getyaw() local yaw = self.object:getyaw()
if ctrl.up then 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 elseif ctrl.down then
self.v = self.v - 0.1 self.v = self.v - self.parameters.controls.down or 0.08
end end
if ctrl.left then if ctrl.left then
if self.v < 0 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 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
elseif ctrl.right then elseif ctrl.right then
if self.v < 0 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 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 end
end end
@ -152,44 +131,44 @@ function boat.on_step(self, dtime)
self.object:setpos(self.object:getpos()) self.object:setpos(self.object:getpos())
return return
end end
local s = get_sign(self.v) local s = boats.get_sign(self.v)
self.v = self.v - 0.02 * s 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.object:setvelocity({x = 0, y = 0, z = 0})
self.v = 0 self.v = 0
return return
end end
if math.abs(self.v) > 5 then if math.abs(self.v) > 4.5 then
self.v = 5 * get_sign(self.v) self.v = 4.5 * boats.get_sign(self.v)
end end
local p = self.object:getpos() local p = self.object:getpos()
p.y = p.y - 0.5 p.y = p.y - 0.5
local new_velo = {x = 0, y = 0, z = 0} local new_velo = {x = 0, y = 0, z = 0}
local new_acce = {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] local nodedef = minetest.registered_nodes[minetest.get_node(p).name]
if (not nodedef) or nodedef.walkable then if (not nodedef) or nodedef.walkable then
self.v = 0 self.v = 0
new_acce = {x = 0, y = 1, z = 0} new_acce = {x = 0, y = 1, z = 0}
else 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 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:getvelocity().y)
self.object:setpos(self.object:getpos()) self.object:setpos(self.object:getpos())
else else
p.y = p.y + 1 p.y = p.y + 1
if is_water(p) then if boats.is_water(p) then
local y = self.object:getvelocity().y local y = self.object:getvelocity().y
if y >= 5 then if y >= 4.5 then
y = 5 y = 4.5
elseif y < 0 then elseif y < 0 then
new_acce = {x = 0, y = 20, z = 0} new_acce = {x = 0, y = 20, z = 0}
else else
new_acce = {x = 0, y = 5, z = 0} new_acce = {x = 0, y = 5, z = 0}
end 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()) self.object:setpos(self.object:getpos())
else else
new_acce = {x = 0, y = 0, z = 0} new_acce = {x = 0, y = 0, z = 0}
@ -197,9 +176,9 @@ function boat.on_step(self, dtime)
local pos = self.object:getpos() local pos = self.object:getpos()
pos.y = math.floor(pos.y) + 0.5 pos.y = math.floor(pos.y) + 0.5
self.object:setpos(pos) 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 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:getvelocity().y)
self.object:setpos(self.object:getpos()) self.object:setpos(self.object:getpos())
end end
@ -209,14 +188,31 @@ function boat.on_step(self, dtime)
self.object:setacceleration(new_acce) self.object:setacceleration(new_acce)
end 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", { minetest.register_craftitem("boats:" .. parameters.name, {
description = "Boat", description = parameters.description or "Boat",
inventory_image = "boats_inventory.png", inventory_image = "boats_" .. parameters.name .. "_inventory.png",
wield_image = "boats_wield.png", wield_image = "boats_" .. parameters.name .. "_wield.png",
wield_scale = {x = 2, y = 2, z = 1}, wield_scale = {x = 2, y = 2, z = 1},
liquids_pointable = true, liquids_pointable = true,
@ -224,17 +220,109 @@ minetest.register_craftitem("boats:boat", {
if pointed_thing.type ~= "node" then if pointed_thing.type ~= "node" then
return return
end end
if not is_water(pointed_thing.under) then if not boats.is_water(pointed_thing.under) then
return return
end end
pointed_thing.under.y = pointed_thing.under.y + 0.5 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 if not minetest.setting_getbool("creative_mode") then
itemstack:take_item() itemstack:take_item()
end end
return itemstack return itemstack
end, 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({ minetest.register_craft({

Some files were not shown because too many files have changed in this diff Show More