Version MFF.
27
.gitignore
vendored
Normal file → Executable file
@ -1,7 +1,22 @@
|
|||||||
## Generic ignorable patterns and files
|
## Files related to minetest development cycle
|
||||||
*~
|
/*.patch
|
||||||
.*.swp
|
# GNU Patch reject file
|
||||||
*bak*
|
*.rej
|
||||||
tags
|
|
||||||
*.vim
|
|
||||||
|
|
||||||
|
## Editors and Development environments
|
||||||
|
*~
|
||||||
|
*.swp
|
||||||
|
*.bak*
|
||||||
|
*.orig
|
||||||
|
# Vim
|
||||||
|
*.vim
|
||||||
|
# Kate
|
||||||
|
.*.kate-swp
|
||||||
|
.swp.*
|
||||||
|
# Eclipse (LDT)
|
||||||
|
.project
|
||||||
|
.settings/
|
||||||
|
.buildpath
|
||||||
|
.metadata
|
||||||
|
# Idea IDE
|
||||||
|
.idea/*
|
||||||
|
25
README.txt
Normal file → Executable file
@ -1,23 +1,24 @@
|
|||||||
The main game for the Minetest game engine [minetest_game]
|
Minetest Game [minetest_game]
|
||||||
==========================================================
|
=============================
|
||||||
|
The main subgame for the Minetest engine
|
||||||
|
========================================
|
||||||
|
|
||||||
To use this game with Minetest, insert this repository as
|
To use this subgame with the Minetest engine, insert this repository as
|
||||||
/games/minetest_game
|
/games/minetest_game
|
||||||
in the Minetest Engine.
|
|
||||||
|
|
||||||
The Minetest Engine can be found in:
|
The Minetest engine can be found in:
|
||||||
https://github.com/minetest/minetest/
|
https://github.com/minetest/minetest/
|
||||||
|
|
||||||
Compatibility
|
Compatibility
|
||||||
--------------
|
--------------
|
||||||
The minetest_game github master HEAD is generally compatible with the github
|
The Minetest Game github master HEAD is generally compatible with the github
|
||||||
master HEAD of minetest.
|
master HEAD of the Minetest engine.
|
||||||
|
|
||||||
Additionally, when the minetest engine is tagged to be a certain version (eg.
|
Additionally, when the Minetest engine is tagged to be a certain version (eg.
|
||||||
0.4.10), minetest_game is tagged with the version too.
|
0.4.10), Minetest Game is tagged with the version too.
|
||||||
|
|
||||||
When stable releases are made, minetest_game is packaged and made available in
|
When stable releases are made, Minetest Game is packaged and made available in
|
||||||
http://minetest.net/download.php
|
http://minetest.net/download
|
||||||
and in case the repository has grown too much, it may be reset. In that sense,
|
and in case the repository has grown too much, it may be reset. In that sense,
|
||||||
this is not a "real" git repository. (Package maintainers please note!)
|
this is not a "real" git repository. (Package maintainers please note!)
|
||||||
|
|
||||||
@ -49,4 +50,4 @@ Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
|||||||
http://creativecommons.org/licenses/by-sa/3.0/
|
http://creativecommons.org/licenses/by-sa/3.0/
|
||||||
|
|
||||||
License of menu/header.png
|
License of menu/header.png
|
||||||
Copyright (C) 2013 BlockMen CC BY-3.0
|
Copyright (C) 2015 paramat CC BY-SA 3.0
|
||||||
|
2
game.conf
Normal file → Executable file
@ -1 +1 @@
|
|||||||
name = Minetest
|
name = MinetestForFun Game
|
||||||
|
687
game_api.txt
Normal file → Executable file
@ -1,199 +1,652 @@
|
|||||||
minetest_game API
|
Minetest Game API
|
||||||
======================
|
=================
|
||||||
GitHub Repo: https://github.com/minetest/minetest_game
|
GitHub Repo: https://github.com/minetest/minetest_game
|
||||||
|
|
||||||
Introduction
|
Introduction
|
||||||
------------
|
------------
|
||||||
The minetest_game gamemode offers multiple new possibilities in addition to Minetest's built-in API, allowing you to
|
|
||||||
add new plants to farming mod, buckets for new liquids, new stairs and custom panes.
|
The Minetest Game subgame offers multiple new possibilities in addition to the Minetest engine's built-in API,
|
||||||
|
allowing you to add new plants to farming mod, buckets for new liquids, new stairs and custom panes.
|
||||||
For information on the Minetest API, visit https://github.com/minetest/minetest/blob/master/doc/lua_api.txt
|
For information on the Minetest API, visit https://github.com/minetest/minetest/blob/master/doc/lua_api.txt
|
||||||
Please note:
|
Please note:
|
||||||
[XYZ] refers to a section the Minetest API
|
|
||||||
[#ABC] refers to a section in this document
|
* [XYZ] refers to a section the Minetest API
|
||||||
^ Explanation for line above
|
* [#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", -- Source node name
|
"default:lava_source", -- name of the source node
|
||||||
"default:lava_flowing", -- Flowing node name
|
"default:lava_flowing", -- name of the flowing node
|
||||||
"bucket:bucket_lava", -- Name to be used for bucket
|
"bucket:bucket_lava", -- name of the new bucket item (or nil if liquid is not takeable)
|
||||||
"bucket_lava.png", -- Bucket texture (for wielditem and inventory_image)
|
"bucket_lava.png", -- texture of the new bucket item (ignored if itemname == nil)
|
||||||
"Lava Bucket" -- Bucket description
|
"Lava Bucket", -- text description of the bucket item
|
||||||
|
{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.register_bed(
|
||||||
|
"beds:bed", -- Bed name
|
||||||
|
def -- See [#Bed definition]
|
||||||
|
)
|
||||||
|
|
||||||
|
* `beds.read_spawns() ` Returns a table containing players respawn positions
|
||||||
|
* `beds.kick_players()` Forces all players to leave bed
|
||||||
|
* `beds.skip_night()` Sets world time to morning and saves respawn position of all players currently sleeping
|
||||||
|
|
||||||
|
### Bed definition
|
||||||
|
|
||||||
|
{
|
||||||
|
description = "Simple Bed",
|
||||||
|
inventory_image = "beds_bed.png",
|
||||||
|
wield_image = "beds_bed.png",
|
||||||
|
tiles = {
|
||||||
|
bottom = {'Tile definition'}, -- the tiles of the bottom part of the bed.
|
||||||
|
top = {Tile definition} -- the tiles of the bottom part of the bed.
|
||||||
|
},
|
||||||
|
nodebox = {
|
||||||
|
bottom = 'regular nodebox', -- bottom part of bed (see [Node boxes])
|
||||||
|
top = 'regular nodebox', -- top part of bed (see [Node boxes])
|
||||||
|
},
|
||||||
|
selectionbox = 'regular nodebox', -- for both nodeboxes (see [Node boxes])
|
||||||
|
recipe = { -- Craft recipe
|
||||||
|
{"group:wool", "group:wool", "group:wool"},
|
||||||
|
{"group:wood", "group:wood", "group:wood"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
---------
|
---------
|
||||||
The doors mod allows modders to register custom doors.
|
|
||||||
|
|
||||||
doors.register_door(name, def)
|
The doors mod allows modders to register custom doors and trapdoors.
|
||||||
^ name: "Door name"
|
|
||||||
^ def: See [#Door definition]
|
`doors.register_door(name, def)`
|
||||||
|
|
||||||
|
* Registers new door
|
||||||
|
* `name` Name for door
|
||||||
|
* `def` See [#Door definition]
|
||||||
|
|
||||||
|
`doors.register_trapdoor(name, def)`
|
||||||
|
|
||||||
|
* Registers new trapdoor
|
||||||
|
* `name` Name for trapdoor
|
||||||
|
* `def` See [#Trapdoor definition]
|
||||||
|
|
||||||
|
`doors.register_fencegate(name, def)`
|
||||||
|
|
||||||
|
* Registers new fence gate
|
||||||
|
* `name` Name for fence gate
|
||||||
|
* `def` See [#Fence gate definition]
|
||||||
|
|
||||||
|
`doors.get(pos)`
|
||||||
|
|
||||||
|
* `pos` A position as a table, e.g `{x = 1, y = 1, z = 1}`
|
||||||
|
* Returns an ObjectRef to a door, or nil if the position does not contain a door
|
||||||
|
|
||||||
|
### Methods
|
||||||
|
|
||||||
|
:open(player) -- Open the door object, returns if door was opened
|
||||||
|
:close(player) -- Close the door object, returns if door was closed
|
||||||
|
:toggle(player) -- Toggle the door state, returns if state was toggled
|
||||||
|
:state() -- returns the door state, true = open, false = closed
|
||||||
|
|
||||||
|
the "player" parameter can be omitted in all methods. If passed then
|
||||||
|
the usual permission checks will be performed to make sure the player
|
||||||
|
has the permissions needed to open this door. If omitted then no
|
||||||
|
permission checks are performed.
|
||||||
|
|
||||||
|
### Door definition
|
||||||
|
|
||||||
#Door definition
|
|
||||||
----------------
|
|
||||||
{
|
|
||||||
description = "Door description",
|
description = "Door description",
|
||||||
inventory_image = "mod_door_inv.png",
|
inventory_image = "mod_door_inv.png",
|
||||||
groups = {group = 1},
|
groups = {choppy = 2},
|
||||||
tiles_bottom: [Tile definition],
|
tiles = {"mod_door.png"}, -- UV map.
|
||||||
^ the tiles of the bottom part of the door {front, side}
|
recipe = craftrecipe,
|
||||||
tiles_top: [Tile definition],
|
sounds = default.node_sound_wood_defaults(), -- optional
|
||||||
^ the tiles of the bottom part of the door {front, side}
|
sound_open = sound play for open door, -- optional
|
||||||
node_box_bottom = regular nodebox, see [Node boxes], OPTIONAL,
|
sound_close = sound play for close door, -- optional
|
||||||
node_box_top = regular nodebox, see [Node boxes], OPTIONAL,
|
protected = false, -- If true, only placer can open the door (locked for others)
|
||||||
selection_box_bottom = regular nodebox, see [Node boxes], OPTIONAL,
|
|
||||||
selection_box_top = regular nodebox, see [Node boxes], OPTIONAL,
|
### Trapdoor definition
|
||||||
only_placer_can_open = true/false,
|
|
||||||
^ If true, only placer can open the door (locked for others)
|
description = "Trapdoor description",
|
||||||
}
|
inventory_image = "mod_trapdoor_inv.png",
|
||||||
|
groups = {choppy = 2},
|
||||||
|
tile_front = "doors_trapdoor.png", -- the texture for the front and back of the trapdoor
|
||||||
|
tile_side = "doors_trapdoor_side.png", -- the tiles of the four side parts of the trapdoor
|
||||||
|
sounds = default.node_sound_wood_defaults(), -- optional
|
||||||
|
sound_open = sound play for open door, -- optional
|
||||||
|
sound_close = sound play for close door, -- optional
|
||||||
|
protected = false, -- If true, only placer can open the door (locked for others)
|
||||||
|
|
||||||
|
### Fence gate definition
|
||||||
|
|
||||||
|
description = "Wooden Fence Gate",
|
||||||
|
texture = "default_wood.png",
|
||||||
|
material = "default:wood",
|
||||||
|
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
|
||||||
|
sounds = default.node_sound_wood_defaults(), -- optional
|
||||||
|
|
||||||
|
Fence API
|
||||||
|
---------
|
||||||
|
|
||||||
|
Allows creation of new fences with "fencelike" drawtype.
|
||||||
|
|
||||||
|
`default.register_fence(name, item definition)`
|
||||||
|
|
||||||
|
Registers a new fence. Custom fields texture and material are required, as
|
||||||
|
are name and description. The rest is optional. You can pass most normal
|
||||||
|
nodedef fields here except drawtype. The fence group will always be added
|
||||||
|
for this node.
|
||||||
|
|
||||||
|
### fence definition
|
||||||
|
|
||||||
|
name = "default:fence_wood",
|
||||||
|
description = "Wooden Fence",
|
||||||
|
texture = "default_wood.png",
|
||||||
|
material = "default:wood",
|
||||||
|
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
|
||||||
|
Walls API
|
||||||
|
---------
|
||||||
|
|
||||||
|
The walls API allows easy addition of stone auto-connecting wall nodes.
|
||||||
|
|
||||||
|
walls.register(name, desc, texture, mat, sounds)
|
||||||
|
^ name = "walls:stone_wall". Node name.
|
||||||
|
^ desc = "A Stone wall"
|
||||||
|
^ texture = "default_stone.png"
|
||||||
|
^ mat = "default:stone". Used to auto-generate crafting recipe.
|
||||||
|
^ sounds = sounds: see [#Default sounds]
|
||||||
|
|
||||||
Farming API
|
Farming API
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
The farming API allows you to easily register plants and hoes.
|
The farming API allows you to easily register plants and hoes.
|
||||||
|
|
||||||
farming.register_hoe(name, hoe definition)
|
`farming.register_hoe(name, hoe definition)`
|
||||||
-> Register a new hoe, see [#hoe definition]
|
* Register a new hoe, see [#hoe definition]
|
||||||
|
|
||||||
|
`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
|
||||||
|
|
||||||
farming.register_plant(name, Plant definition)
|
|
||||||
-> Register a new growing plant, see [#Plant definition]
|
|
||||||
|
|
||||||
#Hoe Definition
|
|
||||||
---------------
|
|
||||||
{
|
{
|
||||||
description = "", -- Description for tooltip
|
description = "", -- Description for tooltip
|
||||||
inventory_image = "unknown_item.png", -- Image to be used as wield- and inventory image
|
inventory_image = "unknown_item.png", -- Image to be used as wield- and inventory image
|
||||||
max_uses = 30, -- Uses until destroyed
|
max_uses = 30, -- Uses until destroyed
|
||||||
recipe = { -- Craft recipe
|
material = "", -- Material for recipes
|
||||||
|
recipe = { -- Craft recipe, if material isn't used
|
||||||
{"air", "air", "air"},
|
{"air", "air", "air"},
|
||||||
{"", "group:stick"},
|
{"", "group:stick"},
|
||||||
{"", "group:stick"},
|
{"", "group:stick"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Plant definition
|
### Plant definition
|
||||||
-----------------
|
|
||||||
{
|
{
|
||||||
description = "", -- Description of seed item
|
description = "", -- Description of seed item
|
||||||
inventory_image = "unknown_item.png", -- Image to be used as seed's wield- and inventory image
|
inventory_image = "unknown_item.png", -- Image to be used as seed's wield- and inventory image
|
||||||
steps = 8, -- How many steps the plant has to grow, until it can be harvested
|
steps = 8, -- How many steps the plant has to grow, until it can be harvested
|
||||||
^ Always provide a plant texture for ech step, format: modname_plantname_i.png (i = stepnumber)
|
-- ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber)
|
||||||
minlight = 13, -- Minimum light to grow
|
minlight = 13, -- Minimum light to grow
|
||||||
maxlight = LIGHT_MAX -- Maximum light to grow
|
maxlight = default.LIGHT_MAX -- Maximum light to grow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Fire API
|
||||||
|
--------
|
||||||
|
|
||||||
|
New node def property:
|
||||||
|
|
||||||
|
`on_burn(pos)`
|
||||||
|
|
||||||
|
* 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
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
`give_initial_stuff.give(player)`
|
||||||
|
|
||||||
|
^ Give initial stuff to "player"
|
||||||
|
|
||||||
|
`give_initial_stuff.add(stack)`
|
||||||
|
|
||||||
|
^ Add item to the initial stuff
|
||||||
|
^ Stack can be an ItemStack or a item name eg: "default:dirt 99"
|
||||||
|
^ Can be called after the game has loaded
|
||||||
|
|
||||||
|
`give_initial_stuff.clear()`
|
||||||
|
|
||||||
|
^ Removes all items from the initial stuff
|
||||||
|
^ Can be called after the game has loaded
|
||||||
|
|
||||||
|
`give_initial_stuff.get_list()`
|
||||||
|
|
||||||
|
^ returns list of item stacks
|
||||||
|
|
||||||
|
`give_initial_stuff.set_list(list)`
|
||||||
|
|
||||||
|
^ List of initial items with numeric indices.
|
||||||
|
|
||||||
|
`give_initial_stuff.add_from_csv(str)`
|
||||||
|
|
||||||
|
^ 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
|
||||||
|
----------
|
||||||
|
|
||||||
|
`tnt.register_tnt(definition)`
|
||||||
|
|
||||||
|
^ Register a new type of tnt.
|
||||||
|
|
||||||
|
* `name` The name of the node. If no prefix is given `tnt` is used.
|
||||||
|
* `description` A description for your TNT.
|
||||||
|
* `radius` The radius within which the TNT can destroy nodes. The default is 3.
|
||||||
|
* `damage_radius` The radius within which the TNT can damage players and mobs. By default it is twice the `radius`.
|
||||||
|
* `disable_drops` Disable drops. By default it is set to false.
|
||||||
|
* `ignore_protection` Don't check `minetest.is_protected` before removing a node.
|
||||||
|
* `ignore_on_blast` Don't call `on_blast` even if a node has one.
|
||||||
|
* `tiles` Textures for node
|
||||||
|
* `side` Side tiles. By default the name of the tnt with a suffix of `_side.png`.
|
||||||
|
* `top` Top tile. By default the name of the tnt with a suffix of `_top.png`.
|
||||||
|
* `bottom` Bottom tile. By default the name of the tnt with a suffix of `_bottom.png`.
|
||||||
|
* `burning` Top tile when lit. By default the name of the tnt with a suffix of `_top_burning_animated.png".
|
||||||
|
|
||||||
|
`tnt.boom(position, definition)`
|
||||||
|
|
||||||
|
^ Create an explosion.
|
||||||
|
|
||||||
|
* `position` The center of explosion.
|
||||||
|
* `definition` The TNT definion as passed to `tnt.register`
|
||||||
|
|
||||||
|
`tnt.burn(position, [nodename])`
|
||||||
|
|
||||||
|
^ Ignite TNT at position, nodename isn't required unless already known.
|
||||||
|
|
||||||
|
|
||||||
|
To make dropping items from node inventories easier, you can use the
|
||||||
|
following helper function from 'default':
|
||||||
|
|
||||||
|
default.get_inventory_drops(pos, inventory, drops)
|
||||||
|
|
||||||
|
^ Return drops from node inventory "inventory" in drops.
|
||||||
|
|
||||||
|
* `pos` - the node position
|
||||||
|
* `inventory` - the name of the inventory (string)
|
||||||
|
* `drops` - an initialized list
|
||||||
|
|
||||||
|
The function returns no values. The drops are returned in the `drops`
|
||||||
|
parameter, and drops is not reinitialized so you can call it several
|
||||||
|
times in a row to add more inventory items to it.
|
||||||
|
|
||||||
|
|
||||||
|
`on_blast` callbacks:
|
||||||
|
|
||||||
|
Both nodedefs and entitydefs can provide an `on_blast()` callback
|
||||||
|
|
||||||
|
`nodedef.on_blast(pos, intensity)`
|
||||||
|
^ Allow drop and node removal overriding
|
||||||
|
* `pos` - node position
|
||||||
|
* `intensity` - TNT explosion measure. larger or equal to 1.0
|
||||||
|
^ Should return a list of drops (e.g. {"default:stone"})
|
||||||
|
^ Should perform node removal itself. If callback exists in the nodedef
|
||||||
|
^ then the TNT code will not destroy this node.
|
||||||
|
|
||||||
|
`entitydef.on_blast(luaobj, damage)`
|
||||||
|
^ Allow TNT effects on entities to be overridden
|
||||||
|
* `luaobj` - LuaEntityRef of the entity
|
||||||
|
* `damage` - suggested HP damage value
|
||||||
|
^ Should return a list of (bool do_damage, bool do_knockback, table drops)
|
||||||
|
* `do_damage` - if true then TNT mod wil damage the entity
|
||||||
|
* `do_knockback` - if true then TNT mod will knock the entity away
|
||||||
|
* `drops` - a list of drops, e.g. {"wool:red"}
|
||||||
|
|
||||||
|
|
||||||
|
Screwdriver API
|
||||||
|
---------------
|
||||||
|
|
||||||
|
The screwdriver API allows you to control a node's behaviour when a screwdriver is used on it.
|
||||||
|
To use it, add the `on_screwdriver` function to the node definition.
|
||||||
|
|
||||||
|
`on_rotate(pos, node, user, mode, new_param2)`
|
||||||
|
|
||||||
|
* `pos` Position of the node that the screwdriver is being used on
|
||||||
|
* `node` that node
|
||||||
|
* `user` The player who used the screwdriver
|
||||||
|
* `mode` screwdriver.ROTATE_FACE or screwdriver.ROTATE_AXIS
|
||||||
|
* `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 = 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
|
Stairs API
|
||||||
----------
|
----------
|
||||||
|
|
||||||
The stairs API lets you register stairs and slabs and ensures that they are registered the same way as those
|
The stairs API lets you register stairs and slabs and ensures that they are registered the same way as those
|
||||||
delivered with minetest_game, to keep them compatible with other mods.
|
delivered with Minetest Game, to keep them compatible with other mods.
|
||||||
|
|
||||||
stairs.register_stair(subname, recipeitem, groups, images, description, sounds)
|
`stairs.register_stair(subname, recipeitem, groups, images, description, sounds)`
|
||||||
-> 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"
|
|
||||||
-> groups: see [Known damage and digging time defining groups]
|
|
||||||
-> images: see [Tile definition]
|
|
||||||
-> description: used for the description field in the stair's definition
|
|
||||||
-> sounds: see [#Default sounds]
|
|
||||||
|
|
||||||
stairs.register_slab(subname, recipeitem, groups, images, description, sounds)
|
* Registers a stair.
|
||||||
-> Registers a slabs
|
* `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", may be `nil`
|
||||||
-> recipeitem: Item used in the craft recipe, e.g. "default:cobble"
|
* `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
|
* `sounds`: see [#Default sounds]
|
||||||
-> sounds: see [#Default sounds]
|
|
||||||
|
|
||||||
stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab, sounds)
|
`stairs.register_slab(subname, recipeitem, groups, images, description, sounds)`
|
||||||
-> A wrapper for stairs.register_stair and stairs.register_slab
|
|
||||||
-> Uses almost the same arguments as stairs.register_stair
|
* Registers a slabs
|
||||||
-> desc_stair: Description for stair node
|
* `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname"
|
||||||
-> desc_slab: Description for slab node
|
* `recipeitem`: Item used in the craft recipe, e.g. "default:cobble"
|
||||||
|
* `groups`: see [Known damage and digging time defining groups]
|
||||||
|
* `images`: see [Tile definition]
|
||||||
|
* `description`: used for the description field in the stair's definition
|
||||||
|
* `sounds`: see [#Default sounds]
|
||||||
|
|
||||||
|
`stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab, sounds)`
|
||||||
|
|
||||||
|
* A wrapper for stairs.register_stair and stairs.register_slab
|
||||||
|
* Uses almost the same arguments as stairs.register_stair
|
||||||
|
* `desc_stair`: Description for stair node
|
||||||
|
* `desc_slab`: Description for slab node
|
||||||
|
|
||||||
Xpanes API
|
Xpanes API
|
||||||
----------
|
----------
|
||||||
|
|
||||||
Creates panes that automatically connect to each other
|
Creates panes that automatically connect to each other
|
||||||
|
|
||||||
xpanes.register_pane(subname, def)
|
`xpanes.register_pane(subname, def)`
|
||||||
-> subname: used for nodename. Result: "xpanes:subname_{1..16}"
|
|
||||||
-> def: See [#Pane definition]
|
* `subname`: used for nodename. Result: "xpanes:subname" and "xpanes:subname_{2..15}"
|
||||||
|
* `def`: See [#Pane definition]
|
||||||
|
|
||||||
|
### Pane definition
|
||||||
|
|
||||||
#Pane definition
|
|
||||||
----------------
|
|
||||||
{
|
{
|
||||||
textures = {"texture_Bottom_top", "texture_left_right", "texture_front_back"},
|
textures = {"texture for sides", (unused), "texture for top and bottom"}, -- More tiles aren't supported
|
||||||
^ More tiles aren't supported
|
groups = {group = rating}, -- Uses the known node groups, see [Known damage and digging time defining groups]
|
||||||
groups = {group = rating},
|
sounds = SoundSpec, -- See [#Default sounds]
|
||||||
^ Uses the known node groups, see [Known damage and digging time defining groups]
|
recipe = {{"","","","","","","","",""}}, -- Recipe field only
|
||||||
sounds = SoundSpec,
|
|
||||||
^ See [#Default sounds]
|
|
||||||
recipe = {{"","","","","","","","",""}},
|
|
||||||
^ Recipe field only
|
|
||||||
on_construct = function(pos)
|
|
||||||
update_pane(pos, "pane")
|
|
||||||
end,
|
|
||||||
^ Required to handle rotation correctly
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Raillike definitions
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
The following nodes use the group `connect_to_raillike` and will only connect to
|
||||||
|
raillike nodes within this group and the same group value.
|
||||||
|
Use `minetest.raillike_group(<Name>)` to get the group value.
|
||||||
|
|
||||||
|
| Node type | Raillike group name
|
||||||
|
|-----------------------|---------------------
|
||||||
|
| default:rail | "rail"
|
||||||
|
| tnt:gunpowder | "gunpowder"
|
||||||
|
| tnt:gunpowder_burning | "gunpowder"
|
||||||
|
|
||||||
|
Example:
|
||||||
|
If you want to add a new rail type and want it to connect with default:rail,
|
||||||
|
add `connect_to_raillike=minetest.raillike_group("rail")` into the `groups` table
|
||||||
|
of your node.
|
||||||
|
|
||||||
|
|
||||||
Default sounds
|
Default sounds
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Sounds inside the default table can be used within the sounds field of node definitions.
|
Sounds inside the default table can be used within the sounds field of node definitions.
|
||||||
|
|
||||||
default.node_sound_defaults()
|
* `default.node_sound_defaults()`
|
||||||
default.node_sound_stone_defaults()
|
* `default.node_sound_stone_defaults()`
|
||||||
default.node_sound_dirt_defaults()
|
* `default.node_sound_dirt_defaults()`
|
||||||
default.node_sound_sand_defaults()
|
* `default.node_sound_sand_defaults()`
|
||||||
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.LIGHT_MAX` The maximum light level (see [Node definition] light_source)
|
||||||
|
|
||||||
Player API
|
Player API
|
||||||
----------
|
----------
|
||||||
|
|
||||||
The player API can register player models and update the player's appearence
|
The player API can register player models and update the player's appearence
|
||||||
|
|
||||||
default.player_register_model(name, def)
|
`default.player_register_model(name, def)`
|
||||||
^ Register a new model to be used by players.
|
|
||||||
-> name: model filename such as "character.x", "foo.b3d", etc.
|
|
||||||
-> def: See [#Model definition]
|
|
||||||
|
|
||||||
default.registered_player_models[name]
|
* Register a new model to be used by players.
|
||||||
^ Get a model's definition
|
* name: model filename such as "character.x", "foo.b3d", etc.
|
||||||
-> see [#Model definition]
|
* def: See [#Model definition]
|
||||||
|
|
||||||
default.player_set_model(player, model_name)
|
`default.registered_player_models[name]`
|
||||||
^ Change a player's model
|
|
||||||
-> player: PlayerRef
|
|
||||||
-> model_name: model registered with player_register_model()
|
|
||||||
|
|
||||||
default.player_set_animation(player, anim_name [, speed])
|
* Get a model's definition
|
||||||
^ Applies an animation to a player
|
* see [#Model definition]
|
||||||
-> anim_name: name of the animation.
|
|
||||||
-> speed: frames per second. If nil, default from the model is used
|
|
||||||
|
|
||||||
default.player_set_textures(player, textures)
|
`default.player_set_model(player, model_name)`
|
||||||
^ Sets player textures
|
|
||||||
-> player: PlayerRef
|
* Change a player's model
|
||||||
-> textures: array of textures
|
* `player`: PlayerRef
|
||||||
^ If <textures> is nil, the default textures from the model def are used
|
* `model_name`: model registered with player_register_model()
|
||||||
|
|
||||||
|
`default.player_set_animation(player, anim_name [, speed])`
|
||||||
|
|
||||||
|
* Applies an animation to a player
|
||||||
|
* anim_name: name of the animation.
|
||||||
|
* speed: frames per second. If nil, default from the model is used
|
||||||
|
|
||||||
|
`default.player_set_textures(player, textures)`
|
||||||
|
|
||||||
|
* Sets player textures
|
||||||
|
* `player`: PlayerRef
|
||||||
|
* `textures`: array of textures, If `textures` is nil, the default textures from the model def are used
|
||||||
|
|
||||||
default.player_get_animation(player)
|
default.player_get_animation(player)
|
||||||
^ Returns a table containing fields "model", "textures" and "animation".
|
|
||||||
^ Any of the fields of the returned table may be nil.
|
|
||||||
-> player: PlayerRef
|
|
||||||
|
|
||||||
Model Definition
|
* Returns a table containing fields `model`, `textures` and `animation`.
|
||||||
----------------
|
* Any of the fields of the returned table may be nil.
|
||||||
|
* player: PlayerRef
|
||||||
|
|
||||||
|
### Model Definition
|
||||||
|
|
||||||
{
|
{
|
||||||
animation_speed = 30, -- Default animation speed, in FPS.
|
animation_speed = 30, -- Default animation speed, in FPS.
|
||||||
textures = {"character.png", }, -- Default array of textures.
|
textures = {"character.png", }, -- Default array of textures.
|
||||||
visual_size = {x=1, y=1,}, -- Used to scale the model.
|
visual_size = {x = 1, y = 1}, -- Used to scale the model.
|
||||||
animations = {
|
animations = {
|
||||||
-- <anim_name> = { x=<start_frame>, y=<end_frame>, },
|
-- <anim_name> = {x = <start_frame>, y = <end_frame>},
|
||||||
foo = { x= 0, y=19, },
|
foo = {x = 0, y = 19},
|
||||||
bar = { x=20, y=39, },
|
bar = {x = 20, y = 39},
|
||||||
-- ...
|
-- ...
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Leafdecay
|
||||||
|
---------
|
||||||
|
|
||||||
|
To enable leaf decay for a node, add it to the `leafdecay` group.
|
||||||
|
|
||||||
|
The rating of the group determines how far from a node in the group `tree`
|
||||||
|
the node can be without decaying.
|
||||||
|
|
||||||
|
If `param2` of the node is ~= 0, the node will always be preserved. Thus, if
|
||||||
|
the player places a node of that kind, you will want to set `param2 = 1` or so.
|
||||||
|
|
||||||
|
The function `default.after_place_leaves` can be set as `after_place_node of a node`
|
||||||
|
to set param2 to 1 if the player places the node (should not be used for nodes
|
||||||
|
that use param2 otherwise (e.g. facedir)).
|
||||||
|
|
||||||
|
If the node is in the `leafdecay_drop` group then it will always be dropped as an
|
||||||
|
item.
|
||||||
|
|
||||||
|
Dyes
|
||||||
|
----
|
||||||
|
|
||||||
|
To make recipes that will work with any dye ever made by anybody, define
|
||||||
|
them based on groups. You can select any group of groups, based on your need for
|
||||||
|
amount of colors.
|
||||||
|
|
||||||
|
### Color groups
|
||||||
|
|
||||||
|
Base color groups:
|
||||||
|
|
||||||
|
* `basecolor_white`
|
||||||
|
* `basecolor_grey`
|
||||||
|
* `basecolor_black`
|
||||||
|
* `basecolor_red`
|
||||||
|
* `basecolor_yellow`
|
||||||
|
* `basecolor_green`
|
||||||
|
* `basecolor_cyan`
|
||||||
|
* `basecolor_blue`
|
||||||
|
* `basecolor_magenta`
|
||||||
|
|
||||||
|
Extended color groups ( * means also base color )
|
||||||
|
|
||||||
|
* `excolor_white` *
|
||||||
|
* `excolor_lightgrey`
|
||||||
|
* `excolor_grey` *
|
||||||
|
* `excolor_darkgrey`
|
||||||
|
* `excolor_black` *
|
||||||
|
* `excolor_red` *
|
||||||
|
* `excolor_orange`
|
||||||
|
* `excolor_yellow` *
|
||||||
|
* `excolor_lime`
|
||||||
|
* `excolor_green` *
|
||||||
|
* `excolor_aqua`
|
||||||
|
* `excolor_cyan` *
|
||||||
|
* `excolor_sky_blue`
|
||||||
|
* `excolor_blue` *
|
||||||
|
* `excolor_violet`
|
||||||
|
* `excolor_magenta` *
|
||||||
|
* `excolor_red_violet`
|
||||||
|
|
||||||
|
The whole unifieddyes palette as groups:
|
||||||
|
|
||||||
|
* `unicolor_<excolor>`
|
||||||
|
|
||||||
|
For the following, no white/grey/black is allowed:
|
||||||
|
|
||||||
|
* `unicolor_medium_<excolor>`
|
||||||
|
* `unicolor_dark_<excolor>`
|
||||||
|
* `unicolor_light_<excolor>`
|
||||||
|
* `unicolor_<excolor>_s50`
|
||||||
|
* `unicolor_medium_<excolor>_s50`
|
||||||
|
* `unicolor_dark_<excolor>_s50`
|
||||||
|
|
||||||
|
Example of one shapeless recipe using a color group:
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
type = "shapeless",
|
||||||
|
output = '<mod>:item_yellow',
|
||||||
|
recipe = {'<mod>:item_no_color', 'group:basecolor_yellow'},
|
||||||
|
})
|
||||||
|
|
||||||
|
### Color lists
|
||||||
|
|
||||||
|
* `dye.basecolors` are an array containing the names of available base colors
|
||||||
|
|
||||||
|
* `dye.excolors` are an array containing the names of the available extended colors
|
||||||
|
|
||||||
|
Trees
|
||||||
|
-----
|
||||||
|
|
||||||
|
* `default.grow_tree(pos, is_apple_tree)`
|
||||||
|
* Grows a mgv6 tree or apple tree at pos
|
||||||
|
|
||||||
|
* `default.grow_jungle_tree(pos)`
|
||||||
|
* Grows a mgv6 jungletree at pos
|
||||||
|
|
||||||
|
* `default.grow_pine_tree(pos)`
|
||||||
|
* Grows a mgv6 pinetree at pos
|
||||||
|
|
||||||
|
* `default.grow_new_apple_tree(pos)`
|
||||||
|
* Grows a new design apple tree at pos
|
||||||
|
|
||||||
|
* `default.grow_new_jungle_tree(pos)`
|
||||||
|
* Grows a new design jungle tree at pos
|
||||||
|
|
||||||
|
* `default.grow_new_pine_tree(pos)`
|
||||||
|
* Grows a new design pine tree at pos
|
||||||
|
|
||||||
|
* `default.grow_new_acacia_tree(pos)`
|
||||||
|
* Grows a new design acacia tree at pos
|
||||||
|
|
||||||
|
* `default.grow_new_aspen_tree(pos)`
|
||||||
|
* Grows a new design aspen tree at pos
|
||||||
|
|
||||||
|
* `default.grow_new_snowy_pine_tree(pos)`
|
||||||
|
* Grows a new design snowy pine tree at pos
|
||||||
|
BIN
menu/header.png
Before Width: | Height: | Size: 152 KiB After Width: | Height: | Size: 904 B |
BIN
menu/icon.png
Normal file → Executable file
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 2.9 KiB |
9
minetest.conf
Normal file → Executable file
@ -1,6 +1,3 @@
|
|||||||
mgv6_spflags = biomeblend, jungles
|
# Enable jungles on new worlds, disable biome blend and mud flow (faster, looks better).
|
||||||
|
mgv6_spflags = jungles, nobiomeblend, nomudflow
|
||||||
movement_liquid_sink = 25
|
disable_fire = true
|
||||||
movement_speed_jump = 6.2
|
|
||||||
movement_liquid_fluidity = 0.8
|
|
||||||
movement_liquid_fluidity_smooth = 2
|
|
||||||
|
47
minetest.conf.example
Executable file
@ -0,0 +1,47 @@
|
|||||||
|
# This file contains settings of Minetest Game that can be changed in minetest.conf
|
||||||
|
# By default, all the settings are commented and not functional.
|
||||||
|
# Uncomment settings by removing the preceding #.
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# How much earlier the bones of a dead player can be looted by
|
||||||
|
# everyone if the player dies in a protected area they don't own.
|
||||||
|
# 0 to disable. By default it is "share_bones_time" divide by four.
|
||||||
|
#share_bones_time_early = 300
|
||||||
|
|
||||||
|
# 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
|
||||||
|
#initial_stuff = default:pick_steel,default:axe_steel,default:shovel_steel,default:torch 99,default:cobble 99
|
||||||
|
|
||||||
|
# Whether the TNT mod should be enabled
|
||||||
|
#enable_tnt = <true in singleplayer, false in multiplayer>
|
||||||
|
|
||||||
|
# The radius of a TNT explosion
|
||||||
|
#tnt_radius = 3
|
||||||
|
|
||||||
|
# Enable the stairs mod ABM that replaces the old 'upside down'
|
||||||
|
# stair and slab nodes in old maps with the new param2 versions.
|
||||||
|
#enable_stairs_replace_abm = false
|
||||||
|
|
||||||
|
# Whether you allow respawning in beds
|
||||||
|
# Default value is true
|
||||||
|
#enable_bed_respawn = true
|
||||||
|
|
||||||
|
# Whether players can skip night by sleeping
|
||||||
|
# Default value is true
|
||||||
|
#enable_bed_night_skip = true
|
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
|
30
mods/beds/README.txt
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
Minetest Game mod: beds
|
||||||
|
=======================
|
||||||
|
by BlockMen (c) 2014-2015
|
||||||
|
|
||||||
|
Version: 1.1.1
|
||||||
|
|
||||||
|
About
|
||||||
|
~~~~~
|
||||||
|
This mod adds a bed to Minetest which allows to skip the night. To sleep rightclick the bed, if playing
|
||||||
|
in singleplayer mode the night gets skipped imideatly. If playing on server you get shown how many other
|
||||||
|
players are in bed too. If all players are sleeping the night gets skipped aswell. Also the night skip can be forced
|
||||||
|
if more than 50% of the players are lying in bed and use this option.
|
||||||
|
|
||||||
|
Another feature is a controled respawning. If you have slept in bed (not just lying in it) your respawn point
|
||||||
|
is set to the beds location and you will respawn there after death.
|
||||||
|
You can disable the respawn at beds by setting "enable_bed_respawn = false" in minetest.conf
|
||||||
|
You can also disable the night skip feature by setting "enable_bed_night_skip = false" in minetest.conf or by using
|
||||||
|
the /set command ingame.
|
||||||
|
|
||||||
|
|
||||||
|
License of source code, textures: WTFPL
|
||||||
|
---------------------------------------
|
||||||
|
(c) Copyright BlockMen (2014-2015)
|
||||||
|
|
||||||
|
|
||||||
|
This program is free software. It comes without any warranty, to
|
||||||
|
the extent permitted by applicable law. You can redistribute it
|
||||||
|
and/or modify it under the terms of the Do What The Fuck You Want
|
||||||
|
To Public License, Version 2, as published by Sam Hocevar. See
|
||||||
|
http://sam.zoy.org/wtfpl/COPYING for more details.
|
113
mods/beds/api.lua
Executable file
@ -0,0 +1,113 @@
|
|||||||
|
function beds.register_bed(name, def)
|
||||||
|
minetest.register_node(name .. "_bottom", {
|
||||||
|
description = def.description,
|
||||||
|
inventory_image = def.inventory_image,
|
||||||
|
wield_image = def.wield_image,
|
||||||
|
drawtype = "nodebox",
|
||||||
|
tiles = def.tiles.bottom,
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
is_ground_content = false,
|
||||||
|
stack_max = 1,
|
||||||
|
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 1},
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = def.nodebox.bottom,
|
||||||
|
},
|
||||||
|
selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = def.selectionbox,
|
||||||
|
},
|
||||||
|
after_place_node = function(pos, placer, itemstack)
|
||||||
|
local n = minetest.get_node_or_nil(pos)
|
||||||
|
if not n or not n.param2 then
|
||||||
|
minetest.remove_node(pos)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
local dir = minetest.facedir_to_dir(n.param2)
|
||||||
|
local p = vector.add(pos, dir)
|
||||||
|
local n2 = minetest.get_node_or_nil(p)
|
||||||
|
local def = n2 and minetest.registered_items[n2.name]
|
||||||
|
if not def or not def.buildable_to then
|
||||||
|
minetest.remove_node(pos)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
minetest.set_node(p, {name = n.name:gsub("%_bottom", "_top"), param2 = n.param2})
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
on_destruct = function(pos)
|
||||||
|
local n = minetest.get_node_or_nil(pos)
|
||||||
|
if not n then return end
|
||||||
|
local dir = minetest.facedir_to_dir(n.param2)
|
||||||
|
local p = vector.add(pos, dir)
|
||||||
|
local n2 = minetest.get_node(p)
|
||||||
|
if minetest.get_item_group(n2.name, "bed") == 2 and n.param2 == n2.param2 then
|
||||||
|
minetest.remove_node(p)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
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)
|
||||||
|
local node2 = minetest.get_node_or_nil(p)
|
||||||
|
if not node2 or not minetest.get_item_group(node2.name, "bed") == 2 or
|
||||||
|
not node.param2 == node2.param2 then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
if minetest.is_protected(p, user:get_player_name()) then
|
||||||
|
minetest.record_protection_violation(p, user:get_player_name())
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
if mode ~= screwdriver.ROTATE_FACE then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local newp = vector.add(pos, minetest.facedir_to_dir(new_param2))
|
||||||
|
local node3 = minetest.get_node_or_nil(newp)
|
||||||
|
local def = node3 and minetest.registered_nodes[node3.name]
|
||||||
|
if not def or not def.buildable_to then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
if minetest.is_protected(newp, user:get_player_name()) then
|
||||||
|
minetest.record_protection_violation(newp, user:get_player_name())
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
node.param2 = new_param2
|
||||||
|
minetest.swap_node(pos, node)
|
||||||
|
minetest.remove_node(p)
|
||||||
|
minetest.set_node(newp, {name = node.name:gsub("%_bottom", "_top"), param2 = new_param2})
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node(name .. "_top", {
|
||||||
|
drawtype = "nodebox",
|
||||||
|
tiles = def.tiles.top,
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
is_ground_content = false,
|
||||||
|
pointable = false,
|
||||||
|
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 2},
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = def.nodebox.top,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_alias(name, name .. "_bottom")
|
||||||
|
|
||||||
|
-- register recipe
|
||||||
|
minetest.register_craft({
|
||||||
|
output = name,
|
||||||
|
recipe = def.recipe
|
||||||
|
})
|
||||||
|
end
|
92
mods/beds/beds.lua
Executable file
@ -0,0 +1,92 @@
|
|||||||
|
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_" .. colour .. ".png",
|
||||||
|
"default_wood.png",
|
||||||
|
"beds_bed_side1_" .. colour .. ".png",
|
||||||
|
"beds_bed_side1_" .. colour .. ".png^[transformFX",
|
||||||
|
"default_wood.png",
|
||||||
|
"beds_bed_foot_" .. colour .. ".png",
|
||||||
|
},
|
||||||
|
top = {
|
||||||
|
"beds_bed_top2_" .. colour .. ".png",
|
||||||
|
"default_wood.png",
|
||||||
|
"beds_bed_side2_" .. colour .. ".png",
|
||||||
|
"beds_bed_side2_" .. colour .. ".png^[transformFX",
|
||||||
|
"beds_bed_head.png",
|
||||||
|
"default_wood.png",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
nodebox = {
|
||||||
|
bottom = {
|
||||||
|
{-0.5, -0.5, -0.5, -0.375, -0.065, -0.4375},
|
||||||
|
{0.375, -0.5, -0.5, 0.5, -0.065, -0.4375},
|
||||||
|
{-0.5, -0.375, -0.5, 0.5, -0.125, -0.4375},
|
||||||
|
{-0.5, -0.375, -0.5, -0.4375, -0.125, 0.5},
|
||||||
|
{0.4375, -0.375, -0.5, 0.5, -0.125, 0.5},
|
||||||
|
{-0.4375, -0.3125, -0.4375, 0.4375, -0.0625, 0.5},
|
||||||
|
},
|
||||||
|
top = {
|
||||||
|
{-0.5, -0.5, 0.4375, -0.375, 0.1875, 0.5},
|
||||||
|
{0.375, -0.5, 0.4375, 0.5, 0.1875, 0.5},
|
||||||
|
{-0.5, 0, 0.4375, 0.5, 0.125, 0.5},
|
||||||
|
{-0.5, -0.375, 0.4375, 0.5, -0.125, 0.5},
|
||||||
|
{-0.5, -0.375, -0.5, -0.4375, -0.125, 0.5},
|
||||||
|
{0.4375, -0.375, -0.5, 0.5, -0.125, 0.5},
|
||||||
|
{-0.4375, -0.3125, -0.5, 0.4375, -0.0625, 0.4375},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
|
||||||
|
recipe = {
|
||||||
|
{"", "", "group:stick"},
|
||||||
|
{"wool:" .. colour, "wool:" .. colour, "wool:white"},
|
||||||
|
{"group:wood", "group:wood", "group:wood"},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- 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_" .. colour .. ".png^[transformR90",
|
||||||
|
"default_wood.png",
|
||||||
|
"beds_bed_side_bottom_r_" .. colour .. ".png",
|
||||||
|
"beds_bed_side_bottom_r_" .. colour .. ".png^[transformfx",
|
||||||
|
"beds_transparent.png",
|
||||||
|
"beds_bed_side_bottom_" .. colour .. ".png"
|
||||||
|
},
|
||||||
|
top = {
|
||||||
|
"beds_bed_top_top_" .. colour .. ".png^[transformR90",
|
||||||
|
"default_wood.png",
|
||||||
|
"beds_bed_side_top_r_" .. colour .. ".png",
|
||||||
|
"beds_bed_side_top_r_" .. colour .. ".png^[transformfx",
|
||||||
|
"beds_bed_side_top.png",
|
||||||
|
"beds_transparent.png",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
nodebox = {
|
||||||
|
bottom = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5},
|
||||||
|
top = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5},
|
||||||
|
},
|
||||||
|
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
|
||||||
|
recipe = {
|
||||||
|
{"wool:" .. colour, "wool:" .. colour, "wool:white"},
|
||||||
|
{"group:wood", "group:wood", "group:wood"}
|
||||||
|
},
|
||||||
|
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
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")
|
3
mods/beds/depends.txt
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
default
|
||||||
|
wool
|
||||||
|
areas
|
271
mods/beds/functions.lua
Executable file
@ -0,0 +1,271 @@
|
|||||||
|
local pi = math.pi
|
||||||
|
local player_in_bed = 0
|
||||||
|
local is_sp = minetest.is_singleplayer()
|
||||||
|
local enable_respawn = minetest.setting_getbool("enable_bed_respawn")
|
||||||
|
if enable_respawn == nil then
|
||||||
|
enable_respawn = true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- helper functions
|
||||||
|
|
||||||
|
local function get_look_yaw(pos)
|
||||||
|
local n = minetest.get_node(pos)
|
||||||
|
if n.param2 == 1 then
|
||||||
|
return pi/2, n.param2
|
||||||
|
elseif n.param2 == 3 then
|
||||||
|
return -pi/2, n.param2
|
||||||
|
elseif n.param2 == 0 then
|
||||||
|
return pi, n.param2
|
||||||
|
else
|
||||||
|
return 0, n.param2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function is_night_skip_enabled()
|
||||||
|
local enable_night_skip = minetest.setting_getbool("enable_bed_night_skip")
|
||||||
|
if enable_night_skip == nil then
|
||||||
|
enable_night_skip = true
|
||||||
|
end
|
||||||
|
return enable_night_skip
|
||||||
|
end
|
||||||
|
|
||||||
|
local function check_in_beds(players)
|
||||||
|
local in_bed = beds.player
|
||||||
|
if not players then
|
||||||
|
players = minetest.get_connected_players()
|
||||||
|
end
|
||||||
|
|
||||||
|
for n, player in ipairs(players) do
|
||||||
|
local name = player:get_player_name()
|
||||||
|
if not in_bed[name] then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return #players > 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local function lay_down(player, pos, bed_pos, state, skip)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local hud_flags = player:hud_get_flags()
|
||||||
|
|
||||||
|
if not player or not name then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- stand up
|
||||||
|
if state ~= nil and not state then
|
||||||
|
local p = beds.pos[name] or nil
|
||||||
|
if beds.player[name] ~= nil then
|
||||||
|
beds.player[name] = nil
|
||||||
|
player_in_bed = player_in_bed - 1
|
||||||
|
end
|
||||||
|
-- skip here to prevent sending player specific changes (used for leaving players)
|
||||||
|
if skip then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if p then
|
||||||
|
player:setpos(p)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- physics, eye_offset, etc
|
||||||
|
player:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0})
|
||||||
|
player:set_look_yaw(math.random(1, 180)/100)
|
||||||
|
default.player_attached[name] = false
|
||||||
|
player:set_physics_override(1, 1, 1)
|
||||||
|
hud_flags.wielditem = true
|
||||||
|
default.player_set_animation(player, "stand" , 30)
|
||||||
|
|
||||||
|
-- lay down
|
||||||
|
else
|
||||||
|
beds.player[name] = 1
|
||||||
|
beds.pos[name] = pos
|
||||||
|
player_in_bed = player_in_bed + 1
|
||||||
|
|
||||||
|
-- physics, eye_offset, etc
|
||||||
|
player:set_eye_offset({x=0,y=-13,z=0}, {x=0,y=0,z=0})
|
||||||
|
local yaw, param2 = get_look_yaw(bed_pos)
|
||||||
|
player:set_look_yaw(yaw)
|
||||||
|
local dir = minetest.facedir_to_dir(param2)
|
||||||
|
local p = {x=bed_pos.x+dir.x/2,y=bed_pos.y,z=bed_pos.z+dir.z/2}
|
||||||
|
player:set_physics_override(0, 0, 0)
|
||||||
|
player:setpos(p)
|
||||||
|
default.player_attached[name] = true
|
||||||
|
hud_flags.wielditem = false
|
||||||
|
default.player_set_animation(player, "lay" , 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
player:hud_set_flags(hud_flags)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function update_formspecs(finished)
|
||||||
|
local ges = #minetest.get_connected_players()
|
||||||
|
local form_n = ""
|
||||||
|
local is_majority = (ges/2) < player_in_bed
|
||||||
|
|
||||||
|
if finished then
|
||||||
|
form_n = beds.formspec ..
|
||||||
|
"label[2.7,11; Good morning.]"
|
||||||
|
else
|
||||||
|
form_n = beds.formspec ..
|
||||||
|
"label[2.2,11;"..tostring(player_in_bed).." of "..tostring(ges).." players are in bed]"
|
||||||
|
if is_majority and is_night_skip_enabled() then
|
||||||
|
form_n = form_n ..
|
||||||
|
"button_exit[2,8;4,0.75;force;Force night skip]"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for name,_ in pairs(beds.player) do
|
||||||
|
minetest.show_formspec(name, "beds_form", form_n)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- public functions
|
||||||
|
|
||||||
|
function beds.kick_players()
|
||||||
|
for name,_ in pairs(beds.player) do
|
||||||
|
local player = minetest.get_player_by_name(name)
|
||||||
|
lay_down(player, nil, nil, false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function beds.skip_night()
|
||||||
|
minetest.set_timeofday(0.23)
|
||||||
|
beds.set_spawns()
|
||||||
|
end
|
||||||
|
|
||||||
|
function beds.on_rightclick(pos, player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local ppos = player:getpos()
|
||||||
|
local tod = minetest.get_timeofday()
|
||||||
|
|
||||||
|
if tod > 0.2 and tod < 0.805 then
|
||||||
|
if beds.player[name] then
|
||||||
|
lay_down(player, nil, nil, false)
|
||||||
|
end
|
||||||
|
minetest.chat_send_player(name, "You can only sleep at night.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- move to bed
|
||||||
|
if not beds.player[name] then
|
||||||
|
lay_down(player, ppos, pos)
|
||||||
|
else
|
||||||
|
lay_down(player, nil, nil, false)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not is_sp then
|
||||||
|
update_formspecs(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- skip the night and let all players stand up
|
||||||
|
if check_in_beds() then
|
||||||
|
minetest.after(2, function()
|
||||||
|
if not is_sp then
|
||||||
|
update_formspecs(is_night_skip_enabled())
|
||||||
|
end
|
||||||
|
if is_night_skip_enabled() then
|
||||||
|
beds.skip_night()
|
||||||
|
beds.kick_players()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- callbacks
|
||||||
|
--[[ --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)
|
||||||
|
--]]
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local pos = beds.spawn[name] or nil
|
||||||
|
if pos then
|
||||||
|
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)
|
||||||
|
beds.player[name] = nil
|
||||||
|
if check_in_beds() then
|
||||||
|
minetest.after(2, function()
|
||||||
|
update_formspecs(is_night_skip_enabled())
|
||||||
|
if is_night_skip_enabled() then
|
||||||
|
beds.skip_night()
|
||||||
|
beds.kick_players()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
if formname ~= "beds_form" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if fields.quit or fields.leave then
|
||||||
|
lay_down(player, nil, nil, false)
|
||||||
|
update_formspecs(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
if fields.force then
|
||||||
|
update_formspecs(is_night_skip_enabled())
|
||||||
|
if is_night_skip_enabled() then
|
||||||
|
beds.skip_night()
|
||||||
|
beds.kick_players()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
16
mods/beds/init.lua
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
beds = {}
|
||||||
|
beds.player = {}
|
||||||
|
beds.pos = {}
|
||||||
|
beds.spawn = {}
|
||||||
|
|
||||||
|
beds.formspec = "size[8,15;true]"..
|
||||||
|
"bgcolor[#080808BB; true]"..
|
||||||
|
"button_exit[2,12;4,0.75;leave;Leave Bed]"
|
||||||
|
|
||||||
|
local modpath = minetest.get_modpath("beds")
|
||||||
|
|
||||||
|
-- load files
|
||||||
|
dofile(modpath.."/functions.lua")
|
||||||
|
dofile(modpath.."/api.lua")
|
||||||
|
dofile(modpath.."/beds.lua")
|
||||||
|
dofile(modpath.."/spawns.lua")
|
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
|
60
mods/beds/spawns.lua
Executable file
@ -0,0 +1,60 @@
|
|||||||
|
local world_path = minetest.get_worldpath()
|
||||||
|
local org_file = world_path .. "/beds_spawns"
|
||||||
|
local file = world_path .. "/beds_spawns"
|
||||||
|
local bkwd = false
|
||||||
|
|
||||||
|
-- check for PA's beds mod spawns
|
||||||
|
local cf = io.open(world_path .. "/beds_player_spawns", "r")
|
||||||
|
if cf ~= nil then
|
||||||
|
io.close(cf)
|
||||||
|
file = world_path .. "/beds_player_spawns"
|
||||||
|
bkwd = true
|
||||||
|
end
|
||||||
|
|
||||||
|
function beds.read_spawns()
|
||||||
|
local spawns = beds.spawn
|
||||||
|
local input = io.open(file, "r")
|
||||||
|
if input and not bkwd then
|
||||||
|
repeat
|
||||||
|
local x = input:read("*n")
|
||||||
|
if x == nil then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
local y = input:read("*n")
|
||||||
|
local z = input:read("*n")
|
||||||
|
local name = input:read("*l")
|
||||||
|
spawns[name:sub(2)] = {x = x, y = y, z = z}
|
||||||
|
until input:read(0) == nil
|
||||||
|
io.close(input)
|
||||||
|
elseif input and bkwd then
|
||||||
|
beds.spawn = minetest.deserialize(input:read("*all"))
|
||||||
|
input:close()
|
||||||
|
beds.save_spawns()
|
||||||
|
os.rename(file, file .. ".backup")
|
||||||
|
file = org_file
|
||||||
|
else
|
||||||
|
spawns = {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function beds.save_spawns()
|
||||||
|
if not beds.spawn then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local output = io.open(org_file, "w")
|
||||||
|
for i, v in pairs(beds.spawn) do
|
||||||
|
output:write(v.x.." "..v.y.." "..v.z.." "..i.."\n")
|
||||||
|
end
|
||||||
|
io.close(output)
|
||||||
|
end
|
||||||
|
|
||||||
|
function beds.set_spawns()
|
||||||
|
for name,_ in pairs(beds.player) do
|
||||||
|
local player = minetest.get_player_by_name(name)
|
||||||
|
local p = player:getpos()
|
||||||
|
beds.spawn[name] = p
|
||||||
|
end
|
||||||
|
beds.save_spawns()
|
||||||
|
end
|
||||||
|
|
||||||
|
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 |
BIN
mods/beds/textures/beds_bed_fancy_red.png
Executable file
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 |
BIN
mods/beds/textures/beds_bed_foot_red.png
Executable file
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
Executable file
After Width: | Height: | Size: 347 B |
BIN
mods/beds/textures/beds_bed_red.png
Executable file
After Width: | Height: | Size: 540 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 |
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 |
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 |
BIN
mods/beds/textures/beds_bed_side_bottom_r_red.png
Executable file
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
Executable file
After Width: | Height: | Size: 574 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 |
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 |
BIN
mods/beds/textures/beds_bed_top2_red.png
Executable file
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 |
BIN
mods/beds/textures/beds_bed_top_bottom_red.png
Executable file
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 |
BIN
mods/beds/textures/beds_bed_top_top_red.png
Executable file
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
Executable file
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 |
6
mods/boats/README.txt
Normal file → Executable file
@ -1,6 +1,6 @@
|
|||||||
Minetest 0.4 mod: boats
|
Minetest Game mod: boats
|
||||||
=======================
|
========================
|
||||||
by PilzAdam, slightly modified for NeXt
|
by PilzAdam
|
||||||
|
|
||||||
License of source code:
|
License of source code:
|
||||||
-----------------------
|
-----------------------
|
||||||
|
0
mods/boats/depends.txt
Normal file → Executable file
@ -1,14 +1,15 @@
|
|||||||
|
|
||||||
--
|
--
|
||||||
-- 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
|
||||||
|
|
||||||
local function get_sign(i)
|
function boats.get_sign(i)
|
||||||
if i == 0 then
|
if i == 0 then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
@ -16,34 +17,17 @@ local function get_sign(i)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_velocity(v, yaw, y)
|
function boats.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
|
||||||
|
|
||||||
local function get_v(v)
|
function boats.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.6,-0.4,-0.6, 0.6,0.3,0.6},
|
|
||||||
visual = "mesh",
|
|
||||||
mesh = "boat.x",
|
|
||||||
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
|
||||||
@ -53,7 +37,21 @@ function boat.on_rightclick(self, clicker)
|
|||||||
clicker:set_detach()
|
clicker:set_detach()
|
||||||
default.player_attached[name] = false
|
default.player_attached[name] = false
|
||||||
default.player_set_animation(clicker, "stand" , 30)
|
default.player_set_animation(clicker, "stand" , 30)
|
||||||
|
local pos = clicker:getpos()
|
||||||
|
pos = {x = pos.x, y = pos.y + 0.2, z = pos.z}
|
||||||
|
minetest.after(0.1, function()
|
||||||
|
clicker:setpos(pos)
|
||||||
|
end)
|
||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
|
local attach = clicker:get_attach()
|
||||||
|
if attach and attach:get_luaentity() then
|
||||||
|
local luaentity = attach:get_luaentity()
|
||||||
|
if luaentity.driver then
|
||||||
|
luaentity.driver = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
clicker:set_detach()
|
||||||
|
end
|
||||||
self.driver = clicker
|
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
|
default.player_attached[name] = true
|
||||||
@ -62,9 +60,9 @@ function boat.on_rightclick(self, clicker)
|
|||||||
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)
|
||||||
@ -72,99 +70,117 @@ function boat.on_activate(self, staticdata, dtime_s)
|
|||||||
self.last_v = self.v
|
self.last_v = self.v
|
||||||
end
|
end
|
||||||
|
|
||||||
function boat.get_staticdata()
|
|
||||||
return tostring(v)
|
function boats.get_staticdata(self)
|
||||||
|
return tostring(self.v)
|
||||||
end
|
end
|
||||||
|
|
||||||
function boat.on_punch(self, puncher, time_from_last_punch, tool_capabilities, direction)
|
|
||||||
|
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
|
||||||
|
if self.driver and puncher == self.driver then
|
||||||
|
self.driver = nil
|
||||||
puncher:set_detach()
|
puncher:set_detach()
|
||||||
default.player_attached[puncher:get_player_name()] = false
|
default.player_attached[puncher:get_player_name()] = false
|
||||||
|
end
|
||||||
|
if not self.driver then
|
||||||
self.removed = true
|
self.removed = true
|
||||||
-- delay remove to ensure player is detached
|
-- delay remove to ensure player is detached
|
||||||
minetest.after(0.1, function()
|
minetest.after(0.1, function()
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
end)
|
end)
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
puncher:get_inventory():add_item("main", "boats:boat")
|
local inv = puncher:get_inventory()
|
||||||
|
if inv:room_for_item("main", "boats:" .. self.parameters.name) then
|
||||||
|
inv:add_item("main", "boats:" .. self.parameters.name)
|
||||||
|
else
|
||||||
|
minetest.add_item(self.object:getpos(), "boats:" .. self.parameters.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function boat.on_step(self, dtime)
|
function boats.on_step(self, dtime)
|
||||||
self.v = get_v(self.object:getvelocity())*get_sign(self.v)
|
self.v = boats.get_v(self.object:getvelocity()) * boats.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
|
||||||
end
|
elseif ctrl.down then
|
||||||
if ctrl.down then
|
self.v = self.v - self.parameters.controls.down or 0.08
|
||||||
self.v = self.v-0.08
|
|
||||||
end
|
end
|
||||||
if ctrl.left then
|
if ctrl.left then
|
||||||
if ctrl.down then
|
if self.v < 0 then
|
||||||
self.object:setyaw(yaw-math.pi/120-dtime*math.pi/120)
|
self.object:setyaw(yaw - (1 + dtime) * (0.03 * (self.parameters.controls.rotate or 1)))
|
||||||
else
|
else
|
||||||
self.object:setyaw(yaw+math.pi/120+dtime*math.pi/120)
|
self.object:setyaw(yaw + (1 + dtime) * (0.03 * (self.parameters.controls.rotate or 1)))
|
||||||
end
|
end
|
||||||
end
|
elseif ctrl.right then
|
||||||
if ctrl.right then
|
if self.v < 0 then
|
||||||
if ctrl.down then
|
self.object:setyaw(yaw + (1 + dtime) * (0.03 * (self.parameters.controls.rotate or 1)))
|
||||||
self.object:setyaw(yaw+math.pi/120+dtime*math.pi/120)
|
|
||||||
else
|
else
|
||||||
self.object:setyaw(yaw-math.pi/120-dtime*math.pi/120)
|
self.object:setyaw(yaw - (1 + dtime) * (0.03 * (self.parameters.controls.rotate or 1)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local velo = self.object:getvelocity()
|
local velo = self.object:getvelocity()
|
||||||
if self.v == 0 and velo.x == 0 and velo.z == 0 then
|
if self.v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
||||||
|
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) > 4.5 then
|
if math.abs(self.v) > 4.5 then
|
||||||
self.v = 4.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
|
||||||
if minetest.registered_nodes[minetest.env:get_node(p).name].walkable then
|
local nodedef = minetest.registered_nodes[minetest.get_node(p).name]
|
||||||
|
if (not nodedef) or nodedef.walkable then
|
||||||
self.v = 0
|
self.v = 0
|
||||||
|
new_acce = {x = 0, y = 1, z = 0}
|
||||||
|
else
|
||||||
|
new_acce = {x = 0, y = -9.8, z = 0} -- freefall in air -9.81
|
||||||
end
|
end
|
||||||
new_acce = {x=0, y=-10, z=0}
|
new_velo = boats.get_velocity(self.v, self.object:getyaw(),
|
||||||
new_velo = get_velocity(self.v, self.object:getyaw(), self.object:getvelocity().y)
|
self.object:getvelocity().y)
|
||||||
|
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
|
||||||
new_acce = {x=0, y=3, z=0}
|
|
||||||
local y = self.object:getvelocity().y
|
local y = self.object:getvelocity().y
|
||||||
if y > 2 then
|
if y >= 4.5 then
|
||||||
y = 2
|
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
|
end
|
||||||
if y < 0 then
|
new_velo = boats.get_velocity(self.v, self.object:getyaw(), y)
|
||||||
self.object:setacceleration({x=0, y=10, z=0})
|
self.object:setpos(self.object:getpos())
|
||||||
end
|
|
||||||
new_velo = get_velocity(self.v, self.object:getyaw(), y)
|
|
||||||
else
|
else
|
||||||
new_acce = {x = 0, y = 0, z = 0}
|
new_acce = {x = 0, y = 0, z = 0}
|
||||||
if math.abs(self.object:getvelocity().y) < 1 then
|
if math.abs(self.object:getvelocity().y) < 1 then
|
||||||
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(), self.object:getvelocity().y)
|
new_velo = boats.get_velocity(self.v, self.object:getyaw(),
|
||||||
|
self.object:getvelocity().y)
|
||||||
|
self.object:setpos(self.object:getpos())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -172,13 +188,31 @@ function boat.on_step(self, dtime)
|
|||||||
self.object:setacceleration(new_acce)
|
self.object:setacceleration(new_acce)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_entity("boats:boat", boat)
|
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"},
|
||||||
|
|
||||||
|
parameters = parameters,
|
||||||
|
driver = nil,
|
||||||
|
v = 0,
|
||||||
|
last_v = 0,
|
||||||
|
removed = false,
|
||||||
|
|
||||||
minetest.register_craftitem("boats:boat", {
|
on_rightclick = boats.on_rightclick,
|
||||||
description = "Boat",
|
on_activate = boats.on_activate,
|
||||||
inventory_image = "boat_inventory.png",
|
get_staticdata = boats.get_staticdata,
|
||||||
wield_image = "boat_wield.png",
|
on_punch = boats.on_punch,
|
||||||
|
on_step = boats.on_step
|
||||||
|
})
|
||||||
|
|
||||||
|
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},
|
wield_scale = {x = 2, y = 2, z = 1},
|
||||||
liquids_pointable = true,
|
liquids_pointable = true,
|
||||||
|
|
||||||
@ -186,17 +220,110 @@ 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({
|
||||||
output = "boats:boat",
|
output = "boats:boat",
|
||||||
|
3111
mods/boats/models/boat.obj
Executable file
11110
mods/boats/models/boat.x
0
mods/boats/textures/boat_inventory.png → mods/boats/textures/boats_boat_inventory.png
Normal file → Executable file
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
0
mods/boats/textures/boat_wield.png → mods/boats/textures/boats_boat_wield.png
Normal file → Executable file
Before Width: | Height: | Size: 847 B After Width: | Height: | Size: 847 B |
BIN
mods/boats/textures/boats_expert_race_inventory.png
Executable file
After Width: | Height: | Size: 1.4 KiB |