Compare commits
119 Commits
stable-5.2
...
stable-4.0
Author | SHA1 | Date | |
---|---|---|---|
|
a1ab186c6e | ||
451b2994fe | |||
60ac7cccc9 | |||
77484db3a4 | |||
10e85eb910 | |||
46ce26ded2 | |||
99e163dd82 | |||
b2b66a6fa7 | |||
6ed6ce1317 | |||
d0edf57d46 | |||
55189a57f8 | |||
da0cad8af7 | |||
4901df3c95 | |||
c2c28d5e2a | |||
ddfec19a2b | |||
a3a271b21f | |||
a110849017 | |||
23eb8437f4 | |||
d77ba194d4 | |||
a6073f034d | |||
2de5aaeeff | |||
a3f7816526 | |||
918bb6e8bb | |||
|
b4c29033c9 | ||
fd5ca024e6 | |||
336ce1c8db | |||
8196401ab8 | |||
c624fef6f3 | |||
9836d04755 | |||
ee13c9f46a | |||
ea2069d30e | |||
1624147edc | |||
f208b6312d | |||
ae8c3f8eba | |||
729e344fc8 | |||
8e59006dc8 | |||
284eb28d6c | |||
901fb492c1 | |||
13a6891758 | |||
dab09dfd32 | |||
ebdf4427d3 | |||
4a9e24b2f2 | |||
aa9f63cb3f | |||
115c85ce40 | |||
00bad47eed | |||
c23219729c | |||
07d4778ffb | |||
d82008a256 | |||
e02a31343a | |||
36427dada6 | |||
b6d93e76d3 | |||
812bb323f6 | |||
d18f9b4251 | |||
574d6cc65c | |||
b1440d887d | |||
2f97407591 | |||
c7cb79422b | |||
c23bd322f7 | |||
18aed0219b | |||
f1e7172fe1 | |||
|
74702c6ada | ||
|
d37c1d2312 | ||
be96530e20 | |||
|
535204298e | ||
657f7cee6e | |||
95e70da3a6 | |||
e07ad71d11 | |||
|
9cf3c953f1 | ||
|
4a1fc02e82 | ||
2b6de659cb | |||
|
aa7f6cd060 | ||
|
fb610ffa59 | ||
|
fea78bdf54 | ||
|
d6a66860af | ||
|
6d850f23a5 | ||
|
2c1af0861f | ||
|
d2ae721235 | ||
|
01db55cee5 | ||
|
4ba2b5179e | ||
|
a5092c0df6 | ||
|
575c098bae | ||
|
cddd59b578 | ||
|
7a4b1e0ce1 | ||
|
0216fa08ec | ||
|
ca3e807d35 | ||
|
ca38bb2390 | ||
|
7d07c52d09 | ||
|
532013a032 | ||
|
a52622669f | ||
|
ce5e668681 | ||
|
6530fa914b | ||
|
86eb0e1617 | ||
|
93fb9b36ce | ||
|
09e3505ea1 | ||
|
cecbfc1676 | ||
|
fba6f6a4cf | ||
|
6053456af1 | ||
|
cc2f75b2f9 | ||
|
b6ef71c92e | ||
|
876da2fbc6 | ||
|
ea45ca57a5 | ||
|
6fa3ebfa75 | ||
|
efe6fb6dfb | ||
|
1aeb2baa91 | ||
|
e4d6425846 | ||
|
81f885795d | ||
|
f3e29bc2cc | ||
|
3a72f7b84b | ||
|
20bd4560f8 | ||
|
8991b9fe54 | ||
|
aea6c5dd1d | ||
|
da41caca66 | ||
|
103af98864 | ||
|
26606b0520 | ||
|
706844e8bf | ||
|
a56274c230 | ||
|
3512226867 | ||
|
d5b9fee6fe | ||
|
437860feff |
@ -12,6 +12,7 @@ Copyright (C) 2015 paramat CC BY-SA 3.0
|
||||
|
||||
License of source code
|
||||
----------------------
|
||||
Copyright (C) 2010-2012 Blockmen
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
See README.txt in each mod directory for information about other authors.
|
||||
|
||||
|
63
README.md
Normal file
@ -0,0 +1,63 @@
|
||||
Minetest4 Game
|
||||
==============
|
||||
|
||||
The default game for the Minetest4 engine.
|
||||
|
||||
This is a fork from minetest default game, this
|
||||
are made from minenux project https://codeberg.org/minenux
|
||||
for minetest v4 and minetest v5 or 5.X releases.
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
This is the branch `stable-4.0` of minetest game for minetest4 a version
|
||||
that is focused in v4 of minetest but mainly in 0.4 release. There's
|
||||
also a minetest5 game version too in `stable-5.2` branch.
|
||||
|
||||
This are focused to provide minimal default game featured for minetest4
|
||||
to be playable, with an [api](game_api.md) for more aditions (in the form of mods)
|
||||
|
||||
For further information, check the [Minetest Wiki](https://wiki.minetest.org/index.php?title=Games/Minetest_Game)
|
||||
|
||||
## Download
|
||||
|
||||
Can be obtained from https://codeberg.org/minenux/minetest-game-minetest/tags
|
||||
those like 4.0.17 by example https://codeberg.org/minenux/minetest-game-minetest/releases/tag/4.0.17
|
||||
|
||||
It will download a tar.gz file, uncompress the content and a directory will be created,
|
||||
the name of the directory does not matter, the contents will be used later to install.
|
||||
|
||||
When stable releases are made, Minetest Game and the Minetest engine is packaged
|
||||
and made available at https://codeberg.org/minenux/minetest-engine/archive/stable-4.0.tar.gz
|
||||
or generally at https://codeberg.org/minenux/minetest-engine/releases/tag/4.0.17 by example.
|
||||
|
||||
This have a mirror at https://git.minetest.org/minenux/minetest-game-minetest/releases
|
||||
|
||||
## Installation
|
||||
|
||||
This game can be used in any version from 0.4.15 to 5.1, it may work with recent version but with issues
|
||||
|
||||
After download, rename the directory decompressed to `minetest_game` and put to the "games" directory:
|
||||
|
||||
- GNU/Linux: If you use a system-wide installation place
|
||||
it in ~/.minetest4/games/.
|
||||
- Others: `minetest/games/` or `games` directory from the path were the binary are.
|
||||
|
||||
For further information or help, see: https://wiki.minetest.net/Installing_Mods
|
||||
|
||||
## Content
|
||||
|
||||
This sub game or game will contain a set of mods, that provide a behaviour of the game,
|
||||
For more information check [mods/README.md](mods/README.md)
|
||||
|
||||
## Compatibility
|
||||
|
||||
This source code and files are focused in most olders minetest4 engine or 0.4.X ones
|
||||
from https://codeberg.org/minenux/minetest-engine/src/branch/stable-4.0
|
||||
|
||||
For minetest5 check https://codeberg.org/minenux/minetest-engine/src/branch/stable-5.2
|
||||
|
||||
## Licensing
|
||||
|
||||
See `LICENSE.txt`, Blockmen was the original and fisrt person to provide this set game.
|
||||
|
99
README.txt
@ -1,28 +1,85 @@
|
||||
Minetest Game [minetest_game]
|
||||
=============================
|
||||
The main subgame for the Minetest engine
|
||||
========================================
|
||||
Minetest4 Game
|
||||
==============
|
||||
|
||||
To use this subgame with the Minetest engine, insert this repository as
|
||||
/games/minetest_game
|
||||
The default game for the Minetest4 engine.
|
||||
|
||||
The Minetest engine can be found in:
|
||||
https://github.com/minetest/minetest/
|
||||
This is a fork from minetest default game, this
|
||||
are made from minenux project https://codeberg.org/minenux
|
||||
for minetest v5 and minetest v4 or 0.4.
|
||||
|
||||
Compatibility
|
||||
--------------
|
||||
The Minetest Game github master HEAD is generally compatible with the github
|
||||
master HEAD of the Minetest engine.
|
||||
Introduction
|
||||
------------
|
||||
|
||||
Additionally, when the Minetest engine is tagged to be a certain version (eg.
|
||||
0.4.10), Minetest Game is tagged with the version too.
|
||||
This is the branch `stable-4.0` of minetest game for minetest4 a version
|
||||
that is focused in v5 of minetest but mainly in 4.0 release. There's
|
||||
also a minetest4 game version too in `stable-4.0` branch.
|
||||
|
||||
When stable releases are made, Minetest Game is packaged and made available in
|
||||
http://minetest.net/download
|
||||
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 are focused to provide minimal default game featured for minetest4
|
||||
to be playable, with an [api](game_api.md) for more aditions (in the form of mods)
|
||||
|
||||
Licensing
|
||||
---------
|
||||
For further information, check the [Minetest Wiki](https://wiki.minetest.net/Subgames/Minetest_Game)
|
||||
|
||||
See LICENSE.txt
|
||||
## Download
|
||||
|
||||
Can be obtained from https://codeberg.org/minenux/minetest-game-minetest/tags
|
||||
those like 4.0.X by example https://codeberg.org/minenux/minetest-game-minetest/releases/tag/4.0.17
|
||||
|
||||
It will download a tar.gz file, uncompress the content and a directory will be created,
|
||||
the name of the directory does not matter, the contents will be used later to install.
|
||||
|
||||
When stable releases are made, Minetest Game and the Minetest engine is packaged
|
||||
and made available at https://codeberg.org/minenux/minetest-engine/archive/stable-4.0.tar.gz
|
||||
or generally at https://codeberg.org/minenux/minetest-engine/releases/tag/4.0.17 by example.
|
||||
|
||||
## Installation
|
||||
|
||||
This game can be used in any version from 5.0 to 4.0, it may work with 5.3 but not with 5.5
|
||||
|
||||
After download, rename the directory decompressed to `minetest_game` and put to the "games" directory:
|
||||
|
||||
- GNU/Linux: If you use a system-wide installation place
|
||||
it in ~/.minetest4/games/.
|
||||
- Others: `minetest/games/` or `games` directory from the path were the binary are.
|
||||
|
||||
For further information or help, see: https://wiki.minetest.net/Installing_Mods
|
||||
|
||||
## Content
|
||||
|
||||
* api
|
||||
* beds
|
||||
* bucket
|
||||
* bones
|
||||
* boats
|
||||
* creative
|
||||
* default
|
||||
* doors
|
||||
* farming
|
||||
* fire
|
||||
* give_initial_stuff
|
||||
* stairs
|
||||
* carts
|
||||
* dye
|
||||
* flowers
|
||||
* screwdriver
|
||||
* tnt
|
||||
* xpanes
|
||||
* sfinv
|
||||
* vessels
|
||||
* walls
|
||||
* wool
|
||||
|
||||
The default mod provides sethome and player_api call ones, binoculars from v5 are
|
||||
just separate privilegies for zoom, butterflies and fireflies from v5 can be set
|
||||
by dmobs or mobs_doomed mod, the spawn mod is just minimal spawn management
|
||||
pooly provided and better managed by mods like rspawn and spawnrandom.
|
||||
|
||||
## Compatibility
|
||||
|
||||
This source code and files are only compatible with matched minetest4 engine
|
||||
from https://codeberg.org/minenux/minetest-engine/src/branch/stable-4.0
|
||||
Additionally, when the Minetest4 engine is tagged to be a certain version (e.g.
|
||||
4.0.17), Minetest Game is tagged with the version 4.0.17 too.
|
||||
|
||||
## Licensing
|
||||
|
||||
See `LICENSE.txt`
|
||||
|
@ -1 +1,6 @@
|
||||
name = Minetest Game
|
||||
name = Minetest4
|
||||
title = Minetest4
|
||||
author = Blockmen
|
||||
description = MinenuX game bundled default with Minetest4
|
||||
min_minetest_version = 0.4.15
|
||||
max_minetest_version = 5.1
|
962
game_api.md
Normal file
@ -0,0 +1,962 @@
|
||||
Minetest Game API
|
||||
=================
|
||||
|
||||
This is a fork of the original one at https://github.com/minetest/minetest_game
|
||||
For more information about fork check [Differences](#differences) section.
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
The Minetest4 Game game 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 Minetest4 API, visit https://codeberg.org/minenux/minetest-engine-minetest/src/branch/stable-4.0/doc/lua_api.txt
|
||||
Please note:
|
||||
|
||||
* [XYZ] refers to a section the Minetest API
|
||||
* [#ABC] refers to a section in this document
|
||||
* [pos] refers to a position table `{x = -5, y = 0, z = 200}`
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Bucket API](#bucket-api)
|
||||
- [Beds API](#beds-api)
|
||||
- [Bed definition](#bed-definition)
|
||||
- [Creative API](#creative-api)
|
||||
- [Doors API](#doors-api)
|
||||
- [Methods](#methods)
|
||||
- [Door definition](#door-definition)
|
||||
- [Trapdoor definition](#trapdoor-definition)
|
||||
- [Fence gate definition](#fence-gate-definition)
|
||||
- [Fence API](#fence-api)
|
||||
- [fence definition](#fence-definition)
|
||||
- [Walls API](#walls-api)
|
||||
- [Farming API](#farming-api)
|
||||
- [Hoe Definition](#hoe-definition)
|
||||
- [Plant definition](#plant-definition)
|
||||
- [Fire API](#fire-api)
|
||||
- [Give Initial Stuff API](#give-initial-stuff-api)
|
||||
- [TNT API](#tnt-api)
|
||||
- [Screwdriver API](#screwdriver-api)
|
||||
- [Sethome API](#sethome-api)
|
||||
- [Sfinv API](#sfinv-api)
|
||||
- [sfinv Methods](#sfinv-methods)
|
||||
- [sfinv Members](#sfinv-members)
|
||||
- [Context](#context)
|
||||
- [sfinv.register_page](#sfinvregister_page)
|
||||
- [get formspec](#get-formspec)
|
||||
- [Customising themes](#customising-themes)
|
||||
- [Stairs API](#stairs-api)
|
||||
- [Xpanes API](#xpanes-api)
|
||||
- [Pane definition](#pane-definition)
|
||||
- [Raillike definitions](#raillike-definitions)
|
||||
- [Default sounds](#default-sounds)
|
||||
- [Default constants](#default-constants)
|
||||
- [Player API](#player-api)
|
||||
- [Model Definition](#model-definition)
|
||||
- [Leafdecay](#leafdecay)
|
||||
- [Dyes](#dyes)
|
||||
- [Color groups](#color-groups)
|
||||
- [Color lists](#color-lists)
|
||||
- [Trees](#trees)
|
||||
- [Carts](#carts)
|
||||
- [Key API](#key-api)
|
||||
|
||||
|
||||
Bucket API
|
||||
----------
|
||||
|
||||
The bucket API allows registering new types of buckets for non-default liquids.
|
||||
|
||||
bucket.register_liquid(
|
||||
"default:lava_source", -- name of the source node
|
||||
"default:lava_flowing", -- name of the flowing node
|
||||
"bucket:bucket_lava", -- name of the new bucket item (or nil if liquid is not takeable)
|
||||
"bucket_lava.png", -- texture of the new bucket item (ignored if itemname == nil)
|
||||
"Lava Bucket", -- text description of the bucket item
|
||||
{lava_bucket = 1}, -- groups of the bucket item, OPTIONAL
|
||||
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
|
||||
------------
|
||||
|
||||
Use `creative.register_tab(name, title, items)` to add a tab with filtered items.
|
||||
For example,
|
||||
|
||||
creative.register_tab("tools", "Tools", minetest.registered_tools)
|
||||
|
||||
is used to show all tools. Name is used in the sfinv page name, title is the
|
||||
human readable title.
|
||||
|
||||
`is_enabled_for` is used to check whether a player is in creative mode:
|
||||
|
||||
creative.is_enabled_for(name)
|
||||
|
||||
Override this to allow per-player game modes.
|
||||
|
||||
The contents of `creative.formspec_add` is appended to every creative inventory
|
||||
page. Mods can use it to add additional formspec elements onto the default
|
||||
creative inventory formspec to be drawn after each update.
|
||||
|
||||
Doors API
|
||||
---------
|
||||
|
||||
The doors mod allows modders to register custom doors and trapdoors.
|
||||
|
||||
`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
|
||||
|
||||
description = "Door description",
|
||||
inventory_image = "mod_door_inv.png",
|
||||
groups = {choppy = 2},
|
||||
tiles = {"mod_door.png"}, -- UV map.
|
||||
recipe = craftrecipe,
|
||||
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)
|
||||
|
||||
### Trapdoor definition
|
||||
|
||||
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", -- `backface_culling` will automatically be
|
||||
-- set to `true` if not specified.
|
||||
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
|
||||
-----------
|
||||
|
||||
The farming API allows you to easily register plants and hoes.
|
||||
|
||||
`farming.register_hoe(name, 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
|
||||
|
||||
|
||||
{
|
||||
description = "", -- Description for tooltip
|
||||
inventory_image = "unknown_item.png", -- Image to be used as wield- and inventory image
|
||||
max_uses = 30, -- Uses until destroyed
|
||||
material = "", -- Material for recipes
|
||||
recipe = { -- Craft recipe, if material isn't used
|
||||
{"air", "air", "air"},
|
||||
{"", "group:stick"},
|
||||
{"", "group:stick"},
|
||||
}
|
||||
}
|
||||
|
||||
### Plant definition
|
||||
|
||||
{
|
||||
description = "", -- Description of seed item
|
||||
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
|
||||
-- ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber)
|
||||
minlight = 13, -- Minimum 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
|
||||
|
||||
|
||||
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` with the following addition:
|
||||
* `explode_center` false by default which removes TNT node on blast, when true will explode center node.
|
||||
|
||||
`tnt.burn(position, [nodename])`
|
||||
|
||||
^ Ignite node at position, triggering its `on_ignite` callback (see fire mod).
|
||||
If no such callback exists, fallback to turn tnt group nodes to their
|
||||
"_burning" variant.
|
||||
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
|
||||
|
||||
|
||||
Sfinv API
|
||||
---------
|
||||
|
||||
### sfinv Methods
|
||||
|
||||
**Pages**
|
||||
|
||||
* sfinv.set_page(player, pagename) - changes the page
|
||||
* sfinv.get_homepage_name(player) - get the page name of the first page to show to a player
|
||||
* sfinv.register_page(name, def) - register a page, see section below
|
||||
* sfinv.override_page(name, def) - overrides fields of an page registered with register_page.
|
||||
* Note: Page must already be defined, (opt)depend on the mod defining it.
|
||||
* sfinv.set_player_inventory_formspec(player) - (re)builds page formspec
|
||||
and calls set_inventory_formspec().
|
||||
* sfinv.get_formspec(player, context) - builds current page's formspec
|
||||
|
||||
**Contexts**
|
||||
|
||||
* sfinv.get_or_create_context(player) - gets the player's context
|
||||
* sfinv.set_context(player, context)
|
||||
|
||||
**Theming**
|
||||
|
||||
* sfinv.make_formspec(player, context, content, show_inv, size) - adds a theme to a formspec
|
||||
* show_inv, defaults to false. Whether to show the player's main inventory
|
||||
* size, defaults to `size[8,8.6]` if not specified
|
||||
* sfinv.get_nav_fs(player, context, nav, current_idx) - creates tabheader or ""
|
||||
|
||||
### sfinv Members
|
||||
|
||||
* pages - table of pages[pagename] = def
|
||||
* pages_unordered - array table of pages in order of addition (used to build navigation tabs).
|
||||
* contexts - contexts[playername] = player_context
|
||||
* enabled - set to false to disable. Good for inventory rehaul mods like unified inventory
|
||||
|
||||
### Context
|
||||
|
||||
A table with these keys:
|
||||
|
||||
* page - current page name
|
||||
* nav - a list of page names
|
||||
* nav_titles - a list of page titles
|
||||
* nav_idx - current nav index (in nav and nav_titles)
|
||||
* any thing you want to store
|
||||
* sfinv will clear the stored data on log out / log in
|
||||
|
||||
### sfinv.register_page
|
||||
|
||||
sfinv.register_page(name, def)
|
||||
|
||||
def is a table containing:
|
||||
|
||||
* `title` - human readable page name (required)
|
||||
* `get(self, player, context)` - returns a formspec string. See formspec variables. (required)
|
||||
* `is_in_nav(self, player, context)` - return true to show in the navigation (the tab header, by default)
|
||||
* `on_player_receive_fields(self, player, context, fields)` - on formspec submit.
|
||||
* `on_enter(self, player, context)` - called when the player changes pages, usually using the tabs.
|
||||
* `on_leave(self, player, context)` - when leaving this page to go to another, called before other's on_enter
|
||||
|
||||
### get formspec
|
||||
|
||||
Use sfinv.make_formspec to apply a layout:
|
||||
|
||||
return sfinv.make_formspec(player, context, [[
|
||||
list[current_player;craft;1.75,0.5;3,3;]
|
||||
list[current_player;craftpreview;5.75,1.5;1,1;]
|
||||
image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]
|
||||
listring[current_player;main]
|
||||
listring[current_player;craft]
|
||||
image[0,4.25;1,1;gui_hb_bg.png]
|
||||
image[1,4.25;1,1;gui_hb_bg.png]
|
||||
image[2,4.25;1,1;gui_hb_bg.png]
|
||||
image[3,4.25;1,1;gui_hb_bg.png]
|
||||
image[4,4.25;1,1;gui_hb_bg.png]
|
||||
image[5,4.25;1,1;gui_hb_bg.png]
|
||||
image[6,4.25;1,1;gui_hb_bg.png]
|
||||
image[7,4.25;1,1;gui_hb_bg.png]
|
||||
]], true)
|
||||
|
||||
See above (methods section) for more options.
|
||||
|
||||
### Customising themes
|
||||
|
||||
Simply override this function to change the navigation:
|
||||
|
||||
function sfinv.get_nav_fs(player, context, nav, current_idx)
|
||||
return "navformspec"
|
||||
end
|
||||
|
||||
And override this function to change the layout:
|
||||
|
||||
function sfinv.make_formspec(player, context, content, show_inv, size)
|
||||
local tmp = {
|
||||
size or "size[8,8.6]",
|
||||
theme_main,
|
||||
sfinv.get_nav_fs(player, context, context.nav_titles, context.nav_idx),
|
||||
content
|
||||
}
|
||||
if show_inv then
|
||||
tmp[4] = theme_inv
|
||||
end
|
||||
return table.concat(tmp, "")
|
||||
end
|
||||
|
||||
Stairs API
|
||||
----------
|
||||
|
||||
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.
|
||||
|
||||
`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", may be `nil`
|
||||
* `groups`: see [Known damage and digging time defining groups]
|
||||
* `images`: see [Tile definition]
|
||||
* `description`: used for the description field in the stair's definition
|
||||
* `sounds`: see [#Default sounds]
|
||||
|
||||
`stairs.register_slab(subname, recipeitem, groups, images, description, sounds)`
|
||||
|
||||
* Registers a slabs
|
||||
* `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_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
|
||||
----------
|
||||
|
||||
Creates panes that automatically connect to each other
|
||||
|
||||
`xpanes.register_pane(subname, def)`
|
||||
|
||||
* `subname`: used for nodename. Result: "xpanes:subname" and "xpanes:subname_{2..15}"
|
||||
* `def`: See [#Pane definition]
|
||||
|
||||
### Pane definition
|
||||
|
||||
{
|
||||
textures = {"texture for sides", (unused), "texture for top and bottom"}, -- More tiles aren't supported
|
||||
groups = {group = rating}, -- Uses the known node groups, see [Known damage and digging time defining groups]
|
||||
sounds = SoundSpec, -- See [#Default sounds]
|
||||
recipe = {{"","","","","","","","",""}}, -- Recipe field only
|
||||
}
|
||||
|
||||
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
|
||||
--------------
|
||||
|
||||
Sounds inside the default table can be used within the sounds field of node definitions.
|
||||
|
||||
* `default.node_sound_defaults()`
|
||||
* `default.node_sound_stone_defaults()`
|
||||
* `default.node_sound_dirt_defaults()`
|
||||
* `default.node_sound_sand_defaults()`
|
||||
* `default.node_sound_wood_defaults()`
|
||||
* `default.node_sound_leaves_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
|
||||
----------
|
||||
|
||||
The player API can register player models and update the player's appearence
|
||||
|
||||
`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]`
|
||||
|
||||
* Get a model's definition
|
||||
* see [#Model definition]
|
||||
|
||||
`default.player_set_model(player, model_name)`
|
||||
|
||||
* Change a player's model
|
||||
* `player`: PlayerRef
|
||||
* `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)
|
||||
|
||||
* 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.
|
||||
textures = {"character.png", }, -- Default array of textures.
|
||||
visual_size = {x = 1, y = 1}, -- Used to scale the model.
|
||||
animations = {
|
||||
-- <anim_name> = {x = <start_frame>, y = <end_frame>},
|
||||
foo = {x = 0, y = 19},
|
||||
bar = {x = 20, y = 39},
|
||||
-- ...
|
||||
},
|
||||
eye_height = 1.47, -- In nodes above feet position
|
||||
}
|
||||
|
||||
Leafdecay
|
||||
---------
|
||||
|
||||
To enable leaf decay for leaves when a tree is cut down by a player,
|
||||
register the tree with the default.register_leafdecay(leafdecaydef)
|
||||
function.
|
||||
|
||||
If `param2` of any registered 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.
|
||||
|
||||
`default.register_leafdecay(leafdecaydef)`
|
||||
|
||||
`leafdecaydef` is a table, with following members:
|
||||
{
|
||||
trunks = {"default:tree"}, -- nodes considered trunks
|
||||
leaves = {"default:leaves", "default:apple"},
|
||||
-- nodes considered for removal
|
||||
radius = 3, -- radius to consider for searching
|
||||
}
|
||||
|
||||
Note: all the listed nodes in `trunks` have their `on_after_destruct`
|
||||
callback overridden. All the nodes listed in `leaves` have their
|
||||
`on_timer` callback overridden.
|
||||
|
||||
|
||||
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_snowy_pine_tree(pos)`
|
||||
* Grows a new design snowy 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_bush(pos)`
|
||||
* Grows a bush at pos
|
||||
|
||||
* `default.grow_acacia_bush(pos)`
|
||||
* Grows an acaia bush at pos
|
||||
|
||||
Carts
|
||||
-----
|
||||
|
||||
carts.register_rail(
|
||||
"mycarts:myrail", -- Rail name
|
||||
nodedef, -- standard nodedef
|
||||
railparams -- rail parameter struct (optional)
|
||||
)
|
||||
|
||||
railparams = {
|
||||
on_step(obj, dtime), -- Event handler called when
|
||||
-- cart is on rail
|
||||
acceleration, -- integer acceleration factor (negative
|
||||
-- values to brake)
|
||||
}
|
||||
|
||||
The event handler is called after all default calculations
|
||||
are made, so the custom on_step handler can override things
|
||||
like speed, acceleration, player attachment. The handler will
|
||||
likely be called many times per second, so the function needs
|
||||
to make sure that the event is handled properly.
|
||||
|
||||
Key API
|
||||
-------
|
||||
|
||||
The key API allows mods to add key functionality to nodes that have
|
||||
ownership or specific permissions. Using the API will make it so
|
||||
that a node owner can use skeleton keys on their nodes to create keys
|
||||
for that node in that location, and give that key to other players,
|
||||
allowing them some sort of access that they otherwise would not have
|
||||
due to node protection.
|
||||
|
||||
To make your new nodes work with the key API, you need to register
|
||||
two callback functions in each nodedef:
|
||||
|
||||
|
||||
`on_key_use(pos, player)`
|
||||
* Is called when a player right-clicks (uses) a normal key on your
|
||||
* node.
|
||||
* `pos` - position of the node
|
||||
* `player` - PlayerRef
|
||||
* return value: none, ignored
|
||||
|
||||
The `on_key_use` callback should validate that the player is wielding
|
||||
a key item with the right key meta secret. If needed the code should
|
||||
deny access to the node functionality.
|
||||
|
||||
If formspecs are used, the formspec callbacks should duplicate these
|
||||
checks in the metadata callback functions.
|
||||
|
||||
|
||||
`on_skeleton_key_use(pos, player, newsecret)`
|
||||
|
||||
* Is called when a player right-clicks (uses) a skeleton key on your
|
||||
* node.
|
||||
* `pos` - position of the node
|
||||
* `player` - PlayerRef
|
||||
* `newsecret` - a secret value(string)
|
||||
* return values:
|
||||
* `secret` - `nil` or the secret value that unlocks the door
|
||||
* `name` - a string description of the node ("a locked chest")
|
||||
* `owner` - name of the node owner
|
||||
|
||||
The `on_skeleton_key_use` function should validate that the player has
|
||||
the right permissions to make a new key for the item. The newsecret
|
||||
value is useful if the node has no secret value. The function should
|
||||
store this secret value somewhere so that in the future it may compare
|
||||
key secrets and match them to allow access. If a node already has a
|
||||
secret value, the function should return that secret value instead
|
||||
of the newsecret value. The secret value stored for the node should
|
||||
not be overwritten, as this would invalidate existing keys.
|
||||
|
||||
Aside from the secret value, the function should retun a descriptive
|
||||
name for the node and the owner name. The return values are all
|
||||
encoded in the key that will be given to the player in replacement
|
||||
for the wielded skeleton key.
|
||||
|
||||
if `nil` is returned, it is assumed that the wielder did not have
|
||||
permissions to create a key for this node, and no key is created.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Bucket API](#bucket-api)
|
||||
- [Beds API](#beds-api)
|
||||
- [Bed definition](#bed-definition)
|
||||
- [Creative API](#creative-api)
|
||||
- [Doors API](#doors-api)
|
||||
- [Methods](#methods)
|
||||
- [Door definition](#door-definition)
|
||||
- [Trapdoor definition](#trapdoor-definition)
|
||||
- [Fence gate definition](#fence-gate-definition)
|
||||
- [Fence API](#fence-api)
|
||||
- [fence definition](#fence-definition)
|
||||
- [Walls API](#walls-api)
|
||||
- [Farming API](#farming-api)
|
||||
- [Hoe Definition](#hoe-definition)
|
||||
- [Plant definition](#plant-definition)
|
||||
- [Fire API](#fire-api)
|
||||
- [Give Initial Stuff API](#give-initial-stuff-api)
|
||||
- [TNT API](#tnt-api)
|
||||
- [Screwdriver API](#screwdriver-api)
|
||||
- [Sethome API](#sethome-api)
|
||||
- [Sfinv API](#sfinv-api)
|
||||
- [sfinv Methods](#sfinv-methods)
|
||||
- [sfinv Members](#sfinv-members)
|
||||
- [Context](#context)
|
||||
- [sfinv.register_page](#sfinvregister_page)
|
||||
- [get formspec](#get-formspec)
|
||||
- [Customising themes](#customising-themes)
|
||||
- [Stairs API](#stairs-api)
|
||||
- [Xpanes API](#xpanes-api)
|
||||
- [Pane definition](#pane-definition)
|
||||
- [Raillike definitions](#raillike-definitions)
|
||||
- [Default sounds](#default-sounds)
|
||||
- [Default constants](#default-constants)
|
||||
- [Player API](#player-api)
|
||||
- [Model Definition](#model-definition)
|
||||
- [Leafdecay](#leafdecay)
|
||||
- [Dyes](#dyes)
|
||||
- [Color groups](#color-groups)
|
||||
- [Color lists](#color-lists)
|
||||
- [Trees](#trees)
|
||||
- [Carts](#carts)
|
||||
- [Key API](#key-api)
|
114
game_api.txt
@ -1,19 +1,69 @@
|
||||
Minetest Game API
|
||||
=================
|
||||
GitHub Repo: https://github.com/minetest/minetest_game
|
||||
|
||||
This is a fork of the original one at https://github.com/minetest/minetest_game
|
||||
For more information about fork check [Differences](#differences) section.
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
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
|
||||
The Minetest4 Game game 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 Minetest4 API, visit https://codeberg.org/minenux/minetest-engine-minetest/src/branch/stable-4.0/doc/lua_api.txt
|
||||
Please note:
|
||||
|
||||
* [XYZ] refers to a section the Minetest API
|
||||
* [#ABC] refers to a section in this document
|
||||
* [pos] refers to a position table `{x = -5, y = 0, z = 200}`
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Bucket API](#bucket-api)
|
||||
- [Beds API](#beds-api)
|
||||
- [Bed definition](#bed-definition)
|
||||
- [Creative API](#creative-api)
|
||||
- [Doors API](#doors-api)
|
||||
- [Methods](#methods)
|
||||
- [Door definition](#door-definition)
|
||||
- [Trapdoor definition](#trapdoor-definition)
|
||||
- [Fence gate definition](#fence-gate-definition)
|
||||
- [Fence API](#fence-api)
|
||||
- [fence definition](#fence-definition)
|
||||
- [Walls API](#walls-api)
|
||||
- [Farming API](#farming-api)
|
||||
- [Hoe Definition](#hoe-definition)
|
||||
- [Plant definition](#plant-definition)
|
||||
- [Fire API](#fire-api)
|
||||
- [Give Initial Stuff API](#give-initial-stuff-api)
|
||||
- [TNT API](#tnt-api)
|
||||
- [Screwdriver API](#screwdriver-api)
|
||||
- [Sethome API](#sethome-api)
|
||||
- [Sfinv API](#sfinv-api)
|
||||
- [sfinv Methods](#sfinv-methods)
|
||||
- [sfinv Members](#sfinv-members)
|
||||
- [Context](#context)
|
||||
- [sfinv.register_page](#sfinvregister_page)
|
||||
- [get formspec](#get-formspec)
|
||||
- [Customising themes](#customising-themes)
|
||||
- [Stairs API](#stairs-api)
|
||||
- [Xpanes API](#xpanes-api)
|
||||
- [Pane definition](#pane-definition)
|
||||
- [Raillike definitions](#raillike-definitions)
|
||||
- [Default sounds](#default-sounds)
|
||||
- [Default constants](#default-constants)
|
||||
- [Player API](#player-api)
|
||||
- [Model Definition](#model-definition)
|
||||
- [Leafdecay](#leafdecay)
|
||||
- [Dyes](#dyes)
|
||||
- [Color groups](#color-groups)
|
||||
- [Color lists](#color-lists)
|
||||
- [Trees](#trees)
|
||||
- [Carts](#carts)
|
||||
- [Key API](#key-api)
|
||||
|
||||
|
||||
Bucket API
|
||||
----------
|
||||
|
||||
@ -155,7 +205,8 @@ The doors mod allows modders to register custom doors and trapdoors.
|
||||
### Fence gate definition
|
||||
|
||||
description = "Wooden Fence Gate",
|
||||
texture = "default_wood.png",
|
||||
texture = "default_wood.png", -- `backface_culling` will automatically be
|
||||
-- set to `true` if not specified.
|
||||
material = "default:wood",
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
|
||||
sounds = default.node_sound_wood_defaults(), -- optional
|
||||
@ -301,14 +352,15 @@ TNT API
|
||||
* `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".
|
||||
* `burning` Top tile when lit. By default the name of the tnt with a suffix of `_top_burning_animated.png`.
|
||||
|
||||
`tnt.boom(position, definition)`
|
||||
`tnt.boom(position[, definition])`
|
||||
|
||||
^ Create an explosion.
|
||||
|
||||
* `position` The center of explosion.
|
||||
* `definition` The TNT definion as passed to `tnt.register`
|
||||
* `definition` The TNT definion as passed to `tnt.register` with the following addition:
|
||||
* `explode_center` false by default which removes TNT node on blast, when true will explode center node.
|
||||
|
||||
`tnt.burn(position, [nodename])`
|
||||
|
||||
@ -643,6 +695,7 @@ default.player_get_animation(player)
|
||||
bar = {x = 20, y = 39},
|
||||
-- ...
|
||||
},
|
||||
eye_height = 1.47, -- In nodes above feet position
|
||||
}
|
||||
|
||||
Leafdecay
|
||||
@ -862,3 +915,48 @@ for the wielded skeleton key.
|
||||
|
||||
if `nil` is returned, it is assumed that the wielder did not have
|
||||
permissions to create a key for this node, and no key is created.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Bucket API](#bucket-api)
|
||||
- [Beds API](#beds-api)
|
||||
- [Bed definition](#bed-definition)
|
||||
- [Creative API](#creative-api)
|
||||
- [Doors API](#doors-api)
|
||||
- [Methods](#methods)
|
||||
- [Door definition](#door-definition)
|
||||
- [Trapdoor definition](#trapdoor-definition)
|
||||
- [Fence gate definition](#fence-gate-definition)
|
||||
- [Fence API](#fence-api)
|
||||
- [fence definition](#fence-definition)
|
||||
- [Walls API](#walls-api)
|
||||
- [Farming API](#farming-api)
|
||||
- [Hoe Definition](#hoe-definition)
|
||||
- [Plant definition](#plant-definition)
|
||||
- [Fire API](#fire-api)
|
||||
- [Give Initial Stuff API](#give-initial-stuff-api)
|
||||
- [TNT API](#tnt-api)
|
||||
- [Screwdriver API](#screwdriver-api)
|
||||
- [Sethome API](#sethome-api)
|
||||
- [Sfinv API](#sfinv-api)
|
||||
- [sfinv Methods](#sfinv-methods)
|
||||
- [sfinv Members](#sfinv-members)
|
||||
- [Context](#context)
|
||||
- [sfinv.register_page](#sfinvregister_page)
|
||||
- [get formspec](#get-formspec)
|
||||
- [Customising themes](#customising-themes)
|
||||
- [Stairs API](#stairs-api)
|
||||
- [Xpanes API](#xpanes-api)
|
||||
- [Pane definition](#pane-definition)
|
||||
- [Raillike definitions](#raillike-definitions)
|
||||
- [Default sounds](#default-sounds)
|
||||
- [Default constants](#default-constants)
|
||||
- [Player API](#player-api)
|
||||
- [Model Definition](#model-definition)
|
||||
- [Leafdecay](#leafdecay)
|
||||
- [Dyes](#dyes)
|
||||
- [Color groups](#color-groups)
|
||||
- [Color lists](#color-lists)
|
||||
- [Trees](#trees)
|
||||
- [Carts](#carts)
|
||||
- [Key API](#key-api)
|
||||
|
BIN
menu/header.png
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 3.2 KiB |
BIN
menu/icon.png
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
@ -31,8 +31,11 @@
|
||||
#enable_lavacooling = 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
|
||||
# its depends of the configured at the initital_stuff_mod
|
||||
#give_initial_stuff = true
|
||||
|
||||
# What initial stuff will be given to player if initial stuff are set to true
|
||||
#initial_stuff = default:wood,farming:bread,default:furnace,default:torch
|
||||
|
||||
# Whether the TNT mod should be enabled
|
||||
#enable_tnt = <true in singleplayer, false in multiplayer>
|
||||
|
55
mods/README.md
Normal file
@ -0,0 +1,55 @@
|
||||
Default mods
|
||||
------------
|
||||
|
||||
For information check [../README.md](../README.md)
|
||||
|
||||
## Content
|
||||
|
||||
Most of those mods have mirror at http://git.mirror.org
|
||||
|
||||
| mod name | origin or work | version | info |
|
||||
| ------------------ | --------------------------------------------------- | -------- | --- |
|
||||
| api | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/c7cb79422ba19c696966472942db6177c934838d | [api](../game_api.md) |
|
||||
| beds | https://codeberg.org/minenux/minetest-mod-beds | https://codeberg.org/minenux/minetest-mod-beds/commit/7b6fae96d5e273dad9a373e63eb958145c9bfbef | [beds/README.md](beds/README.md) |
|
||||
| boats | https://codeberg.org/minenux/minetest-mod-boats | https://codeberg.org/minenux/minetest-mod-boats/commit/3832de08f705d5d2e7b5a971760e5fad1653305f | [boats/README.md](boats/README.md) |
|
||||
| bucket | https://codeberg.org/minenux/minetest-mod-bucket.git | https://codeberg.org/minenux/minetest-mod-bucket/commit/1d9f32295aba3ef2a86be302050f34c1766e93d5 | [bucket/README.md](bucket/README.md) |
|
||||
| bones | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/c7cb79422ba19c696966472942db6177c934838d | |
|
||||
| carts | https://codeberg.org/minenux/minetest-mod-carts | https://codeberg.org/minenux/minetest-mod-carts/commit/dcbca916cffdcec281f0129ef350db2686bda933 | [carts/README.md](carts/README.md) |
|
||||
| creative | https://codeberg.org/minenux/minetest-mod-creative | https://codeberg.org/minenux/minetest-mod-creative/commit/ca09e773701f834fec7de18bf13598b3323778db | [creative/README.md](creative/README.md) |
|
||||
| default | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/c7cb79422ba19c696966472942db6177c934838d | |
|
||||
| doors | https://codeberg.org/minenux/minetest-mod-doors | https://codeberg.org/minenux/minetest-mod-doors/commit/a89ab0454deb4933b6e4971c57055c40b7938e5b | [doors/README.md](doors/README.md) |
|
||||
| dye | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/c7cb79422ba19c696966472942db6177c934838d | |
|
||||
| farming | https://codeberg.org/minenux/minetest-mod-farming | https://codeberg.org/minenux/minetest-mod-farming/commit/08c3a9b37bab5d8a0f5971b168aef412db5fc424 | [farming/README.md](farming/README.md) |
|
||||
| fire | https://codeberg.org/minenux/minetest-mod-fire | https://codeberg.org/minenux/minetest-mod-fire/commit/4e5f7ad55314bd9b126fb133cfc5a32fa58b20d2 | [fire/README.md](fire/README.md) |
|
||||
| fireflies | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/ee13c9f46ad23972dfd52e74104b265d81bd50b8 | [fireflies/README.md](fireflies/README.md) |
|
||||
| flowers | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/c7cb79422ba19c696966472942db6177c934838d | |
|
||||
| hudbars | https://codeberg.org/minenux/minetest-mod-hudbars | https://codeberg.org/minenux/minetest-mod-hudbars/commit/1a86b2a773030bd26d6fac2c3b9f6df6d23916ed | [hudbars/README.md](hudbars/README.md) |
|
||||
| give_initial_stuff | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/c7cb79422ba19c696966472942db6177c934838d | |
|
||||
| killme | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/c7cb79422ba19c696966472942db6177c934838d | |
|
||||
| sfinv | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/c7cb79422ba19c696966472942db6177c934838d | |
|
||||
| stairs | https://codeberg.org/minenux/minetest-mod-stairs | https://codeberg.org/minenux/minetest-mod-stairs/commit/c3a5af6c452daca599d226df694df1b75f15c110 | [stairs/README.md](stairs/README.md) |
|
||||
| screwdriver | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/c7cb79422ba19c696966472942db6177c934838d | |
|
||||
| sethome | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/8e59006dc81ebe6785380158e57ba126cb3a4163 | |
|
||||
| tnt | https://codeberg.org/minenux/minetest-mod-tnt | https://codeberg.org/minenux/minetest-mod-tnt/commit/8195861f905a90b53cd52348deb34df41a053027 | [tnt/README.md](tnt/README.md) |
|
||||
| toolranks | https://codeberg.org/minenux/minetest-mod-toolranks | https://codeberg.org/minenux/minetest-mod-toolranks/commit/5c9553e5ac6cc7ae375033b76ef7771a6935c771 | [toolranks/README.md](toolranks/README.md) |
|
||||
| vessels | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/c7cb79422ba19c696966472942db6177c934838d | |
|
||||
| walls | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/c7cb79422ba19c696966472942db6177c934838d | |
|
||||
| wool | https://codeberg.org/minenux/minetest-mod-wool | https://codeberg.org/minenux/minetest-mod-wool/commit/de642a08e80bfd7a4a1e5629e50458a609dbda3a | [wool/README.md](wool/README.md) |
|
||||
| xpanes | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/c7cb79422ba19c696966472942db6177c934838d | |
|
||||
| xdecor | https://codeberg.org/minenux/minetest-game-xdecor | https://codeberg.org/minenux/minetest-game-xdecor/commit/cd0c35b8c58153f7c353b5dbfac35e524fa0ea18 | [xdecor/README.md](xdecor/README.md) |
|
||||
|
||||
The default mod provides sethome and player_api call ones, binoculars from v5 are
|
||||
just separate privilegies for zoom, butterflies and fireflies from v5 can be set
|
||||
by dmobs or mobs_doomed mod, the spawn mod is just minimal spawn management
|
||||
pooly provided and better managed by mods like rspawn and spawnrandom.
|
||||
|
||||
## Compatibility
|
||||
|
||||
This source code and files are focused in most olders minetest4 engine or 0.4.X ones
|
||||
from https://codeberg.org/minenux/minetest-engine/src/branch/stable-4.0
|
||||
|
||||
For minetest5 check https://codeberg.org/minenux/minetest-engine/src/branch/stable-5.2
|
||||
|
||||
## Licensing
|
||||
|
||||
See `LICENSE.txt`
|
26
mods/beds/Changelog.txt
Normal file
@ -0,0 +1,26 @@
|
||||
1.0.1 beta
|
||||
----------
|
||||
- Add backwards compatibility with PilzAdam's beds mod
|
||||
- Fix placement
|
||||
- Fix small bugs
|
||||
- Prevent possible crash
|
||||
|
||||
1.1
|
||||
---
|
||||
- Add fancy bed model (based on jp's model)
|
||||
- Add API to register beds
|
||||
- Allow players always to detach from bed (by donat-b)
|
||||
- If more than 50% of players want sleep they can skip the night
|
||||
- Don't show sleep dialog in singleplayer
|
||||
|
||||
1.1.1
|
||||
-----
|
||||
- Prevent possbile crash by trying to reposition leaving players
|
||||
|
||||
1.2
|
||||
---
|
||||
- Updated to use default bed functions
|
||||
- Texture check to fix beds using old api
|
||||
- 'bed_sleep_divide' setting added [1 for all, 2 for half, 3 for third]
|
||||
- Add POVA support
|
||||
- Add pink fancy bed and blue simple bed
|
96
mods/beds/README.md
Normal file
@ -0,0 +1,96 @@
|
||||
minetest mod Beds
|
||||
=========================
|
||||
|
||||
This mod improves beds which allows sleep, featured to (auto) skip the night.
|
||||
|
||||
Information
|
||||
-----------
|
||||
|
||||
This mod is named `beds` to sleep, by rightclick the bed. It featured
|
||||
in singleplayer mode that the night gets skipped immediately. If playing
|
||||
in multiplayer you get shown how many other players are in bed too,
|
||||
if all players are sleeping the night gets skipped.
|
||||
|
||||
![screenshot.jpg](screenshot.jpg)
|
||||
|
||||
Tech information
|
||||
----------------
|
||||
|
||||
This mod sustitute default one, you must disable the default of minetest
|
||||
game if present or override it.
|
||||
|
||||
#### Features
|
||||
|
||||
* Night Skypping:
|
||||
|
||||
This mod auto featured night skip in singleplayer, in multiplayer it skipped
|
||||
if more than a set percentage (default 50%) of the players are lying
|
||||
in bed and use this option. Check configuration section for more info.
|
||||
|
||||
* Controlled respawning:
|
||||
|
||||
If you have slept in bed (not just lying in it) your respawn point
|
||||
is set to the beds location and you will respawn there after
|
||||
death. Check configuration section for more info.
|
||||
|
||||
* More beds:
|
||||
|
||||
It features two more beds, the "Blue Simple Bed" like the "Simple Bed"
|
||||
but in blue, and the "Pink Fancy Bed" like the "Fancy Bed" but in pink.
|
||||
|
||||
#### Dependencies
|
||||
|
||||
* default
|
||||
* player_api (for newer engines)
|
||||
|
||||
Optional dependences:
|
||||
|
||||
* intllib (only for older engines)
|
||||
* pova (optional)
|
||||
|
||||
The pova mod are not xplicit set as optional depends, due the circular depends bug,
|
||||
its detected and used.
|
||||
|
||||
#### Configuration
|
||||
|
||||
| Configuration | type | default | place file | Notes about |
|
||||
| --------------------- | ----- | ------- | ------------ | ----------------------------------------- |
|
||||
| enable_bed_respawn | bool | true | minetest.conf | Enable respawn point set to last sleep bed |
|
||||
| enable_bed_night_skip | bool | false | minetest.conf | You can disable the night skip feature |
|
||||
| bed_sleep_divide | int | 2 | minetest.conf | Division of players needed to skip night |
|
||||
|
||||
#### Nodes
|
||||
|
||||
Crafting are same as original default mod, but colored uses a white plus the other color.
|
||||
|
||||
| Node name | Description name |
|
||||
| ----------------------- | --------------------- |
|
||||
| beds:bed | Simple bed |
|
||||
| beds:bed_blue | Simple bed blue |
|
||||
| beds:fancy_bed | Fancy shaped bed |
|
||||
| beds:fancy_bed_pink | Fancy shaped bed pink |
|
||||
|
||||
#### Nodes and Aliasing
|
||||
|
||||
| mod name : node name | new mod name : new node |
|
||||
| --------------------------- | ----------------------- |
|
||||
| beds:bed_top_red | beds:bed_top |
|
||||
| beds:bed_bottom_red | beds:bed_bottom |
|
||||
|
||||
License
|
||||
------
|
||||
|
||||
### Authors of source code
|
||||
|
||||
Originally by BlockMen (MIT)
|
||||
Various Minetest developers and contributors (MIT)
|
||||
|
||||
### Authors of media (textures)
|
||||
|
||||
BlockMen (CC BY-SA 3.0)
|
||||
All textures unless otherwise noted
|
||||
|
||||
JP (WTFPL)
|
||||
All models unless otherwise noted
|
||||
|
||||
Check [license.txt](license.txt)
|
@ -1,26 +0,0 @@
|
||||
Minetest Game mod: beds
|
||||
=======================
|
||||
See license.txt for license information.
|
||||
|
||||
Authors of source code
|
||||
----------------------
|
||||
Originally by BlockMen (MIT)
|
||||
Various Minetest developers and contributors (MIT)
|
||||
|
||||
Authors of media (textures)
|
||||
---------------------------
|
||||
BlockMen (CC BY-SA 3.0)
|
||||
|
||||
This mod adds a bed to Minetest which allows to skip the night.
|
||||
To sleep, rightclick the bed. If playing in singleplayer mode the night gets skipped
|
||||
immediately. If playing multiplayer you get shown how many other players are in bed too,
|
||||
if all players are sleeping the night gets skipped. The night skip can be forced if more
|
||||
than 50% of the players are lying in bed and use this option.
|
||||
|
||||
Another feature is a controlled respawning. If you have slept in bed (not just lying in
|
||||
it) your respawn point is set to the beds location and you will respawn there after
|
||||
death.
|
||||
You can disable the respawn at beds by setting "enable_bed_respawn = false" in
|
||||
minetest.conf.
|
||||
You can disable the night skip feature by setting "enable_bed_night_skip = false" in
|
||||
minetest.conf or by using the /set command in-game.
|
@ -1,165 +1,128 @@
|
||||
|
||||
local reverse = true
|
||||
|
||||
local function destruct_bed(pos, n)
|
||||
local node = minetest.get_node(pos)
|
||||
local other
|
||||
|
||||
if n == 2 then
|
||||
local dir = minetest.facedir_to_dir(node.param2)
|
||||
other = vector.subtract(pos, dir)
|
||||
elseif n == 1 then
|
||||
local dir = minetest.facedir_to_dir(node.param2)
|
||||
other = vector.add(pos, dir)
|
||||
end
|
||||
|
||||
if reverse then
|
||||
reverse = not reverse
|
||||
minetest.remove_node(other)
|
||||
minetest.check_for_falling(other)
|
||||
else
|
||||
reverse = not reverse
|
||||
end
|
||||
end
|
||||
|
||||
function beds.register_bed(name, def)
|
||||
minetest.register_node(name .. "_bottom", {
|
||||
|
||||
local new_tiles
|
||||
local new_mesh = "beds_simple_bed.obj"
|
||||
|
||||
-- old api texture check
|
||||
if def.tiles and def.tiles.bottom then
|
||||
|
||||
new_tiles = "beds_simple_bed.png" -- default
|
||||
|
||||
-- check for fancy bed
|
||||
if def.nodebox and def.nodebox.bottom and #def.nodebox.bottom > 3 then
|
||||
new_tiles = "beds_fancy_bed.png"
|
||||
new_mesh = "beds_fancy_bed.obj"
|
||||
end
|
||||
end
|
||||
|
||||
-- register bed node
|
||||
minetest.register_node(name, {
|
||||
description = def.description,
|
||||
inventory_image = def.inventory_image,
|
||||
wield_image = def.wield_image,
|
||||
drawtype = "nodebox",
|
||||
tiles = def.tiles.bottom,
|
||||
drawtype = "mesh",
|
||||
mesh = def.mesh or new_mesh,
|
||||
tiles = new_tiles or def.tiles,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
stack_max = 1,
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 1},
|
||||
sounds = def.sounds or default.node_sound_wood_defaults(),
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = def.nodebox.bottom,
|
||||
groups = {
|
||||
choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 1,
|
||||
fall_damage_add_percent = -40, bouncy = 85
|
||||
},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = def.selectionbox,
|
||||
fixed = def.selectionbox
|
||||
},
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = def.collisionbox
|
||||
},
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
|
||||
local under = pointed_thing.under
|
||||
local node = minetest.get_node(under)
|
||||
local udef = minetest.registered_nodes[node.name]
|
||||
if udef and udef.on_rightclick and
|
||||
not (placer and placer:get_player_control().sneak) then
|
||||
|
||||
if udef and udef.on_rightclick
|
||||
and not (placer and placer:is_player()
|
||||
and placer:get_player_control().sneak) then
|
||||
|
||||
return udef.on_rightclick(under, node, placer, itemstack,
|
||||
pointed_thing) or itemstack
|
||||
end
|
||||
|
||||
local pos
|
||||
if minetest.registered_items[minetest.get_node(under).name].buildable_to then
|
||||
|
||||
if udef and udef.buildable_to then
|
||||
pos = under
|
||||
else
|
||||
pos = pointed_thing.above
|
||||
end
|
||||
|
||||
if minetest.is_protected(pos, placer:get_player_name()) and
|
||||
not minetest.check_player_privs(placer, "protection_bypass") then
|
||||
minetest.record_protection_violation(pos, placer:get_player_name())
|
||||
local player_name = placer and placer:get_player_name() or ""
|
||||
|
||||
if minetest.is_protected(pos, player_name)
|
||||
and not minetest.check_player_privs(player_name, "protection_bypass") then
|
||||
|
||||
minetest.record_protection_violation(pos, player_name)
|
||||
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local node_def = minetest.registered_nodes[minetest.get_node(pos).name]
|
||||
|
||||
if not node_def or not node_def.buildable_to then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local dir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
local dir = placer and placer:get_look_dir() and
|
||||
minetest.dir_to_facedir(placer:get_look_dir()) or 0
|
||||
local botpos = vector.add(pos, minetest.facedir_to_dir(dir))
|
||||
|
||||
if minetest.is_protected(botpos, placer:get_player_name()) and
|
||||
not minetest.check_player_privs(placer, "protection_bypass") then
|
||||
minetest.record_protection_violation(botpos, placer:get_player_name())
|
||||
if minetest.is_protected(botpos, player_name)
|
||||
and not minetest.check_player_privs(player_name, "protection_bypass") then
|
||||
|
||||
minetest.record_protection_violation(botpos, player_name)
|
||||
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local botdef = minetest.registered_nodes[minetest.get_node(botpos).name]
|
||||
|
||||
if not botdef or not botdef.buildable_to then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
minetest.set_node(pos, {name = name .. "_bottom", param2 = dir})
|
||||
minetest.set_node(botpos, {name = name .. "_top", param2 = dir})
|
||||
minetest.set_node(pos, {name = name, param2 = dir})
|
||||
|
||||
if not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(placer:get_player_name())) then
|
||||
if not beds.is_creative(player_name) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_destruct = function(pos)
|
||||
destruct_bed(pos, 1)
|
||||
end,
|
||||
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
beds.on_rightclick(pos, clicker)
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_rotate = function(pos, node, user, mode, new_param2)
|
||||
local dir = minetest.facedir_to_dir(node.param2)
|
||||
local p = vector.add(pos, dir)
|
||||
local node2 = minetest.get_node_or_nil(p)
|
||||
if not node2 or not minetest.get_item_group(node2.name, "bed") == 2 or
|
||||
not node.param2 == node2.param2 then
|
||||
return false
|
||||
end
|
||||
if minetest.is_protected(p, user:get_player_name()) then
|
||||
minetest.record_protection_violation(p, user:get_player_name())
|
||||
return false
|
||||
end
|
||||
if mode ~= screwdriver.ROTATE_FACE then
|
||||
return false
|
||||
end
|
||||
local newp = vector.add(pos, minetest.facedir_to_dir(new_param2))
|
||||
local node3 = minetest.get_node_or_nil(newp)
|
||||
local node_def = node3 and minetest.registered_nodes[node3.name]
|
||||
if not node_def or not node_def.buildable_to then
|
||||
return false
|
||||
end
|
||||
if minetest.is_protected(newp, user:get_player_name()) then
|
||||
minetest.record_protection_violation(newp, user:get_player_name())
|
||||
return false
|
||||
end
|
||||
node.param2 = new_param2
|
||||
-- do not remove_node here - it will trigger destroy_bed()
|
||||
minetest.set_node(p, {name = "air"})
|
||||
minetest.set_node(pos, node)
|
||||
minetest.set_node(newp, {name = name .. "_top", param2 = new_param2})
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node(name .. "_top", {
|
||||
drawtype = "nodebox",
|
||||
tiles = def.tiles.top,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
pointable = false,
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 2},
|
||||
sounds = def.sounds or default.node_sound_wood_defaults(),
|
||||
drop = name .. "_bottom",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = def.nodebox.top,
|
||||
},
|
||||
on_destruct = function(pos)
|
||||
destruct_bed(pos, 2)
|
||||
beds.remove_spawns_at(pos)
|
||||
end,
|
||||
|
||||
can_dig = function(pos, player)
|
||||
return beds.can_dig(pos)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_alias(name, name .. "_bottom")
|
||||
minetest.register_alias(name .. "_bottom", name)
|
||||
minetest.register_alias(name .. "_top", "air")
|
||||
|
||||
-- register recipe
|
||||
minetest.register_craft({
|
||||
output = name,
|
||||
recipe = def.recipe
|
||||
|
@ -1,87 +1,65 @@
|
||||
local S = beds.get_translator
|
||||
|
||||
-- Fancy shaped bed
|
||||
|
||||
beds.register_bed("beds:fancy_bed", {
|
||||
description = "Fancy Bed",
|
||||
description = S("Fancy Bed"),
|
||||
inventory_image = "beds_bed_fancy.png",
|
||||
wield_image = "beds_bed_fancy.png",
|
||||
tiles = {
|
||||
bottom = {
|
||||
"beds_bed_top1.png",
|
||||
"default_wood.png",
|
||||
"beds_bed_side1.png",
|
||||
"beds_bed_side1.png^[transformFX",
|
||||
"default_wood.png",
|
||||
"beds_bed_foot.png",
|
||||
},
|
||||
top = {
|
||||
"beds_bed_top2.png",
|
||||
"default_wood.png",
|
||||
"beds_bed_side2.png",
|
||||
"beds_bed_side2.png^[transformFX",
|
||||
"beds_bed_head.png",
|
||||
"default_wood.png",
|
||||
}
|
||||
},
|
||||
nodebox = {
|
||||
bottom = {
|
||||
{-0.5, -0.5, -0.5, -0.375, -0.065, -0.4375},
|
||||
{0.375, -0.5, -0.5, 0.5, -0.065, -0.4375},
|
||||
{-0.5, -0.375, -0.5, 0.5, -0.125, -0.4375},
|
||||
{-0.5, -0.375, -0.5, -0.4375, -0.125, 0.5},
|
||||
{0.4375, -0.375, -0.5, 0.5, -0.125, 0.5},
|
||||
{-0.4375, -0.3125, -0.4375, 0.4375, -0.0625, 0.5},
|
||||
},
|
||||
top = {
|
||||
{-0.5, -0.5, 0.4375, -0.375, 0.1875, 0.5},
|
||||
{0.375, -0.5, 0.4375, 0.5, 0.1875, 0.5},
|
||||
{-0.5, 0, 0.4375, 0.5, 0.125, 0.5},
|
||||
{-0.5, -0.375, 0.4375, 0.5, -0.125, 0.5},
|
||||
{-0.5, -0.375, -0.5, -0.4375, -0.125, 0.5},
|
||||
{0.4375, -0.375, -0.5, 0.5, -0.125, 0.5},
|
||||
{-0.4375, -0.3125, -0.5, 0.4375, -0.0625, 0.4375},
|
||||
}
|
||||
},
|
||||
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
|
||||
tiles = {"beds_fancy_bed.png", "default_wood.png"},
|
||||
mesh = "beds_fancy_bed.obj",
|
||||
selectionbox = {-0.5, -0.5, -0.5, 0.5, -0.06, 1.5},
|
||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, -0.06, 1.5},
|
||||
recipe = {
|
||||
{"", "", "group:stick"},
|
||||
{"wool:red", "wool:red", "wool:white"},
|
||||
{"group:wood", "group:wood", "group:wood"},
|
||||
},
|
||||
{"wool:white", "wool:white", "wool:white"},
|
||||
{"group:wood", "group:wood", "group:wood"}
|
||||
}
|
||||
})
|
||||
|
||||
beds.register_bed("beds:fancy_bed_pink", {
|
||||
description = S("Pink Fancy Bed"),
|
||||
inventory_image = "beds_bed_fancy_pink.png",
|
||||
wield_image = "beds_bed_fancy_pink.png",
|
||||
tiles = {"beds_fancy_bed_pink.png", "default_wood.png"},
|
||||
mesh = "beds_fancy_bed.obj",
|
||||
selectionbox = {-0.5, -0.5, -0.5, 0.5, -0.06, 1.5},
|
||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, -0.06, 1.5},
|
||||
recipe = {
|
||||
{"", "", "group:stick"},
|
||||
{"wool:pink", "wool:pink", "wool:white"},
|
||||
{"group:wood", "group:wood", "group:wood"}
|
||||
}
|
||||
})
|
||||
|
||||
-- Simple shaped bed
|
||||
|
||||
beds.register_bed("beds:bed", {
|
||||
description = "Simple Bed",
|
||||
description = S("Simple Bed"),
|
||||
inventory_image = "beds_bed.png",
|
||||
wield_image = "beds_bed.png",
|
||||
tiles = {
|
||||
bottom = {
|
||||
"beds_bed_top_bottom.png^[transformR90",
|
||||
"default_wood.png",
|
||||
"beds_bed_side_bottom_r.png",
|
||||
"beds_bed_side_bottom_r.png^[transformfx",
|
||||
"beds_transparent.png",
|
||||
"beds_bed_side_bottom.png"
|
||||
},
|
||||
top = {
|
||||
"beds_bed_top_top.png^[transformR90",
|
||||
"default_wood.png",
|
||||
"beds_bed_side_top_r.png",
|
||||
"beds_bed_side_top_r.png^[transformfx",
|
||||
"beds_bed_side_top.png",
|
||||
"beds_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},
|
||||
},
|
||||
tiles = {"beds_simple_bed.png"},
|
||||
mesh = "beds_simple_bed.obj",
|
||||
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
|
||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
|
||||
recipe = {
|
||||
{"wool:red", "wool:red", "wool:white"},
|
||||
{"wool:white", "wool:white", "wool:white"},
|
||||
{"group:wood", "group:wood", "group:wood"}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
beds.register_bed("beds:bed_blue", {
|
||||
description = S("Blue Simple Bed"),
|
||||
inventory_image = "beds_bed_blue.png",
|
||||
wield_image = "beds_bed_blue.png",
|
||||
tiles = {"beds_simple_bed_blue.png"},
|
||||
mesh = "beds_simple_bed.obj",
|
||||
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
|
||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
|
||||
recipe = {
|
||||
{"wool:blue", "wool:blue", "wool:white"},
|
||||
{"group:wood", "group:wood", "group:wood"}
|
||||
}
|
||||
})
|
||||
|
||||
-- Aliases for PilzAdam's beds mod
|
||||
@ -93,12 +71,12 @@ minetest.register_alias("beds:bed_top_red", "beds:bed_top")
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "beds:fancy_bed_bottom",
|
||||
burntime = 13,
|
||||
recipe = "beds:fancy_bed",
|
||||
burntime = 13
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "beds:bed_bottom",
|
||||
burntime = 12,
|
||||
recipe = "beds:bed",
|
||||
burntime = 12
|
||||
})
|
||||
|
@ -1,2 +1,4 @@
|
||||
default
|
||||
wool
|
||||
pova?
|
||||
intllib?
|
||||
|
1
mods/beds/description.txt
Normal file
@ -0,0 +1 @@
|
||||
beds which allows sleep, featured to (auto) skip the night.
|
@ -1,7 +1,11 @@
|
||||
local S = beds.get_translator
|
||||
local is_50 = beds.is_50
|
||||
local is_54 = beds.is_54
|
||||
local is_pova = minetest.get_modpath("pova")
|
||||
local pi = math.pi
|
||||
local player_in_bed = 0
|
||||
local is_sp = minetest.is_singleplayer()
|
||||
local enable_respawn = minetest.settings:get_bool("enable_bed_respawn")
|
||||
|
||||
if enable_respawn == nil then
|
||||
enable_respawn = true
|
||||
end
|
||||
@ -9,34 +13,49 @@ 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
|
||||
|
||||
local rotation = minetest.get_node(pos).param2
|
||||
|
||||
if rotation > 3 then
|
||||
rotation = rotation % 4 -- Mask colorfacedir values
|
||||
end
|
||||
|
||||
if rotation == 1 then
|
||||
return pi / 2, rotation
|
||||
elseif rotation == 3 then
|
||||
return -pi / 2, rotation
|
||||
elseif rotation == 0 then
|
||||
return pi, rotation
|
||||
else
|
||||
return 0, n.param2
|
||||
return 0, rotation
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function is_night_skip_enabled()
|
||||
|
||||
local enable_night_skip = minetest.settings:get_bool("enable_bed_night_skip")
|
||||
|
||||
if enable_night_skip == nil then
|
||||
enable_night_skip = true
|
||||
end
|
||||
|
||||
return enable_night_skip
|
||||
end
|
||||
|
||||
|
||||
local function check_in_beds(players)
|
||||
|
||||
local in_bed = beds.player
|
||||
|
||||
if not players then
|
||||
players = minetest.get_connected_players()
|
||||
end
|
||||
|
||||
for n, player in ipairs(players) do
|
||||
|
||||
local name = player:get_player_name()
|
||||
|
||||
if not in_bed[name] then
|
||||
return false
|
||||
end
|
||||
@ -45,7 +64,9 @@ local function check_in_beds(players)
|
||||
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()
|
||||
|
||||
@ -55,61 +76,156 @@ local function lay_down(player, pos, bed_pos, state, skip)
|
||||
|
||||
-- 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
|
||||
|
||||
if not beds.player[name] then
|
||||
return false -- player not in bed, do nothing
|
||||
end
|
||||
|
||||
beds.bed_position[name] = nil
|
||||
|
||||
-- skip here to prevent sending player specific changes (used for leaving players)
|
||||
if skip then
|
||||
return
|
||||
end
|
||||
if p then
|
||||
player:setpos(p)
|
||||
end
|
||||
|
||||
player:set_pos(beds.pos[name])
|
||||
|
||||
-- physics, eye_offset, etc
|
||||
local physics_override = beds.player[name].physics_override
|
||||
|
||||
beds.player[name] = nil
|
||||
|
||||
if is_pova then
|
||||
pova.del_override(name, "force")
|
||||
pova.do_override(player)
|
||||
else
|
||||
player:set_physics_override({
|
||||
speed = physics_override.speed,
|
||||
jump = physics_override.jump,
|
||||
gravity = physics_override.gravity
|
||||
})
|
||||
end
|
||||
|
||||
player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
||||
player:set_look_horizontal(math.random(1, 180) / 100)
|
||||
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
|
||||
if beds.is_50 then
|
||||
player_api.player_attached[name] = false
|
||||
player_api.set_animation(player, "stand" , 30)
|
||||
else
|
||||
beds.player[name] = 1
|
||||
default.player_attached[name] = false
|
||||
default.player_set_animation(player, "stand" , 30)
|
||||
end
|
||||
|
||||
hud_flags.wielditem = true
|
||||
|
||||
else -- lay down
|
||||
|
||||
-- Check if bed is occupied
|
||||
for _, other_pos in pairs(beds.bed_position) do
|
||||
|
||||
if vector.distance(bed_pos, other_pos) < 0.1 then
|
||||
|
||||
minetest.chat_send_player(name, S("This bed is already occupied!"))
|
||||
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
if beds.is_54 then
|
||||
-- Check if player is moving
|
||||
if vector.length(player:get_velocity()) > 0.001 then
|
||||
minetest.chat_send_player(name,
|
||||
S("You have to stop moving before going to bed!"))
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Check if player is attached to an object
|
||||
if player:get_attach() then
|
||||
return false
|
||||
end
|
||||
|
||||
if beds.player[name] then
|
||||
-- player already in bed, do nothing
|
||||
return false
|
||||
end
|
||||
|
||||
beds.pos[name] = pos
|
||||
player_in_bed = player_in_bed + 1
|
||||
beds.bed_position[name] = bed_pos
|
||||
beds.player[name] = {physics_override = player:get_physics_override()}
|
||||
|
||||
-- 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_horizontal(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)
|
||||
|
||||
-- p.y is just above the nodebox height of the 'Simple Bed' (the highest bed),
|
||||
-- to avoid sinking down through the bed.
|
||||
local p = {
|
||||
x = bed_pos.x + dir.x / 2,
|
||||
y = bed_pos.y + 0.07,
|
||||
z = bed_pos.z + dir.z / 2
|
||||
}
|
||||
|
||||
if is_pova then
|
||||
pova.add_override(name, "force", {speed = 0, jump = 0, gravity = 0})
|
||||
pova.do_override(player)
|
||||
else
|
||||
player:set_physics_override({speed = 0, jump = 0, gravity = 0})
|
||||
end
|
||||
|
||||
player:set_pos(p)
|
||||
|
||||
if beds.is_50 then
|
||||
player_api.player_attached[name] = true
|
||||
player_api.set_animation(player, "lay" , 0)
|
||||
else
|
||||
|
||||
default.player_attached[name] = true
|
||||
hud_flags.wielditem = false
|
||||
default.player_set_animation(player, "lay" , 0)
|
||||
end
|
||||
|
||||
hud_flags.wielditem = false
|
||||
end
|
||||
|
||||
player:hud_set_flags(hud_flags)
|
||||
end
|
||||
|
||||
|
||||
local function get_player_in_bed_count()
|
||||
|
||||
local c = 0
|
||||
|
||||
for _, _ in pairs(beds.player) do
|
||||
c = c + 1
|
||||
end
|
||||
|
||||
return c
|
||||
end
|
||||
|
||||
|
||||
local function update_formspecs(finished)
|
||||
|
||||
local ges = #minetest.get_connected_players()
|
||||
local form_n
|
||||
local player_in_bed = get_player_in_bed_count()
|
||||
local is_majority = (ges / 2) < player_in_bed
|
||||
local form_n
|
||||
local esc = minetest.formspec_escape
|
||||
|
||||
if finished then
|
||||
form_n = beds.formspec .. "label[2.7,11; Good morning.]"
|
||||
form_n = beds.formspec .. "label[2.7,9;" .. esc(S("Good morning.")) .. "]"
|
||||
else
|
||||
form_n = beds.formspec .. "label[2.2,11;" .. tostring(player_in_bed) ..
|
||||
" of " .. tostring(ges) .. " players are in bed]"
|
||||
form_n = beds.formspec .. "label[2.2,9;" ..
|
||||
esc(S("@1 of @2 players are in bed", player_in_bed, ges)) .. "]"
|
||||
|
||||
if is_majority and is_night_skip_enabled() then
|
||||
form_n = form_n .. "button_exit[2,8;4,0.75;force;Force night skip]"
|
||||
form_n = form_n .. "button_exit[2,6;4,0.75;force;" ..
|
||||
esc(S("Force night skip")) .. "]"
|
||||
end
|
||||
end
|
||||
|
||||
@ -118,36 +234,46 @@ local function update_formspecs(finished)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Public functions
|
||||
|
||||
function beds.kick_players()
|
||||
|
||||
for name, _ in pairs(beds.player) do
|
||||
|
||||
local player = minetest.get_player_by_name(name)
|
||||
|
||||
lay_down(player, nil, nil, false)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function beds.skip_night()
|
||||
minetest.set_timeofday(0.23)
|
||||
end
|
||||
|
||||
|
||||
function beds.on_rightclick(pos, player)
|
||||
|
||||
local name = player:get_player_name()
|
||||
local ppos = player:getpos()
|
||||
local ppos = player:get_pos()
|
||||
local tod = minetest.get_timeofday()
|
||||
|
||||
if tod > 0.2 and tod < 0.805 then
|
||||
if tod > beds.day_interval.start and tod < beds.day_interval.finish then
|
||||
|
||||
if beds.player[name] then
|
||||
lay_down(player, nil, nil, false)
|
||||
end
|
||||
minetest.chat_send_player(name, "You can only sleep at night.")
|
||||
|
||||
minetest.chat_send_player(name, S("You can only sleep at night."))
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- move to bed
|
||||
if not beds.player[name] then
|
||||
|
||||
lay_down(player, ppos, pos)
|
||||
|
||||
beds.set_spawns() -- save respawn positions when entering bed
|
||||
else
|
||||
lay_down(player, nil, nil, false)
|
||||
@ -159,10 +285,13 @@ function beds.on_rightclick(pos, player)
|
||||
|
||||
-- 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()
|
||||
@ -172,27 +301,56 @@ function beds.on_rightclick(pos, player)
|
||||
end
|
||||
|
||||
|
||||
function beds.can_dig(bed_pos)
|
||||
|
||||
-- Check all players in bed which one is at the expected position
|
||||
for _, player_bed_pos in pairs(beds.bed_position) do
|
||||
|
||||
if vector.equals(bed_pos, player_bed_pos) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- Callbacks
|
||||
|
||||
-- Only register respawn callback if respawn enabled
|
||||
if enable_respawn then
|
||||
|
||||
-- respawn player at bed if enabled and valid position is found
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
|
||||
if not player then return end
|
||||
|
||||
local name = player:get_player_name()
|
||||
local pos = beds.spawn[name]
|
||||
|
||||
if pos then
|
||||
player:setpos(pos)
|
||||
player:set_pos(pos)
|
||||
return true
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
|
||||
if not player then return end
|
||||
|
||||
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()
|
||||
@ -201,20 +359,54 @@ minetest.register_on_leaveplayer(function(player)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
|
||||
if not player then return end
|
||||
|
||||
local name = player:get_player_name()
|
||||
local in_bed = beds.player
|
||||
local pos = player:get_pos()
|
||||
local yaw = get_look_yaw(pos)
|
||||
|
||||
if in_bed[name] then
|
||||
lay_down(player, nil, pos, false)
|
||||
player:set_look_horizontal(yaw)
|
||||
player:set_pos(pos)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
local div = tonumber(minetest.settings:get("bed_sleep_divide")) or 2
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
||||
if formname ~= "beds_form" then
|
||||
return
|
||||
end
|
||||
|
||||
-- Because "Force night skip" button is a button_exit, it will set fields.quit
|
||||
-- and lay_down call will change value of player_in_bed, so it must be taken
|
||||
-- earlier.
|
||||
local last_player_in_bed = get_player_in_bed_count()
|
||||
|
||||
if fields.quit or fields.leave then
|
||||
lay_down(player, nil, nil, false)
|
||||
update_formspecs(false)
|
||||
end
|
||||
|
||||
if fields.force then
|
||||
update_formspecs(is_night_skip_enabled())
|
||||
if is_night_skip_enabled() then
|
||||
|
||||
-- check if enough players are sleeping to skip night (was half)
|
||||
local is_majority = (
|
||||
#minetest.get_connected_players() / div) < last_player_in_bed
|
||||
|
||||
if is_majority and is_night_skip_enabled() then
|
||||
update_formspecs(true)
|
||||
beds.skip_night()
|
||||
beds.kick_players()
|
||||
else
|
||||
update_formspecs(false)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
@ -1,17 +1,67 @@
|
||||
beds = {}
|
||||
beds.player = {}
|
||||
beds.pos = {}
|
||||
beds.spawn = {}
|
||||
local is_50 = nil
|
||||
local is_53 = minetest.has_feature("object_step_has_moveresult")
|
||||
local is_54 = minetest.has_feature("direct_velocity_on_players")
|
||||
|
||||
beds.formspec = "size[8,15;true]" ..
|
||||
"bgcolor[#080808BB; true]" ..
|
||||
"button_exit[2,12;4,0.75;leave;Leave Bed]"
|
||||
-- Load support for MT game translation.
|
||||
local S
|
||||
if minetest.get_translator ~= nil then
|
||||
S = minetest.get_translator("beds") -- 5.x translation function
|
||||
is_50 = true
|
||||
else
|
||||
if minetest.get_modpath("intllib") then
|
||||
dofile(minetest.get_modpath("intllib") .. "/init.lua")
|
||||
if intllib.make_gettext_pair then
|
||||
gettext, ngettext = intllib.make_gettext_pair() -- new gettext method
|
||||
else
|
||||
gettext = intllib.Getter() -- old text file method
|
||||
end
|
||||
S = gettext
|
||||
else -- boilerplate function for 0.4
|
||||
S = function(str, ...)
|
||||
local args = {...}
|
||||
return str:gsub("@%d+", function(match)
|
||||
return args[tonumber(match:sub(2))]
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
beds = {
|
||||
player = {},
|
||||
bed_position = {},
|
||||
pos = {},
|
||||
spawn = {},
|
||||
get_translator = S,
|
||||
formspec = "size[8,11;true]"
|
||||
.. "no_prepend[]"
|
||||
.. "bgcolor[#080808BB;true]"
|
||||
.. "button_exit[2,10;4,0.75;leave;" .. minetest.formspec_escape(S("Leave Bed")) .. "]"
|
||||
}
|
||||
beds.is_50 = is_50
|
||||
beds.is_53 = is_53
|
||||
beds.is_54 = is_54
|
||||
|
||||
beds.day_interval = {
|
||||
start = 0.2,
|
||||
finish = 0.805,
|
||||
}
|
||||
|
||||
local modpath = minetest.get_modpath("beds")
|
||||
|
||||
-- check for minetest 5.x/0.4 compatibility
|
||||
function beds.is_creative(name)
|
||||
if is_53 then
|
||||
return minetest.is_creative_enabled(name)
|
||||
else
|
||||
return creative.is_enabled_for(name) or minetest.settings:get_bool("creative_mode")
|
||||
end
|
||||
end
|
||||
-- Load files
|
||||
|
||||
dofile(modpath .. "/functions.lua")
|
||||
dofile(modpath .. "/api.lua")
|
||||
dofile(modpath .. "/beds.lua")
|
||||
dofile(modpath .. "/spawns.lua")
|
||||
|
||||
|
||||
print("[MOD] Beds loaded")
|
||||
|
@ -30,6 +30,7 @@ Licenses of media (textures)
|
||||
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
Copyright (C) 2014-2016 BlockMen
|
||||
Copyright (C) 2018 TumeniNodes
|
||||
|
||||
You are free to:
|
||||
Share — copy and redistribute the material in any medium or format.
|
||||
|
10
mods/beds/locale/beds.de.tr
Normal file
@ -0,0 +1,10 @@
|
||||
# textdomain: beds
|
||||
Fancy Bed=Schickes Bett
|
||||
Simple Bed=Schlichtes Bett
|
||||
This bed is already occupied!=Dieses Bett ist bereits belegt!
|
||||
You have to stop moving before going to bed!=Sie müssen stehen bleiben, bevor Sie zu Bett gehen können!
|
||||
Good morning.=Guten Morgen.
|
||||
@1 of @2 players are in bed=@1 von @2 Spielern sind im Bett
|
||||
Force night skip=Überspringen der Nacht erzwingen
|
||||
You can only sleep at night.=Sie können nur nachts schlafen.
|
||||
Leave Bed=Bett verlassen
|
10
mods/beds/locale/beds.es.tr
Normal file
@ -0,0 +1,10 @@
|
||||
# textdomain: beds
|
||||
Fancy Bed=Cama de lujo
|
||||
Simple Bed=Cama sencilla
|
||||
This bed is already occupied!=Esta cama esta ocupada
|
||||
You have to stop moving before going to bed!=Deja de moverte o no podras acostarte
|
||||
Good morning.=Buenos días.
|
||||
@1 of @2 players are in bed=@1 de @2 jugadores están durmiendo
|
||||
Force night skip=Forzar hacer de dia
|
||||
You can only sleep at night.=Sólo puedes dormir por la noche.
|
||||
Leave Bed=Levantarse
|
10
mods/beds/locale/beds.fr.tr
Normal file
@ -0,0 +1,10 @@
|
||||
# textdomain: beds
|
||||
Fancy Bed=Lit chic
|
||||
Simple Bed=Lit simple
|
||||
This bed is already occupied!=
|
||||
You have to stop moving before going to bed!=
|
||||
Good morning.=Bonjour.
|
||||
@1 of @2 players are in bed=@1 joueur(s) sur @2 sont au lit
|
||||
Force night skip=Forcer le passage de la nuit
|
||||
You can only sleep at night.=Vous ne pouvez dormir que la nuit.
|
||||
Leave Bed=Se lever du lit
|
10
mods/beds/locale/beds.id.tr
Normal file
@ -0,0 +1,10 @@
|
||||
# textdomain: beds
|
||||
Fancy Bed=Ranjang Mewah
|
||||
Simple Bed=Ranjang Sederhana
|
||||
This bed is already occupied!=
|
||||
You have to stop moving before going to bed!=
|
||||
Good morning.=Selamat pagi.
|
||||
@1 of @2 players are in bed=@1 dari @2 pemain sedang tidur
|
||||
Force night skip=Paksa lewati malam
|
||||
You can only sleep at night.=Anda hanya dapat tidur pada waktu malam.
|
||||
Leave Bed=Tinggalkan Ranjang
|
10
mods/beds/locale/beds.it.tr
Normal file
@ -0,0 +1,10 @@
|
||||
# textdomain: beds
|
||||
Fancy Bed=Letto decorato
|
||||
Simple Bed=Letto semplice
|
||||
This bed is already occupied!=
|
||||
You have to stop moving before going to bed!=
|
||||
Good morning.=
|
||||
@1 of @2 players are in bed=
|
||||
Force night skip=
|
||||
You can only sleep at night.=
|
||||
Leave Bed=Alzati dal letto
|
10
mods/beds/locale/beds.jbo.tr
Normal file
@ -0,0 +1,10 @@
|
||||
# textdomain: beds
|
||||
Fancy Bed=lo selja'i ckana
|
||||
Simple Bed=lo sampu ckana
|
||||
This bed is already occupied!=.i lo ti ckana cu canlu
|
||||
You have to stop moving before going to bed!=lo nu do cando cu sarcu lo nu do sipna
|
||||
Good morning.=.i .uise'inai cerni
|
||||
@1 of @2 players are in bed=.i @1 cmima be lu'i @2 le pilno cu vreta lo ckana
|
||||
Force night skip=bapli le nu co'u nicte
|
||||
You can only sleep at night.=.i steci le ka nicte kei fa le ka do kakne le ka sipna ca pa ckaji be ce'u
|
||||
Leave Bed=cliva lo ckana
|
10
mods/beds/locale/beds.ms.tr
Normal file
@ -0,0 +1,10 @@
|
||||
# textdomain: beds
|
||||
Fancy Bed=Katil Beragam
|
||||
Simple Bed=Katil Biasa
|
||||
This bed is already occupied!=
|
||||
You have to stop moving before going to bed!=
|
||||
Good morning.=Selamat pagi.
|
||||
@1 of @2 players are in bed=@1 daripada @2 pemain sedang tidur
|
||||
Force night skip=Paksa langkau malam
|
||||
You can only sleep at night.=Anda hanya boleh tidur pada waktu malam.
|
||||
Leave Bed=Bangun
|
10
mods/beds/locale/beds.pt_BR.tr
Normal file
@ -0,0 +1,10 @@
|
||||
# textdomain: beds
|
||||
Fancy Bed=Cama Bonita
|
||||
Simple Bed=Cama Simples
|
||||
This bed is already occupied!=Esta cama já está ocupada!
|
||||
You have to stop moving before going to bed!=Você precisa parar de se mover antes de ir para cama!
|
||||
Good morning.=Bom dia.
|
||||
@1 of @2 players are in bed=@1 de @2 jogadores estão na cama
|
||||
Force night skip=Forçar o amanhecer
|
||||
You can only sleep at night.=Você só pode dormir à noite
|
||||
Leave Bed=Sair da Cama
|
10
mods/beds/locale/beds.ru.tr
Normal file
@ -0,0 +1,10 @@
|
||||
# textdomain: beds
|
||||
Fancy Bed=Детализированная Кровать
|
||||
Simple Bed=Обычная Кровать
|
||||
This bed is already occupied!=
|
||||
You have to stop moving before going to bed!=
|
||||
Good morning.=Доброе утро.
|
||||
@1 of @2 players are in bed=@1 из @2 игроков в кровати
|
||||
Force night skip=Пропустить ночь
|
||||
You can only sleep at night.=Вы можете спать только ночью.
|
||||
Leave Bed=Встать с кровати
|
10
mods/beds/locale/beds.se.tr
Normal file
@ -0,0 +1,10 @@
|
||||
# textdomain: beds
|
||||
Fancy Bed=Fin säng
|
||||
Simple Bed=Enkel Säng
|
||||
This bed is already occupied!=
|
||||
You have to stop moving before going to bed!=
|
||||
Good morning.= God morgon.
|
||||
@1 of @2 players are in bed=@1 av @2 spelar försöker sover.
|
||||
Force night skip=Tvinga över natten
|
||||
You can only sleep at night.=Du kan bara sova på natten.
|
||||
Leave Bed=Lämna Säng
|
10
mods/beds/locale/beds.sk.tr
Normal file
@ -0,0 +1,10 @@
|
||||
# textdomain: beds
|
||||
Fancy Bed=Pekná posteľ
|
||||
Simple Bed=Jednoduchá posteľ
|
||||
This bed is already occupied!=
|
||||
You have to stop moving before going to bed!=
|
||||
Good morning.=Dobré ráno.
|
||||
@1 of @2 players are in bed=@1 z @2 hráčov sú v posteli
|
||||
Force night skip=Nútene preskočiť noc
|
||||
You can only sleep at night.=Môžeš spať len v noci.
|
||||
Leave Bed=Opusti posteľ
|
10
mods/beds/locale/beds.zh_CN.tr
Normal file
@ -0,0 +1,10 @@
|
||||
# textdomain: beds
|
||||
Fancy Bed=花式床
|
||||
Simple Bed=简易床
|
||||
This bed is already occupied!=
|
||||
You have to stop moving before going to bed!=
|
||||
Good morning.=早安!
|
||||
@1 of @2 players are in bed=@2位玩家中的@1位在床上
|
||||
Force night skip=强制跳过夜晚
|
||||
You can only sleep at night.=你只能在晚上睡觉。
|
||||
Leave Bed=离开床
|
10
mods/beds/locale/beds.zh_TW.tr
Normal file
@ -0,0 +1,10 @@
|
||||
# textdomain: beds
|
||||
Fancy Bed=花式床
|
||||
Simple Bed=簡易床
|
||||
This bed is already occupied!=
|
||||
You have to stop moving before going to bed!=
|
||||
Good morning.=早安!
|
||||
@1 of @2 players are in bed=@2位玩家中的@1位在床上
|
||||
Force night skip=強制跳過夜晚
|
||||
You can only sleep at night.=你只能在晚上睡覺。
|
||||
Leave Bed=離開床
|
10
mods/beds/locale/template.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# textdomain: beds
|
||||
Fancy Bed=
|
||||
Simple Bed=
|
||||
This bed is already occupied!=
|
||||
You have to stop moving before going to bed!=
|
||||
Good morning.=
|
||||
@1 of @2 players are in bed=
|
||||
Force night skip=
|
||||
You can only sleep at night.=
|
||||
Leave Bed=
|
4
mods/beds/mod.conf
Normal file
@ -0,0 +1,4 @@
|
||||
name = beds
|
||||
description = beds which allows sleep, featured to (auto) skip the night.
|
||||
depends = default, wool
|
||||
optional_depends = player_api, pova, intllib
|
160
mods/beds/models/beds_fancy_bed.obj
Normal 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/beds_simple_bed.obj
Normal 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
|
BIN
mods/beds/screenshot.jpg
Normal file
After Width: | Height: | Size: 215 KiB |
5
mods/beds/settingtypes.txt
Normal file
@ -0,0 +1,5 @@
|
||||
enable_bed_respawn (Enable bed respawn) bool true
|
||||
|
||||
enable_bed_night_skip (Enable night skip) bool true
|
||||
|
||||
bed_sleep_divide (Division of players needed to skip night) float 2
|
@ -3,30 +3,44 @@ 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()
|
||||
@ -35,29 +49,53 @@ function beds.read_spawns()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
beds.read_spawns()
|
||||
|
||||
|
||||
function beds.save_spawns()
|
||||
|
||||
if not beds.spawn then
|
||||
return
|
||||
end
|
||||
|
||||
local data = {}
|
||||
local output = io.open(org_file, "w")
|
||||
|
||||
for k, v in pairs(beds.spawn) do
|
||||
table.insert(data, string.format("%.1f %.1f %.1f %s\n", v.x, v.y, v.z, k))
|
||||
end
|
||||
|
||||
output:write(table.concat(data))
|
||||
io.close(output)
|
||||
end
|
||||
|
||||
|
||||
function beds.set_spawns()
|
||||
|
||||
for name,_ in pairs(beds.player) do
|
||||
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local p = player:getpos()
|
||||
local p = player:get_pos()
|
||||
|
||||
-- but don't change spawn location if borrowing a bed
|
||||
if not minetest.is_protected(p, name) then
|
||||
beds.spawn[name] = p
|
||||
end
|
||||
end
|
||||
|
||||
beds.save_spawns()
|
||||
end
|
||||
|
||||
|
||||
function beds.remove_spawns_at(pos)
|
||||
|
||||
for name, p in pairs(beds.spawn) do
|
||||
|
||||
if vector.equals(vector.round(p), pos) then
|
||||
beds.spawn[name] = nil
|
||||
end
|
||||
end
|
||||
|
||||
beds.save_spawns()
|
||||
end
|
||||
|
Before Width: | Height: | Size: 540 B After Width: | Height: | Size: 364 B |
BIN
mods/beds/textures/beds_bed_blue.png
Normal file
After Width: | Height: | Size: 413 B |
Before Width: | Height: | Size: 537 B After Width: | Height: | Size: 366 B |
BIN
mods/beds/textures/beds_bed_fancy_pink.png
Normal file
After Width: | Height: | Size: 345 B |
Before Width: | Height: | Size: 390 B |
Before Width: | Height: | Size: 387 B |
Before Width: | Height: | Size: 296 B |
Before Width: | Height: | Size: 316 B |
Before Width: | Height: | Size: 561 B |
Before Width: | Height: | Size: 537 B |
Before Width: | Height: | Size: 611 B |
Before Width: | Height: | Size: 596 B |
Before Width: | Height: | Size: 583 B |
Before Width: | Height: | Size: 616 B |
Before Width: | Height: | Size: 495 B |
Before Width: | Height: | Size: 556 B |
BIN
mods/beds/textures/beds_fancy_bed.png
Normal file
After Width: | Height: | Size: 555 B |
BIN
mods/beds/textures/beds_fancy_bed_pink.png
Normal file
After Width: | Height: | Size: 632 B |
BIN
mods/beds/textures/beds_simple_bed.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
mods/beds/textures/beds_simple_bed_blue.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 143 B |
77
mods/boats/README.md
Normal file
@ -0,0 +1,77 @@
|
||||
minetest mod boats
|
||||
==========================
|
||||
|
||||
Boats improved for better performance and more realistic..
|
||||
|
||||
Information
|
||||
-----------
|
||||
|
||||
This mod is named `boats`, it features work from original mod,
|
||||
code changed to make it turn **quicker, better performance agains lag**,
|
||||
and if you hit the shore too hard the boat is destroyed and drops 3 wood
|
||||
|
||||
![screenshot.png](screenshot.png)
|
||||
|
||||
#### Additions by TenPlus1
|
||||
|
||||
changed by TenPlus1 to add some new features
|
||||
- boat is destroyed when crashing at speed (drops 3 wood)
|
||||
- boats drop after 10 seconds if no driver
|
||||
- boats can be damaged by mobs attacking player
|
||||
- Improve physics of boat by implementing drag force (thanks gnag65)
|
||||
- nil player check functions by misterskullz
|
||||
|
||||
Technical informaton
|
||||
--------------------
|
||||
|
||||
When crafted you can use by putting and right click on,
|
||||
then control with your directional keys:
|
||||
|
||||
#### Dependencies
|
||||
|
||||
* default
|
||||
* mesecons (optional)
|
||||
|
||||
#### Crafting
|
||||
|
||||
W = any thing from wood group
|
||||
|
||||
```
|
||||
|
||||
W W
|
||||
WWW
|
||||
```
|
||||
#### nodes
|
||||
|
||||
| Name | node | notes |
|
||||
| ------------ | --------------- | ----- |
|
||||
| Boat | boats:boat | it destroyed when crash at speed |
|
||||
|
||||
#### Controls (by default if not changed)
|
||||
|
||||
| Default key assigned | Action |
|
||||
| -------------------- | -------------------------------------- |
|
||||
| Right mouse button | Enter or exit boat when pointing at boat. |
|
||||
| Forward | Speed up. Slow down when moving backwards. |
|
||||
| Forward + backward | Enable cruise mode: accelerate to maximum speed without needing to hold. |
|
||||
| Backward | Slow down. Speed up when moving backwards. Disable cruise mode. |
|
||||
| Left | Turn to the left. Turn to the right when moving backwards. |
|
||||
| Right | Turn to the right. Turn to the left when moving backwards. |
|
||||
|
||||
Licence
|
||||
------
|
||||
|
||||
**Source code**
|
||||
|
||||
Modifications by TenPlus1
|
||||
Originally by PilzAdam (MIT)
|
||||
Various Minetest developers and contributors (MIT)
|
||||
|
||||
**Media (textures and model)**
|
||||
|
||||
Textures: Zeg9 (CC BY-SA 3.0)
|
||||
original Model thetoon and Zeg9 (CC BY-SA 3.0),
|
||||
modified by PavelS(SokolovPavel) (CC BY-SA 3.0),
|
||||
modified by sofar (CC BY-SA 3.0)
|
||||
|
||||
Check [lisence.txt](lisence.txt)
|
@ -1,15 +0,0 @@
|
||||
Minetest Game mod: boats
|
||||
========================
|
||||
See license.txt for license information.
|
||||
|
||||
Authors of source code
|
||||
----------------------
|
||||
Originally by PilzAdam (MIT)
|
||||
Various Minetest developers and contributors (MIT)
|
||||
|
||||
Authors of media (textures and model)
|
||||
-------------------------------------
|
||||
Textures: Zeg9 (CC BY-SA 3.0)
|
||||
Model: thetoon and Zeg9 (CC BY-SA 3.0),
|
||||
modified by PavelS(SokolovPavel) (CC BY-SA 3.0),
|
||||
modified by sofar (CC BY-SA 3.0)
|
@ -1 +1,3 @@
|
||||
default
|
||||
player_api?
|
||||
creative?
|
||||
|
@ -1,3 +1,33 @@
|
||||
-- boats/init.lua
|
||||
|
||||
local is_pa = minetest.get_modpath("player_api")
|
||||
|
||||
-- translation support and 5.x version check
|
||||
local S, is_50, is_53
|
||||
if minetest.get_translator ~= nil then
|
||||
S = minetest.get_translator("boats") -- 5.x translation function
|
||||
else
|
||||
if minetest.get_modpath("intllib") then
|
||||
dofile(minetest.get_modpath("intllib") .. "/init.lua")
|
||||
if intllib.make_gettext_pair then
|
||||
gettext, ngettext = intllib.make_gettext_pair() -- new gettext method
|
||||
else
|
||||
gettext = intllib.Getter() -- old text file method
|
||||
end
|
||||
S = gettext
|
||||
else -- boilerplate function
|
||||
S = function(str, ...)
|
||||
local args = {...}
|
||||
return str:gsub("@%d+", function(match)
|
||||
return args[tonumber(match:sub(2))]
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- check for minetest 5.x compatibility
|
||||
is_50 = minetest.has_feature("httpfetch_binary_data")
|
||||
is_53 = minetest.has_feature("direct_velocity_on_players") or minetest.has_feature("is_creative_enabled") or false
|
||||
|
||||
--
|
||||
-- Helper functions
|
||||
--
|
||||
@ -8,15 +38,6 @@ local function is_water(pos)
|
||||
end
|
||||
|
||||
|
||||
local function get_sign(i)
|
||||
if i == 0 then
|
||||
return 0
|
||||
else
|
||||
return i / math.abs(i)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function get_velocity(v, yaw, y)
|
||||
local x = -math.sin(yaw) * v
|
||||
local z = math.cos(yaw) * v
|
||||
@ -28,23 +49,41 @@ local function get_v(v)
|
||||
return math.sqrt(v.x ^ 2 + v.z ^ 2)
|
||||
end
|
||||
|
||||
local creative = minetest.settings:get_bool("creative_mode")
|
||||
|
||||
function is_creative_enabled(name)
|
||||
|
||||
if creative or minetest.check_player_privs(name, {creative = true}) then
|
||||
if is_53 then
|
||||
return minetest.is_creative_enabled(name)
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
--
|
||||
-- Boat entity
|
||||
--
|
||||
|
||||
local boat = {
|
||||
initial_properties = {
|
||||
physical = true,
|
||||
-- Warning: Do not change the position of the collisionbox top surface,
|
||||
-- lowering it causes the boat to fall through the world if underwater
|
||||
collisionbox = {-0.5, -0.35, -0.5, 0.5, 0.3, 0.5},
|
||||
visual = "mesh",
|
||||
mesh = "boats_boat.obj",
|
||||
textures = {"default_wood.png"},
|
||||
textures = {"default_wood.png"}
|
||||
},
|
||||
|
||||
driver = nil,
|
||||
v = 0,
|
||||
last_v = 0,
|
||||
removed = false
|
||||
removed = false,
|
||||
auto = false
|
||||
}
|
||||
|
||||
|
||||
@ -53,39 +92,58 @@ function boat.on_rightclick(self, clicker)
|
||||
return
|
||||
end
|
||||
local name = clicker:get_player_name()
|
||||
if self.driver and clicker == self.driver then
|
||||
self.driver = nil
|
||||
if self.driver and name == self.driver then
|
||||
-- Cleanup happens in boat.on_detach_child
|
||||
clicker:set_detach()
|
||||
default.player_attached[name] = false
|
||||
if is_pa then
|
||||
player_api.set_animation(clicker, "stand", 30)
|
||||
else
|
||||
default.player_set_animation(clicker, "stand", 30)
|
||||
local pos = clicker:getpos()
|
||||
end
|
||||
local pos = clicker:get_pos()
|
||||
pos = {x = pos.x, y = pos.y + 0.2, z = pos.z}
|
||||
minetest.after(0.1, function()
|
||||
clicker:setpos(pos)
|
||||
clicker:set_pos(pos)
|
||||
end)
|
||||
elseif not self.driver then
|
||||
local attach = clicker:get_attach()
|
||||
if attach and attach:get_luaentity() then
|
||||
local luaentity = attach:get_luaentity()
|
||||
if luaentity.driver then
|
||||
luaentity.driver = nil
|
||||
end
|
||||
clicker:set_detach()
|
||||
end
|
||||
self.driver = clicker
|
||||
clicker:set_attach(self.object, "",
|
||||
{x = 0, y = 11, z = -3}, {x = 0, y = 0, z = 0})
|
||||
{x = 0.5, y = 1, z = -3}, {x = 0, y = 0, z = 0})
|
||||
|
||||
self.driver = name
|
||||
if is_pa then
|
||||
player_api.player_attached[name] = true
|
||||
else
|
||||
default.player_attached[name] = true
|
||||
end
|
||||
|
||||
minetest.after(0.2, function()
|
||||
if is_pa then
|
||||
player_api.set_animation(clicker, "sit", 30)
|
||||
else
|
||||
default.player_set_animation(clicker, "sit", 30)
|
||||
end
|
||||
end)
|
||||
clicker:set_look_horizontal(self.object:getyaw())
|
||||
clicker:set_look_horizontal(self.object:get_yaw())
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- If driver leaves server while driving boat
|
||||
function boat.on_detach_child(self, child)
|
||||
if child and child:get_player_name() == self.driver then
|
||||
if is_pa then
|
||||
player_api.player_attached[child:get_player_name()] = false
|
||||
else
|
||||
default.player_attached[child:get_player_name()] = false
|
||||
end
|
||||
self.driver = nil
|
||||
self.auto = false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function boat.on_activate(self, staticdata, dtime_s)
|
||||
self.object:set_armor_groups({immortal = 1})
|
||||
self.object:set_armor_groups({fleshy = 100})
|
||||
if staticdata then
|
||||
self.v = tonumber(staticdata)
|
||||
end
|
||||
@ -102,21 +160,26 @@ function boat.on_punch(self, puncher)
|
||||
if not puncher or not puncher:is_player() or self.removed then
|
||||
return
|
||||
end
|
||||
if self.driver and puncher == self.driver then
|
||||
|
||||
local name = puncher:get_player_name()
|
||||
if self.driver and name == self.driver then
|
||||
self.driver = nil
|
||||
puncher:set_detach()
|
||||
default.player_attached[puncher:get_player_name()] = false
|
||||
if is_pa then
|
||||
player_api.player_attached[name] = false
|
||||
else
|
||||
default.player_attached[name] = false
|
||||
end
|
||||
end
|
||||
if not self.driver then
|
||||
self.removed = true
|
||||
local inv = puncher:get_inventory()
|
||||
if not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(puncher:get_player_name()))
|
||||
if not is_creative_enabled(name)
|
||||
or not inv:contains_item("main", "boats:boat") then
|
||||
local leftover = inv:add_item("main", "boats:boat")
|
||||
-- if no room in inventory add a replacement boat to the world
|
||||
if not leftover:is_empty() then
|
||||
minetest.add_item(self.object:getpos(), leftover)
|
||||
minetest.add_item(self.object:get_pos(), leftover)
|
||||
end
|
||||
end
|
||||
-- delay remove to ensure player is detached
|
||||
@ -128,46 +191,73 @@ end
|
||||
|
||||
|
||||
function boat.on_step(self, dtime)
|
||||
self.v = get_v(self.object:getvelocity()) * get_sign(self.v)
|
||||
if self.driver then
|
||||
local ctrl = self.driver:get_player_control()
|
||||
local yaw = self.object:getyaw()
|
||||
if ctrl.up then
|
||||
self.v = self.v + 0.1
|
||||
elseif ctrl.down then
|
||||
self.v = self.v - 0.1
|
||||
end
|
||||
if ctrl.left then
|
||||
if self.v < 0 then
|
||||
self.object:setyaw(yaw - (1 + dtime) * 0.03)
|
||||
else
|
||||
self.object:setyaw(yaw + (1 + dtime) * 0.03)
|
||||
end
|
||||
elseif ctrl.right then
|
||||
if self.v < 0 then
|
||||
self.object:setyaw(yaw + (1 + dtime) * 0.03)
|
||||
else
|
||||
self.object:setyaw(yaw - (1 + dtime) * 0.03)
|
||||
end
|
||||
end
|
||||
end
|
||||
local velo = self.object:getvelocity()
|
||||
if self.v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
||||
self.object:setpos(self.object:getpos())
|
||||
|
||||
-- after 10 seconds remove boat and drop as item if not boarded
|
||||
self.count = (self.count or 0) + dtime
|
||||
|
||||
if self.count > 10 then
|
||||
minetest.add_item(self.object:get_pos(), "boats:boat")
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
local s = get_sign(self.v)
|
||||
self.v = self.v - 0.02 * s
|
||||
if s ~= get_sign(self.v) then
|
||||
self.object:setvelocity({x = 0, y = 0, z = 0})
|
||||
self.v = 0
|
||||
return
|
||||
end
|
||||
if math.abs(self.v) > 5 then
|
||||
self.v = 5 * get_sign(self.v)
|
||||
end
|
||||
|
||||
local p = self.object:getpos()
|
||||
self.v = get_v(self.object:get_velocity()) * math.sign(self.v)
|
||||
if self.driver then
|
||||
self.count = 0 -- reset 10 second drop counter
|
||||
local driver_objref = minetest.get_player_by_name(self.driver)
|
||||
if driver_objref then
|
||||
local ctrl = driver_objref:get_player_control()
|
||||
if ctrl.up and ctrl.down then
|
||||
if not self.auto then
|
||||
self.auto = true
|
||||
minetest.chat_send_player(self.driver, S("Boat cruise mode on"))
|
||||
end
|
||||
elseif ctrl.down then
|
||||
self.v = self.v - dtime * 2.0
|
||||
if self.auto then
|
||||
self.auto = false
|
||||
minetest.chat_send_player(self.driver, S("Boat cruise mode off"))
|
||||
end
|
||||
elseif ctrl.up or self.auto then
|
||||
self.v = self.v + dtime * 2.0
|
||||
end
|
||||
if ctrl.left then
|
||||
if self.v < -0.001 then
|
||||
self.object:set_yaw(self.object:get_yaw() - dtime * 0.9)
|
||||
else
|
||||
self.object:set_yaw(self.object:get_yaw() + dtime * 0.9)
|
||||
end
|
||||
elseif ctrl.right then
|
||||
if self.v < -0.001 then
|
||||
self.object:set_yaw(self.object:get_yaw() + dtime * 0.9)
|
||||
else
|
||||
self.object:set_yaw(self.object:get_yaw() - dtime * 0.9)
|
||||
end
|
||||
end
|
||||
else
|
||||
-- If driver leaves server while driving 'driver' is present
|
||||
-- but driver objectref is nil. Reset boat properties.
|
||||
self.driver = nil
|
||||
self.auto = false
|
||||
end
|
||||
end
|
||||
local velo = self.object:get_velocity()
|
||||
if not self.driver and
|
||||
self.v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
||||
self.object:set_pos(self.object:get_pos())
|
||||
return
|
||||
end
|
||||
-- We need to preserve velocity sign to properly apply drag force
|
||||
-- while moving backward
|
||||
local drag = dtime * math.sign(self.v) * (0.01 + 0.0796 * self.v * self.v)
|
||||
-- If drag is larger than velocity, then stop horizontal movement
|
||||
if math.abs(self.v) <= math.abs(drag) then
|
||||
self.v = 0
|
||||
else
|
||||
self.v = self.v - drag
|
||||
end
|
||||
|
||||
local p = self.object:get_pos()
|
||||
p.y = p.y - 0.5
|
||||
local new_velo
|
||||
local new_acce = {x = 0, y = 0, z = 0}
|
||||
@ -179,13 +269,13 @@ function boat.on_step(self, dtime)
|
||||
else
|
||||
new_acce = {x = 0, y = -9.8, z = 0}
|
||||
end
|
||||
new_velo = get_velocity(self.v, self.object:getyaw(),
|
||||
self.object:getvelocity().y)
|
||||
self.object:setpos(self.object:getpos())
|
||||
new_velo = get_velocity(self.v, self.object:get_yaw(),
|
||||
self.object:get_velocity().y)
|
||||
self.object:set_pos(self.object:get_pos())
|
||||
else
|
||||
p.y = p.y + 1
|
||||
if is_water(p) then
|
||||
local y = self.object:getvelocity().y
|
||||
local y = self.object:get_velocity().y
|
||||
if y >= 5 then
|
||||
y = 5
|
||||
elseif y < 0 then
|
||||
@ -193,24 +283,48 @@ function boat.on_step(self, dtime)
|
||||
else
|
||||
new_acce = {x = 0, y = 5, z = 0}
|
||||
end
|
||||
new_velo = get_velocity(self.v, self.object:getyaw(), y)
|
||||
self.object:setpos(self.object:getpos())
|
||||
new_velo = get_velocity(self.v, self.object:get_yaw(), y)
|
||||
self.object:set_pos(self.object:get_pos())
|
||||
else
|
||||
new_acce = {x = 0, y = 0, z = 0}
|
||||
if math.abs(self.object:getvelocity().y) < 1 then
|
||||
local pos = self.object:getpos()
|
||||
if math.abs(self.object:get_velocity().y) < 1 then
|
||||
local pos = self.object:get_pos()
|
||||
pos.y = math.floor(pos.y) + 0.5
|
||||
self.object:setpos(pos)
|
||||
new_velo = get_velocity(self.v, self.object:getyaw(), 0)
|
||||
self.object:set_pos(pos)
|
||||
new_velo = get_velocity(self.v, self.object:get_yaw(), 0)
|
||||
else
|
||||
new_velo = get_velocity(self.v, self.object:getyaw(),
|
||||
self.object:getvelocity().y)
|
||||
self.object:setpos(self.object:getpos())
|
||||
new_velo = get_velocity(self.v, self.object:get_yaw(),
|
||||
self.object:get_velocity().y)
|
||||
self.object:set_pos(self.object:get_pos())
|
||||
end
|
||||
end
|
||||
end
|
||||
self.object:setvelocity(new_velo)
|
||||
self.object:setacceleration(new_acce)
|
||||
self.object:set_velocity(new_velo)
|
||||
self.object:set_acceleration(new_acce)
|
||||
|
||||
-- if boat comes to sudden stop then destroy boat and drop 3x wood
|
||||
if (self.v2 or 0) - self.v >= 3 then
|
||||
|
||||
if self.driver then
|
||||
--print ("Crash! with driver", self.v2 - self.v)
|
||||
local driver_objref = minetest.get_player_by_name(self.driver)
|
||||
default.player_attached[self.driver] = false
|
||||
driver_objref:set_detach()
|
||||
if is_pa then
|
||||
player_api.set_animation(driver_objref, "stand" , 30)
|
||||
else
|
||||
default.player_set_animation(driver_objref, "stand" , 30)
|
||||
end
|
||||
else
|
||||
--print ("Crash! no driver")
|
||||
end
|
||||
|
||||
minetest.add_item(self.object:get_pos(), "default:wood 3")
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
||||
self.v2 = self.v
|
||||
end
|
||||
|
||||
|
||||
@ -218,7 +332,7 @@ minetest.register_entity("boats:boat", boat)
|
||||
|
||||
|
||||
minetest.register_craftitem("boats:boat", {
|
||||
description = "Boat",
|
||||
description = S("Boat"),
|
||||
inventory_image = "boats_inventory.png",
|
||||
wield_image = "boats_wield.png",
|
||||
wield_scale = {x = 2, y = 2, z = 1},
|
||||
@ -230,7 +344,8 @@ minetest.register_craftitem("boats:boat", {
|
||||
local node = minetest.get_node(under)
|
||||
local udef = minetest.registered_nodes[node.name]
|
||||
if udef and udef.on_rightclick and
|
||||
not (placer and placer:get_player_control().sneak) then
|
||||
not (placer and placer:is_player() and
|
||||
placer:get_player_control().sneak) then
|
||||
return udef.on_rightclick(under, node, placer, itemstack,
|
||||
pointed_thing) or itemstack
|
||||
end
|
||||
@ -244,9 +359,11 @@ minetest.register_craftitem("boats:boat", {
|
||||
pointed_thing.under.y = pointed_thing.under.y + 0.5
|
||||
boat = minetest.add_entity(pointed_thing.under, "boats:boat")
|
||||
if boat then
|
||||
boat:setyaw(placer:get_look_horizontal())
|
||||
if not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(placer:get_player_name())) then
|
||||
if placer then
|
||||
boat:set_yaw(placer:get_look_horizontal())
|
||||
end
|
||||
local player_name = placer and placer:get_player_name() or ""
|
||||
if not is_creative_enabled(player_name) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
end
|
||||
@ -269,3 +386,6 @@ minetest.register_craft({
|
||||
recipe = "boats:boat",
|
||||
burntime = 20,
|
||||
})
|
||||
|
||||
|
||||
print ("[MOD] Boats loaded")
|
||||
|
@ -33,6 +33,7 @@ Copyright (C) 2012-2016 Zeg9
|
||||
Copyright (C) 2012-2016 thetoon
|
||||
Copyright (C) 2012-2016 PavelS(SokolovPavel)
|
||||
Copyright (C) 2016 sofar (sofar@foo-projects.org)
|
||||
Copyright (C) 2019 Bartosz (gang65@poczta.onet.pl)
|
||||
|
||||
You are free to:
|
||||
Share — copy and redistribute the material in any medium or format.
|
||||
|
3
mods/boats/mod.conf
Normal file
@ -0,0 +1,3 @@
|
||||
name = boats
|
||||
depends = default, creative
|
||||
optional_depends = player_api
|
BIN
mods/boats/screenshot.png
Normal file
After Width: | Height: | Size: 88 KiB |
@ -68,6 +68,12 @@ minetest.register_node("bones:bones", {
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_inventory():is_empty("main") then
|
||||
local inv = player:get_inventory()
|
||||
if inv:room_for_item("main", {name = "bones:bones"}) then
|
||||
inv:add_item("main", {name = "bones:bones"})
|
||||
else
|
||||
minetest.add_item(pos, "bones:bones")
|
||||
end
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end,
|
||||
|
56
mods/bucket/README.md
Normal file
@ -0,0 +1,56 @@
|
||||
minetest mod Bucket
|
||||
=========================
|
||||
|
||||
This mod is just bucket, but compatible with any engine
|
||||
|
||||
Information
|
||||
-----------
|
||||
|
||||
This mod must be named `bucket` it permits to handle liquids
|
||||
in a tool named bucket.
|
||||
|
||||
![screenshot.png](screenshot.png)
|
||||
|
||||
Tech information
|
||||
----------------
|
||||
|
||||
This mod sustitute default one, you must disable the default of minetest
|
||||
game if present or override it.
|
||||
|
||||
#### Dependencies
|
||||
|
||||
* default
|
||||
|
||||
Optional dependences:
|
||||
|
||||
* intllib
|
||||
* dungeon_loot
|
||||
|
||||
#### Nodes
|
||||
|
||||
It does not provide any new node.
|
||||
|
||||
#### Items tools
|
||||
|
||||
| Node name | Description name |
|
||||
| ----------------------- | --------------------- |
|
||||
| bucket:bucket_empty | Empty Bucket |
|
||||
| bucket:bucket_water | Water Bucket |
|
||||
| bucket:bucket_river_water | River Water Bucket |
|
||||
| bucket:bucket_lava | Lava Bucket |
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
#### Authors of source code
|
||||
|
||||
Kahrl <kahrl@gmx.net> (LGPLv2.1+)
|
||||
celeron55, Perttu Ahola <celeron55@gmail.com> (LGPLv2.1+)
|
||||
Various Minetest developers and contributors (LGPLv2.1+)
|
||||
|
||||
#### Authors of media (textures)
|
||||
|
||||
ElementW (CC BY-SA 3.0)
|
||||
|
||||
Check [license.txt](license.txt)
|
||||
|
@ -1,13 +1,56 @@
|
||||
Minetest Game mod: bucket
|
||||
minetest mod Bucket
|
||||
=========================
|
||||
See license.txt for license information.
|
||||
|
||||
Authors of source code
|
||||
----------------------
|
||||
Kahrl <kahrl@gmx.net> (LGPL 2.1)
|
||||
celeron55, Perttu Ahola <celeron55@gmail.com> (LGPL 2.1)
|
||||
Various Minetest developers and contributors (LGPL 2.1)
|
||||
This mod is just bucket, but compatible with any engine
|
||||
|
||||
Information
|
||||
-----------
|
||||
|
||||
This mod must be named `bucket` it permits to handle liquids
|
||||
in a tool named bucket.
|
||||
|
||||
![screenshot.png](screenshot.png)
|
||||
|
||||
Tech information
|
||||
----------------
|
||||
|
||||
This mod sustitute default one, you must disable the default of minetest
|
||||
game if present or override it.
|
||||
|
||||
#### Dependencies
|
||||
|
||||
* default
|
||||
|
||||
Optional dependences:
|
||||
|
||||
* intllib
|
||||
* dungeon_loot
|
||||
|
||||
#### Nodes
|
||||
|
||||
It does not provide any new node.
|
||||
|
||||
#### Items tools
|
||||
|
||||
| Node name | Description name |
|
||||
| ----------------------- | --------------------- |
|
||||
| bucket:bucket_empty | Empty Bucket |
|
||||
| bucket:bucket_water | Water Bucket |
|
||||
| bucket:bucket_river_water | River Water Bucket |
|
||||
| bucket:bucket_lava | Lava Bucket |
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
#### Authors of source code
|
||||
|
||||
Kahrl <kahrl@gmx.net> (LGPLv2.1+)
|
||||
celeron55, Perttu Ahola <celeron55@gmail.com> (LGPLv2.1+)
|
||||
Various Minetest developers and contributors (LGPLv2.1+)
|
||||
|
||||
#### Authors of media (textures)
|
||||
|
||||
Authors of media (textures)
|
||||
---------------------------
|
||||
ElementW (CC BY-SA 3.0)
|
||||
|
||||
Check [license.txt](license.txt)
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
default
|
||||
|
||||
intllib?
|
||||
|
1
mods/bucket/description.txt
Normal file
@ -0,0 +1 @@
|
||||
handle liquids in a tool named bucket
|
@ -1,15 +1,39 @@
|
||||
-- Minetest 0.4 mod: bucket
|
||||
-- Minetest mod: bucket
|
||||
-- See README.txt for licensing and other information.
|
||||
|
||||
-- Load support for MT game translation.
|
||||
local S
|
||||
|
||||
if minetest.get_translator ~= nil then
|
||||
S = minetest.get_translator("bucket") -- 5.x translation function
|
||||
else
|
||||
if minetest.get_modpath("intllib") then
|
||||
dofile(minetest.get_modpath("intllib") .. "/init.lua")
|
||||
if intllib.make_gettext_pair then
|
||||
gettext, ngettext = intllib.make_gettext_pair() -- new gettext method
|
||||
else
|
||||
gettext = intllib.Getter() -- old text file method
|
||||
end
|
||||
S = gettext
|
||||
else -- boilerplate function
|
||||
S = function(str, ...)
|
||||
local args = {...}
|
||||
return str:gsub("@%d+", function(match)
|
||||
return args[tonumber(match:sub(2))]
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_alias("bucket", "bucket:bucket_empty")
|
||||
minetest.register_alias("bucket_water", "bucket:bucket_water")
|
||||
minetest.register_alias("bucket_lava", "bucket:bucket_lava")
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'bucket:bucket_empty 1',
|
||||
output = "bucket:bucket_empty 1",
|
||||
recipe = {
|
||||
{'default:steel_ingot', '', 'default:steel_ingot'},
|
||||
{'', 'default:steel_ingot', ''},
|
||||
{"default:steel_ingot", "", "default:steel_ingot"},
|
||||
{"", "default:steel_ingot", ""},
|
||||
}
|
||||
})
|
||||
|
||||
@ -65,11 +89,13 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
|
||||
end
|
||||
|
||||
local node = minetest.get_node_or_nil(pointed_thing.under)
|
||||
if not node then return end
|
||||
local ndef = node and minetest.registered_nodes[node.name]
|
||||
|
||||
-- Call on_rightclick if the pointed node defines it
|
||||
if ndef and ndef.on_rightclick and
|
||||
user and not user:get_player_control().sneak then
|
||||
not (user and user:is_player() and
|
||||
user:get_player_control().sneak) then
|
||||
return ndef.on_rightclick(
|
||||
pointed_thing.under,
|
||||
node, user,
|
||||
@ -110,9 +136,9 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
|
||||
end
|
||||
|
||||
minetest.register_craftitem("bucket:bucket_empty", {
|
||||
description = "Empty Bucket",
|
||||
description = S("Empty Bucket"),
|
||||
inventory_image = "bucket.png",
|
||||
stack_max = 99,
|
||||
groups = {tool = 1},
|
||||
liquids_pointable = true,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if pointed_thing.type == "object" then
|
||||
@ -124,6 +150,7 @@ minetest.register_craftitem("bucket:bucket_empty", {
|
||||
end
|
||||
-- Check if pointing to a liquid source
|
||||
local node = minetest.get_node(pointed_thing.under)
|
||||
if not node then return end
|
||||
local liquiddef = bucket.liquids[node.name]
|
||||
local item_count = user:get_wielded_item():get_count()
|
||||
|
||||
@ -147,7 +174,7 @@ minetest.register_craftitem("bucket:bucket_empty", {
|
||||
if inv:room_for_item("main", {name=liquiddef.itemname}) then
|
||||
inv:add_item("main", liquiddef.itemname)
|
||||
else
|
||||
local pos = user:getpos()
|
||||
local pos = user:get_pos()
|
||||
pos.y = math.floor(pos.y + 0.5)
|
||||
minetest.add_item(pos, liquiddef.itemname)
|
||||
end
|
||||
@ -184,17 +211,23 @@ bucket.register_liquid(
|
||||
"default:water_flowing",
|
||||
"bucket:bucket_water",
|
||||
"bucket_water.png",
|
||||
"Water Bucket",
|
||||
{water_bucket = 1}
|
||||
S("Water Bucket"),
|
||||
{tool = 1, water_bucket = 1}
|
||||
)
|
||||
|
||||
-- River water source is 'liquid_renewable = false' to avoid horizontal spread
|
||||
-- of water sources in sloping rivers that can cause water to overflow
|
||||
-- riverbanks and cause floods.
|
||||
-- River water source is instead made renewable by the 'force renew' option
|
||||
-- used here.
|
||||
|
||||
bucket.register_liquid(
|
||||
"default:river_water_source",
|
||||
"default:river_water_flowing",
|
||||
"bucket:bucket_river_water",
|
||||
"bucket_river_water.png",
|
||||
"River Water Bucket",
|
||||
{water_bucket = 1},
|
||||
S("River Water Bucket"),
|
||||
{tool = 1, water_bucket = 1},
|
||||
true
|
||||
)
|
||||
|
||||
@ -203,7 +236,8 @@ bucket.register_liquid(
|
||||
"default:lava_flowing",
|
||||
"bucket:bucket_lava",
|
||||
"bucket_lava.png",
|
||||
"Lava Bucket"
|
||||
S("Lava Bucket"),
|
||||
{tool = 1}
|
||||
)
|
||||
|
||||
minetest.register_craft({
|
||||
@ -213,3 +247,16 @@ minetest.register_craft({
|
||||
replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}},
|
||||
})
|
||||
|
||||
-- Register buckets as dungeon loot
|
||||
if minetest.global_exists("dungeon_loot") then
|
||||
dungeon_loot.register({
|
||||
{name = "bucket:bucket_empty", chance = 0.55},
|
||||
-- water in deserts/ice or above ground, lava otherwise
|
||||
{name = "bucket:bucket_water", chance = 0.45,
|
||||
types = {"sandstone", "desert", "ice"}},
|
||||
{name = "bucket:bucket_water", chance = 0.45, y = {0, 32768},
|
||||
types = {"normal"}},
|
||||
{name = "bucket:bucket_lava", chance = 0.45, y = {-32768, -1},
|
||||
types = {"normal"}},
|
||||
})
|
||||
end
|
||||
|
5
mods/bucket/locale/bucket.de.tr
Normal file
@ -0,0 +1,5 @@
|
||||
# textdomain: bucket
|
||||
Empty Bucket=Leerer Eimer
|
||||
Water Bucket=Wassereimer
|
||||
River Water Bucket=Flusswassereimer
|
||||
Lava Bucket=Lavaeimer
|
5
mods/bucket/locale/bucket.eo.tr
Normal file
@ -0,0 +1,5 @@
|
||||
# textdomain: bucket
|
||||
Empty Bucket=Malplena Sitelo
|
||||
Water Bucket=Sitelo da Akvo
|
||||
River Water Bucket=Sitelo da Rivera Akvo
|
||||
Lava Bucket=Sitelo da Lafo
|
5
mods/bucket/locale/bucket.es.tr
Normal file
@ -0,0 +1,5 @@
|
||||
# textdomain: bucket
|
||||
Empty Bucket=Cubo vacío
|
||||
Water Bucket=Cubo con agua
|
||||
River Water Bucket=Cubo con agua de río
|
||||
Lava Bucket=Cubo con lava
|
5
mods/bucket/locale/bucket.fr.tr
Normal file
@ -0,0 +1,5 @@
|
||||
# textdomain: bucket
|
||||
Empty Bucket=Seau vide
|
||||
Water Bucket=Seau d'eau
|
||||
River Water Bucket=Seau d'eau de rivière
|
||||
Lava Bucket=Seau de lave
|
5
mods/bucket/locale/bucket.id.tr
Normal file
@ -0,0 +1,5 @@
|
||||
# textdomain: bucket
|
||||
Empty Bucket=Ember Kosong
|
||||
Water Bucket=Ember Air
|
||||
River Water Bucket=Ember Air Sungai
|
||||
Lava Bucket=Ember Lava
|
5
mods/bucket/locale/bucket.it.tr
Normal file
@ -0,0 +1,5 @@
|
||||
# textdomain: bucket
|
||||
Empty Bucket=Secchio vuoto
|
||||
Water Bucket=Secchio d'acqua
|
||||
River Water Bucket=Secchio d'acqua di fiume
|
||||
Lava Bucket=Secchio di lava
|
5
mods/bucket/locale/bucket.ja.tr
Normal file
@ -0,0 +1,5 @@
|
||||
# textdomain: bucket
|
||||
Empty Bucket=空のバケツ
|
||||
Water Bucket=水入りバケツ
|
||||
River Water Bucket=川の水入りバケツ
|
||||
Lava Bucket=溶岩入りバケツ
|
5
mods/bucket/locale/bucket.jbo.tr
Normal file
@ -0,0 +1,5 @@
|
||||
# textdomain: bucket
|
||||
Empty Bucket=lo baktu be no da
|
||||
Water Bucket=lo baktu be lo djacu
|
||||
River Water Bucket=lo baktu be lo rirxe djacu
|
||||
Lava Bucket=lo baktu be lo likro'i
|
5
mods/bucket/locale/bucket.ms.tr
Normal file
@ -0,0 +1,5 @@
|
||||
# textdomain: bucket
|
||||
Empty Bucket=Baldi Kosong
|
||||
Water Bucket=Baldi Air
|
||||
River Water Bucket=Baldi Air Sungai
|
||||
Lava Bucket=Baldi Lava
|
5
mods/bucket/locale/bucket.pt_BR.tr
Normal file
@ -0,0 +1,5 @@
|
||||
# textdomain: bucket
|
||||
Empty Bucket=Balde Vazio
|
||||
Water Bucket=Balde de Água
|
||||
River Water Bucket=Balde de Água do Rio
|
||||
Lava Bucket=Balde de Lava
|
5
mods/bucket/locale/bucket.ru.tr
Normal file
@ -0,0 +1,5 @@
|
||||
# textdomain: bucket
|
||||
Empty Bucket=Пустое Ведро
|
||||
Water Bucket=Ведро с Водой
|
||||
River Water Bucket=Ведро с Речной Водой
|
||||
Lava Bucket=Ведро с Лавой
|
5
mods/bucket/locale/bucket.sk.tr
Normal file
@ -0,0 +1,5 @@
|
||||
# textdomain: bucket
|
||||
Empty Bucket=Prázdne vedro
|
||||
Water Bucket=Vedro s vodou
|
||||
River Water Bucket=Vedro s vodou z rieky
|
||||
Lava Bucket=Vedro s lávou
|
5
mods/bucket/locale/bucket.sv.tr
Normal file
@ -0,0 +1,5 @@
|
||||
# textdomain: bucket
|
||||
Empty Bucket=Tom hink
|
||||
Water Bucket=Vattenhink
|
||||
River Water Bucket=Flodvattenshink
|
||||
Lava Bucket=Lavahink
|
5
mods/bucket/locale/bucket.uk.tr
Normal file
@ -0,0 +1,5 @@
|
||||
# textdomain: bucket
|
||||
Empty Bucket=Пусте Відро
|
||||
Water Bucket=Відро З Водою
|
||||
River Water Bucket=Відро З Річною Водою
|
||||
Lava Bucket=Відро З Лавою
|
5
mods/bucket/locale/bucket.zh_CN.tr
Normal file
@ -0,0 +1,5 @@
|
||||
# textdomain: bucket
|
||||
Empty Bucket=空桶
|
||||
Water Bucket=水桶
|
||||
River Water Bucket=河水桶
|
||||
Lava Bucket=岩浆桶
|
5
mods/bucket/locale/bucket.zh_TW.tr
Normal file
@ -0,0 +1,5 @@
|
||||
# textdomain: bucket
|
||||
Empty Bucket=空桶
|
||||
Water Bucket=水桶
|
||||
River Water Bucket=河水桶
|
||||
Lava Bucket=岩漿桶
|
5
mods/bucket/locale/template.txt
Normal file
@ -0,0 +1,5 @@
|
||||
# textdomain: bucket
|
||||
Empty Bucket=
|
||||
Water Bucket=
|
||||
River Water Bucket=
|
||||
Lava Bucket=
|
4
mods/bucket/mod.conf
Normal file
@ -0,0 +1,4 @@
|
||||
name = bucket
|
||||
description = handle liquids in a tool named bucket
|
||||
depends = default
|
||||
optional_depends = dungeon_loot
|
0
mods/bucket/textures/bucket.png
Executable file → Normal file
Before Width: | Height: | Size: 205 B After Width: | Height: | Size: 205 B |
74
mods/carts/README.md
Normal file
@ -0,0 +1,74 @@
|
||||
minetest mod Carts (formerly boost_cart)
|
||||
==========================
|
||||
|
||||
Carts and rails (formerly boost_cart)
|
||||
|
||||
Information
|
||||
-----------
|
||||
|
||||
This mod is named `carts`, it features work from `boost_cart` mod.
|
||||
This is improved rail carts mod and featured boots rails..
|
||||
|
||||
![screenshot.png](screenshot.png)
|
||||
|
||||
|
||||
#### Features
|
||||
|
||||
- A fast cart for your railway or roller coaster (up to 7 m/s!)
|
||||
- Boost and brake rails
|
||||
- Rail junction switching with the 'right-left' walking keys
|
||||
- Handbrake with the 'back' key
|
||||
|
||||
#### Additions by TenPlus1
|
||||
|
||||
- Mesecon detector rail added
|
||||
- 10 second cart drop when player or item not inside
|
||||
- Alias' set to replace rails from boost_cart mod
|
||||
|
||||
Technical informaton
|
||||
--------------------
|
||||
|
||||
Carts, based almost entirely on the mod boost_cart [1], which
|
||||
itself is based on (and fully compatible with) the carts mod [2]
|
||||
and the model was originally designed by stujones11 [3] (CC-0).
|
||||
|
||||
This mod can (and maybe must) replace the default carts mod of minetest game.
|
||||
|
||||
[1] https://github.com/SmallJoker/boost_cart/
|
||||
[2] https://github.com/PilzAdam/carts/
|
||||
[3] https://github.com/stujones11/railcart/
|
||||
|
||||
#### Dependencies
|
||||
|
||||
* default
|
||||
* mesecons (optional)
|
||||
|
||||
#### nodes
|
||||
|
||||
| Name | node | notes |
|
||||
| ------------ | --------------- | ----- |
|
||||
| Rail | carts:rail | to use and travel over rails with carts |
|
||||
| Bracke rails | carts:brakerail | rail to downgrade velocity of carts |
|
||||
| Powered rail | carts:powerrail | rail to impulse velocity of a cart |
|
||||
| Detector rail | carts:detectorrail | it depends on mesecons for detection of mese |
|
||||
|
||||
Alias:
|
||||
|
||||
| original | carts alias |
|
||||
| -------------------- | -------------- |
|
||||
| default:rail | carts:rail |
|
||||
| carts:copperrail | default:rail |
|
||||
| boost_cart:copperrail | default:rail |
|
||||
| boost_cart:powerrail | carts:powerrail |
|
||||
| boost_cart:brakerail | carts:brakerail |
|
||||
| boost_cart:detectorrail | carts:detectorrail |
|
||||
|
||||
Licence
|
||||
------
|
||||
|
||||
The model was originally designed by stujones11 [3] (CC-0).
|
||||
|
||||
Cart textures are based on original work from PixelBOX by Gambit (permissive
|
||||
license).
|
||||
|
||||
Check [lisence.txt](lisence.txt)
|
@ -1,22 +0,0 @@
|
||||
Carts (formerly boost_cart)
|
||||
==========================
|
||||
|
||||
Carts, based almost entirely on the mod boost_cart [1], which
|
||||
itself is based on (and fully compatible with) the carts mod [2].
|
||||
|
||||
The model was originally designed by stujones11 [3] (CC-0).
|
||||
|
||||
Cart textures are based on original work from PixelBOX (WTFPL).
|
||||
|
||||
|
||||
[1] https://github.com/SmallJoker/boost_cart/
|
||||
[2] https://github.com/PilzAdam/carts/
|
||||
[3] https://github.com/stujones11/railcart/
|
||||
|
||||
|
||||
Features
|
||||
----------
|
||||
- A fast cart for your railway or roller coaster (up to 7 m/s!)
|
||||
- Boost and brake rails
|
||||
- Rail junction switching with the 'right-left' walking keys
|
||||
- Handbrake with the 'back' key
|
@ -1,10 +1,23 @@
|
||||
-- carts/cart_entity.lua
|
||||
|
||||
-- support for MT game translation.
|
||||
local S = carts.get_translator
|
||||
|
||||
-- is mesecons enabled ?
|
||||
local HAVE_MESECONS_ENABLED = minetest.get_modpath("mesecons")
|
||||
if HAVE_MESECONS_ENABLED then
|
||||
dofile(minetest.get_modpath("carts") .. "/detector.lua")
|
||||
end
|
||||
|
||||
local cart_entity = {
|
||||
initial_properties = {
|
||||
physical = false, -- otherwise going uphill breaks
|
||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
visual = "mesh",
|
||||
mesh = "carts_cart.b3d",
|
||||
visual_size = {x=1, y=1},
|
||||
textures = {"carts_cart.png"},
|
||||
},
|
||||
|
||||
driver = nil,
|
||||
punched = false, -- used to re-send velocity and position
|
||||
@ -22,43 +35,49 @@ function cart_entity:on_rightclick(clicker)
|
||||
end
|
||||
local player_name = clicker:get_player_name()
|
||||
if self.driver and player_name == self.driver then
|
||||
self.driver = nil
|
||||
carts:manage_attachment(clicker, nil)
|
||||
elseif not self.driver then
|
||||
self.driver = player_name
|
||||
carts:manage_attachment(clicker, self.object)
|
||||
self.driver = player_name
|
||||
end
|
||||
end
|
||||
|
||||
function cart_entity:on_activate(staticdata, dtime_s)
|
||||
self.object:set_armor_groups({immortal=1})
|
||||
self.attached_items = {} -- needed to stop itemcount glitch
|
||||
if string.sub(staticdata, 1, string.len("return")) ~= "return" then
|
||||
return
|
||||
end
|
||||
local data = minetest.deserialize(staticdata)
|
||||
if not data or type(data) ~= "table" then
|
||||
if type(data) ~= "table" then
|
||||
return
|
||||
end
|
||||
self.railtype = data.railtype
|
||||
if data.old_dir then
|
||||
self.old_dir = data.old_dir
|
||||
end
|
||||
if data.old_vel then
|
||||
self.old_vel = data.old_vel
|
||||
end
|
||||
end
|
||||
|
||||
function cart_entity:get_staticdata()
|
||||
return minetest.serialize({
|
||||
railtype = self.railtype,
|
||||
old_dir = self.old_dir,
|
||||
old_vel = self.old_vel
|
||||
old_dir = self.old_dir
|
||||
})
|
||||
end
|
||||
|
||||
-- 0.5.x and later: When the driver leaves
|
||||
function cart_entity:on_detach_child(child)
|
||||
if child and child:get_player_name() == self.driver then
|
||||
-- Clean up eye height
|
||||
carts:manage_attachment(child, nil)
|
||||
self.driver = nil
|
||||
end
|
||||
end
|
||||
|
||||
function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
|
||||
local pos = self.object:getpos()
|
||||
if not self.railtype then
|
||||
local pos = self.object:get_pos()
|
||||
local vel = self.object:get_velocity()
|
||||
if not self.railtype or vector.equals(vel, {x=0, y=0, z=0}) then
|
||||
local node = minetest.get_node(pos).name
|
||||
self.railtype = minetest.get_item_group(node, "connect_to_raillike")
|
||||
end
|
||||
@ -80,7 +99,7 @@ function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities,
|
||||
-- Detach driver and items
|
||||
if self.driver then
|
||||
if self.old_pos then
|
||||
self.object:setpos(self.old_pos)
|
||||
self.object:set_pos(self.old_pos)
|
||||
end
|
||||
local player = minetest.get_player_by_name(self.driver)
|
||||
carts:manage_attachment(player, nil)
|
||||
@ -98,14 +117,13 @@ function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities,
|
||||
local leftover = inv:add_item("main", "carts:cart")
|
||||
-- If no room in inventory add a replacement cart to the world
|
||||
if not leftover:is_empty() then
|
||||
minetest.add_item(self.object:getpos(), leftover)
|
||||
minetest.add_item(self.object:get_pos(), leftover)
|
||||
end
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
-- Player punches cart to alter velocity
|
||||
local vel = self.object:getvelocity()
|
||||
if puncher:get_player_name() == self.driver then
|
||||
if math.abs(vel.x + vel.z) > carts.punch_speed_max then
|
||||
return
|
||||
@ -120,7 +138,8 @@ function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities,
|
||||
end
|
||||
|
||||
local punch_interval = 1
|
||||
if tool_capabilities and tool_capabilities.full_punch_interval then
|
||||
-- Faulty tool registrations may cause the interval to be set to 0 !
|
||||
if tool_capabilities and (tool_capabilities.full_punch_interval or 0) > 0 then
|
||||
punch_interval = tool_capabilities.full_punch_interval
|
||||
end
|
||||
time_from_last_punch = math.min(time_from_last_punch or punch_interval, punch_interval)
|
||||
@ -152,7 +171,10 @@ local function rail_sound(self, dtime)
|
||||
self.sound_handle = nil
|
||||
minetest.after(0.2, minetest.sound_stop, handle)
|
||||
end
|
||||
local vel = self.object:getvelocity()
|
||||
local vel = self.object:get_velocity()
|
||||
|
||||
if not vel then return end -- nil check
|
||||
|
||||
local speed = vector.length(vel)
|
||||
if speed > 0 then
|
||||
self.sound_handle = minetest.sound_play(
|
||||
@ -169,32 +191,42 @@ local function get_railparams(pos)
|
||||
return carts.railparams[node.name] or {}
|
||||
end
|
||||
|
||||
local v3_len = vector.length
|
||||
local function rail_on_step(self, dtime)
|
||||
local vel = self.object:getvelocity()
|
||||
|
||||
-- if cart contains nothing then drop as item after 10 seconds
|
||||
if not self.driver and #self.attached_items == 0 then
|
||||
self.count = (self.count or 0) + dtime
|
||||
|
||||
if self.count > 10 then
|
||||
minetest.add_item(self.object:get_pos(), "carts:cart")
|
||||
if self.sound_handle then
|
||||
local handle = self.sound_handle
|
||||
self.sound_handle = nil
|
||||
minetest.after(0.2, minetest.sound_stop, handle)
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
else
|
||||
self.count = 0
|
||||
end
|
||||
|
||||
local vel = self.object:get_velocity()
|
||||
if self.punched then
|
||||
vel = vector.add(vel, self.velocity)
|
||||
self.object:setvelocity(vel)
|
||||
self.object:set_velocity(vel)
|
||||
self.old_dir.y = 0
|
||||
elseif vector.equals(vel, {x=0, y=0, z=0}) then
|
||||
return
|
||||
end
|
||||
|
||||
local pos = self.object:getpos()
|
||||
local pos = self.object:get_pos()
|
||||
local cart_dir = carts:velocity_to_dir(vel)
|
||||
local same_dir = vector.equals(cart_dir, self.old_dir)
|
||||
local update = {}
|
||||
|
||||
-- stop cart if velocity vector flips
|
||||
if self.old_vel and self.old_vel.y == 0 and
|
||||
(self.old_vel.x * vel.x < 0 or self.old_vel.z * vel.z < 0) then
|
||||
self.old_vel = {x = 0, y = 0, z = 0}
|
||||
self.old_pos = pos
|
||||
self.object:setvelocity(vector.new())
|
||||
self.object:setacceleration(vector.new())
|
||||
rail_on_step_event(get_railparams(pos).on_step, self, dtime)
|
||||
return
|
||||
end
|
||||
self.old_vel = vector.new(vel)
|
||||
|
||||
if self.old_pos and not self.punched then
|
||||
if self.old_pos and not self.punched and same_dir then
|
||||
local flo_pos = vector.round(pos)
|
||||
local flo_old = vector.round(self.old_pos)
|
||||
if vector.equals(flo_pos, flo_old) then
|
||||
@ -213,20 +245,29 @@ local function rail_on_step(self, dtime)
|
||||
end
|
||||
end
|
||||
|
||||
if self.old_pos then
|
||||
-- Detection for "skipping" nodes
|
||||
local found_path = carts:pathfinder(
|
||||
pos, self.old_pos, self.old_dir, ctrl, self.old_switch, self.railtype
|
||||
local stop_wiggle = false
|
||||
if self.old_pos and same_dir then
|
||||
-- Detection for "skipping" nodes (perhaps use average dtime?)
|
||||
-- It's sophisticated enough to take the acceleration in account
|
||||
local acc = self.object:get_acceleration()
|
||||
local distance = dtime * (v3_len(vel) + 0.5 * dtime * v3_len(acc))
|
||||
|
||||
local new_pos, new_dir = carts:pathfinder(
|
||||
pos, self.old_pos, self.old_dir, distance, ctrl,
|
||||
self.old_switch, self.railtype
|
||||
)
|
||||
|
||||
if not found_path then
|
||||
-- No rail found: reset back to the expected position
|
||||
pos = vector.new(self.old_pos)
|
||||
if new_pos then
|
||||
-- No rail found: set to the expected position
|
||||
pos = new_pos
|
||||
update.pos = true
|
||||
cart_dir = new_dir
|
||||
end
|
||||
elseif self.old_pos and self.old_dir.y ~= 1 and not self.punched then
|
||||
-- Stop wiggle
|
||||
stop_wiggle = true
|
||||
end
|
||||
|
||||
local cart_dir = carts:velocity_to_dir(vel)
|
||||
local railparams
|
||||
|
||||
-- dir: New moving direction of the cart
|
||||
@ -234,16 +275,25 @@ local function rail_on_step(self, dtime)
|
||||
local dir, switch_keys = carts:get_rail_direction(
|
||||
pos, cart_dir, ctrl, self.old_switch, self.railtype
|
||||
)
|
||||
local dir_changed = not vector.equals(dir, self.old_dir)
|
||||
|
||||
local new_acc = {x=0, y=0, z=0}
|
||||
if vector.equals(dir, {x=0, y=0, z=0}) then
|
||||
if stop_wiggle or vector.equals(dir, {x=0, y=0, z=0}) then
|
||||
vel = {x = 0, y = 0, z = 0}
|
||||
pos = vector.round(pos)
|
||||
local pos_r = vector.round(pos)
|
||||
if not carts:is_rail(pos_r, self.railtype)
|
||||
and self.old_pos then
|
||||
pos = self.old_pos
|
||||
elseif not stop_wiggle then
|
||||
pos = pos_r
|
||||
else
|
||||
pos.y = math.floor(pos.y + 0.5)
|
||||
end
|
||||
update.pos = true
|
||||
update.vel = true
|
||||
else
|
||||
-- Direction change detected
|
||||
if not vector.equals(dir, self.old_dir) then
|
||||
if dir_changed then
|
||||
vel = vector.multiply(dir, math.abs(vel.x + vel.z))
|
||||
update.vel = true
|
||||
if dir.y ~= self.old_dir.y then
|
||||
@ -284,6 +334,11 @@ local function rail_on_step(self, dtime)
|
||||
new_acc = vector.multiply(dir, acc)
|
||||
end
|
||||
|
||||
-- mesecon detector rail
|
||||
if HAVE_MESECONS_ENABLED then
|
||||
carts:signal_detector_rail(vector.round(pos))
|
||||
end
|
||||
|
||||
-- Limits
|
||||
local max_vel = carts.speed_max
|
||||
for _, v in pairs({"x","y","z"}) do
|
||||
@ -294,9 +349,9 @@ local function rail_on_step(self, dtime)
|
||||
end
|
||||
end
|
||||
|
||||
self.object:setacceleration(new_acc)
|
||||
self.old_pos = vector.new(pos)
|
||||
if not vector.equals(dir, {x=0, y=0, z=0}) then
|
||||
self.object:set_acceleration(new_acc)
|
||||
self.old_pos = vector.round(pos)
|
||||
if not vector.equals(dir, {x=0, y=0, z=0}) and not stop_wiggle then
|
||||
self.old_dir = vector.new(dir)
|
||||
end
|
||||
self.old_switch = switch_keys
|
||||
@ -306,7 +361,7 @@ local function rail_on_step(self, dtime)
|
||||
for _, obj_ in pairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||
if not obj_:is_player() and
|
||||
obj_:get_luaentity() and
|
||||
not obj_:get_luaentity().physical_state and
|
||||
-- not obj_:get_luaentity().physical_state and
|
||||
obj_:get_luaentity().name == "__builtin:item" then
|
||||
|
||||
obj_:set_attach(self.object, "", {x=0, y=0, z=0}, {x=0, y=0, z=0})
|
||||
@ -332,7 +387,7 @@ local function rail_on_step(self, dtime)
|
||||
elseif self.old_dir.z < 0 then
|
||||
yaw = 1
|
||||
end
|
||||
self.object:setyaw(yaw * math.pi)
|
||||
self.object:set_yaw(yaw * math.pi)
|
||||
|
||||
local anim = {x=0, y=0}
|
||||
if dir.y == -1 then
|
||||
@ -342,9 +397,15 @@ local function rail_on_step(self, dtime)
|
||||
end
|
||||
self.object:set_animation(anim, 1, 0)
|
||||
|
||||
self.object:setvelocity(vel)
|
||||
if update.vel then
|
||||
self.object:set_velocity(vel)
|
||||
end
|
||||
if update.pos then
|
||||
self.object:setpos(pos)
|
||||
if dir_changed then
|
||||
self.object:set_pos(pos)
|
||||
else
|
||||
self.object:move_to(pos)
|
||||
end
|
||||
end
|
||||
|
||||
-- call event handler
|
||||
@ -359,15 +420,17 @@ end
|
||||
minetest.register_entity("carts:cart", cart_entity)
|
||||
|
||||
minetest.register_craftitem("carts:cart", {
|
||||
description = "Cart (Sneak+Click to pick up)",
|
||||
inventory_image = minetest.inventorycube("carts_cart_top.png", "carts_cart_side.png", "carts_cart_side.png"),
|
||||
description = S("Cart") .. "\n" .. S("(Sneak+Click to pick up)"),
|
||||
inventory_image = minetest.inventorycube(
|
||||
"carts_cart_top.png", "carts_cart_front.png", "carts_cart_side.png"),
|
||||
wield_image = "carts_cart_side.png",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local under = pointed_thing.under
|
||||
local node = minetest.get_node(under)
|
||||
local udef = minetest.registered_nodes[node.name]
|
||||
if udef and udef.on_rightclick and
|
||||
not (placer and placer:get_player_control().sneak) then
|
||||
not (placer and placer:is_player() and
|
||||
placer:get_player_control().sneak) then
|
||||
return udef.on_rightclick(under, node, placer, itemstack,
|
||||
pointed_thing) or itemstack
|
||||
end
|
||||
@ -384,10 +447,11 @@ minetest.register_craftitem("carts:cart", {
|
||||
end
|
||||
|
||||
minetest.sound_play({name = "default_place_node_metal", gain = 0.5},
|
||||
{pos = pointed_thing.above})
|
||||
{pos = pointed_thing.above}, true)
|
||||
|
||||
local player_name = placer and placer:get_player_name() or ""
|
||||
if not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(placer:get_player_name())) then
|
||||
and creative.is_enabled_for(player_name)) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
|
@ -1 +1,4 @@
|
||||
default
|
||||
intllib?
|
||||
mesecons?
|
||||
dungeon_loot?
|
||||
|
75
mods/carts/detector.lua
Normal file
@ -0,0 +1,75 @@
|
||||
|
||||
local mesecons_rules = mesecon.rules.flat
|
||||
|
||||
function carts:turnoff_detector_rail(pos)
|
||||
|
||||
local node = minetest.get_node(pos)
|
||||
|
||||
if minetest.get_item_group(node.name, "detector_rail") == 1 then
|
||||
|
||||
if node.name == "carts:detectorrail_on" then --has not been dug
|
||||
minetest.swap_node(pos, {name = "carts:detectorrail", param2 = node.param2})
|
||||
end
|
||||
|
||||
mesecon.receptor_off(pos, mesecons_rules)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function carts:signal_detector_rail(pos)
|
||||
|
||||
local node = minetest.get_node(pos)
|
||||
|
||||
if minetest.get_item_group(node.name, "detector_rail") ~= 1 then
|
||||
return
|
||||
end
|
||||
|
||||
if node.name == "carts:detectorrail" then
|
||||
minetest.swap_node(pos, {name = "carts:detectorrail_on", param2 = node.param2})
|
||||
end
|
||||
|
||||
mesecon.receptor_on(pos, mesecons_rules)
|
||||
|
||||
minetest.after(0.5, carts.turnoff_detector_rail, carts, pos)
|
||||
end
|
||||
|
||||
|
||||
carts:register_rail("carts:detectorrail", {
|
||||
description = "Detector rail",
|
||||
tiles = {
|
||||
"carts_rail_straight_dtc.png", "carts_rail_curved_dtc.png",
|
||||
"carts_rail_t_junction_dtc.png", "carts_rail_crossing_dtc.png"
|
||||
},
|
||||
groups = carts:get_rail_groups({detector_rail = 1}),
|
||||
|
||||
mesecons = {receptor = {state = "off", rules = mesecons_rules}},
|
||||
})
|
||||
|
||||
minetest.register_alias("boost_cart:detectorrail", "carts:detectorrail")
|
||||
|
||||
|
||||
carts:register_rail("carts:detectorrail_on", {
|
||||
description = "Detector rail ON (you hacker you)",
|
||||
tiles = {
|
||||
"carts_rail_straight_dtc_on.png", "carts_rail_curved_dtc_on.png",
|
||||
"carts_rail_t_junction_dtc_on.png", "carts_rail_crossing_dtc_on.png"
|
||||
},
|
||||
groups = carts:get_rail_groups({
|
||||
detector_rail = 1, not_in_creative_inventory = 1
|
||||
}),
|
||||
drop = "carts:detectorrail",
|
||||
|
||||
mesecons = {receptor = {state = "on", rules = mesecons_rules}},
|
||||
})
|
||||
|
||||
minetest.register_alias("boost_cart:detectorrail_on", "carts:detectorrail_on")
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "boost_cart:detectorrail 6",
|
||||
recipe = {
|
||||
{"default:steel_ingot", "mesecons:wire_00000000_off", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "group:stick", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "mesecons:wire_00000000_off", "default:steel_ingot"},
|
||||
},
|
||||
})
|
@ -1,3 +1,5 @@
|
||||
local is_50 = minetest.get_translator
|
||||
|
||||
function carts:get_sign(z)
|
||||
if z == 0 then
|
||||
return 0
|
||||
@ -12,14 +14,28 @@ function carts:manage_attachment(player, obj)
|
||||
end
|
||||
local status = obj ~= nil
|
||||
local player_name = player:get_player_name()
|
||||
if default.player_attached[player_name] == status then
|
||||
if obj and player:get_attach() == obj then
|
||||
return
|
||||
end
|
||||
|
||||
if is_50 then
|
||||
player_api.player_attached[player_name] = status
|
||||
else
|
||||
default.player_attached[player_name] = status
|
||||
end
|
||||
|
||||
if status then
|
||||
player:set_attach(obj, "", {x=0, y=6, z=0}, {x=0, y=0, z=0})
|
||||
player:set_attach(obj, "", {x=0, y=-4.5, z=0}, {x=0, y=0, z=0})
|
||||
player:set_eye_offset({x=0, y=-4, z=0},{x=0, y=-4, z=0})
|
||||
|
||||
-- player_api does not update the animation
|
||||
-- when the player is attached, reset to default animation
|
||||
if is_50 then
|
||||
player_api.set_animation(player, "stand")
|
||||
else
|
||||
default.player_set_animation(player, "stand")
|
||||
end
|
||||
|
||||
else
|
||||
player:set_detach()
|
||||
player:set_eye_offset({x=0, y=0, z=0},{x=0, y=0, z=0})
|
||||
@ -99,6 +115,16 @@ function carts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
|
||||
right.z = -dir.x
|
||||
end
|
||||
|
||||
local straight_priority = ctrl and dir.y ~= 0
|
||||
|
||||
-- Normal, to disallow rail switching up- & downhill
|
||||
if straight_priority then
|
||||
cur = self:check_front_up_down(pos, dir, true, railtype)
|
||||
if cur then
|
||||
return cur
|
||||
end
|
||||
end
|
||||
|
||||
if ctrl then
|
||||
if old_switch == 1 then
|
||||
left_check = false
|
||||
@ -106,14 +132,14 @@ function carts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
|
||||
right_check = false
|
||||
end
|
||||
if ctrl.left and left_check then
|
||||
cur = carts:check_front_up_down(pos, left, false, railtype)
|
||||
cur = self:check_front_up_down(pos, left, false, railtype)
|
||||
if cur then
|
||||
return cur, 1
|
||||
end
|
||||
left_check = false
|
||||
end
|
||||
if ctrl.right and right_check then
|
||||
cur = carts:check_front_up_down(pos, right, false, railtype)
|
||||
cur = self:check_front_up_down(pos, right, false, railtype)
|
||||
if cur then
|
||||
return cur, 2
|
||||
end
|
||||
@ -122,10 +148,12 @@ function carts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
|
||||
end
|
||||
|
||||
-- Normal
|
||||
cur = carts:check_front_up_down(pos, dir, true, railtype)
|
||||
if not straight_priority then
|
||||
cur = self:check_front_up_down(pos, dir, true, railtype)
|
||||
if cur then
|
||||
return cur
|
||||
end
|
||||
end
|
||||
|
||||
-- Left, if not already checked
|
||||
if left_check then
|
||||
@ -158,27 +186,37 @@ function carts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
|
||||
return {x=0, y=0, z=0}
|
||||
end
|
||||
|
||||
function carts:pathfinder(pos_, old_pos, old_dir, ctrl, pf_switch, railtype)
|
||||
local pos = vector.round(pos_)
|
||||
local pf_pos = vector.round(old_pos)
|
||||
local pf_dir = vector.new(old_dir)
|
||||
function carts:pathfinder(pos_, old_pos, old_dir, distance, ctrl,
|
||||
pf_switch, railtype)
|
||||
|
||||
for i = 1, 3 do
|
||||
if vector.equals(pf_pos, pos) then
|
||||
-- Success! Cart moved on correctly
|
||||
return true
|
||||
local pos = vector.round(pos_)
|
||||
if vector.equals(old_pos, pos) then
|
||||
return
|
||||
end
|
||||
|
||||
pf_dir, pf_switch = carts:get_rail_direction(pf_pos, pf_dir, ctrl, pf_switch, railtype)
|
||||
local pf_pos = vector.round(old_pos)
|
||||
local pf_dir = vector.new(old_dir)
|
||||
distance = math.min(carts.path_distance_max,
|
||||
math.floor(distance + 1))
|
||||
|
||||
for i = 1, distance do
|
||||
pf_dir, pf_switch = self:get_rail_direction(
|
||||
pf_pos, pf_dir, ctrl, pf_switch or 0, railtype)
|
||||
|
||||
if vector.equals(pf_dir, {x=0, y=0, z=0}) then
|
||||
-- No way forwards
|
||||
return false
|
||||
return pf_pos, pf_dir
|
||||
end
|
||||
|
||||
pf_pos = vector.add(pf_pos, pf_dir)
|
||||
|
||||
if vector.equals(pf_pos, pos) then
|
||||
-- Success! Cart moved on correctly
|
||||
return
|
||||
end
|
||||
-- Cart not found
|
||||
return false
|
||||
end
|
||||
-- Not found. Put cart to predicted position
|
||||
return pf_pos, pf_dir
|
||||
end
|
||||
|
||||
function carts:register_rail(name, def_overwrite, railparams)
|
||||
@ -211,7 +249,12 @@ end
|
||||
|
||||
function carts:get_rail_groups(additional_groups)
|
||||
-- Get the default rail groups and add more when a table is given
|
||||
local groups = {dig_immediate = 2, attached_node = 1, rail = 1, connect_to_raillike = 1}
|
||||
local groups = {
|
||||
dig_immediate = 2,
|
||||
attached_node = 1,
|
||||
rail = 1,
|
||||
connect_to_raillike = minetest.raillike_group("rail")
|
||||
}
|
||||
if type(additional_groups) == "table" then
|
||||
for k, v in pairs(additional_groups) do
|
||||
groups[k] = v
|
||||
|
@ -1,20 +1,48 @@
|
||||
-- carts/init.lua
|
||||
|
||||
-- translation support
|
||||
local S
|
||||
if minetest.get_translator ~= nil then
|
||||
S = minetest.get_translator("carts") -- 5.x translation function
|
||||
else
|
||||
if minetest.get_modpath("intllib") then
|
||||
dofile(minetest.get_modpath("intllib") .. "/init.lua")
|
||||
if intllib.make_gettext_pair then
|
||||
gettext, ngettext = intllib.make_gettext_pair() -- new gettext method
|
||||
else
|
||||
gettext = intllib.Getter() -- old text file method
|
||||
end
|
||||
S = gettext
|
||||
else -- boilerplate function
|
||||
S = function(str, ...)
|
||||
local args = {...}
|
||||
return str:gsub("@%d+", function(match)
|
||||
return args[tonumber(match:sub(2))]
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
carts = {}
|
||||
carts.modpath = minetest.get_modpath("carts")
|
||||
carts.railparams = {}
|
||||
carts.get_translator = S
|
||||
|
||||
-- Maximal speed of the cart in m/s (min = -1)
|
||||
carts.speed_max = 7
|
||||
-- Set to -1 to disable punching the cart from inside (min = -1)
|
||||
carts.punch_speed_max = 5
|
||||
-- Maximal distance for the path correction (for dtime peaks)
|
||||
carts.path_distance_max = 3
|
||||
|
||||
|
||||
dofile(carts.modpath.."/functions.lua")
|
||||
dofile(carts.modpath.."/rails.lua")
|
||||
|
||||
-- Support for non-default games
|
||||
if not default.player_attached then
|
||||
default.player_attached = {}
|
||||
end
|
||||
|
||||
dofile(carts.modpath.."/cart_entity.lua")
|
||||
|
||||
-- Register rails as dungeon loot
|
||||
if minetest.global_exists("dungeon_loot") then
|
||||
dungeon_loot.register({
|
||||
name = "carts:rail", chance = 0.35, count = {1, 6}
|
||||
})
|
||||
end
|
||||
|