76 Commits

Author SHA1 Message Date
a9ac480dcd Set number of screwdriver uses to 200 2014-12-21 22:36:20 +01:00
1237bc3a4b Don't override param2 bits that are not used for rotation in screwdriver 2014-12-20 13:06:53 +01:00
854415fd33 Fix typo in furnace.lua 2014-12-13 12:52:47 +01:00
99cfe73bbf Give 4 obsidianbrick for 4 obsidian 2014-12-12 17:15:48 +01:00
697b39d40d Only allow rotating nodes that could be dug 2014-12-12 16:14:25 +01:00
2b7ca68805 Cleanup
* Remove unused variables
* Fix wearing out of screwdriver
* Move magic numbers into constants
* Scale down texture
2014-12-12 16:14:25 +01:00
bd24c15db4 Screwdriver rewrite 2014-12-12 16:14:24 +01:00
69614dc20d Pinetree (by sfan5, from mg mapgen) lua generation and sapling ABM. Add checks for ignore to other trees 2014-12-12 16:11:42 +01:00
75dfcdb1e7 Add 3D signs 2014-12-12 16:10:30 +01:00
c332081e81 Add white to the crack texture
This makes the crack stand out better on dark textures,
like obsidian and black wool.
2014-12-12 16:06:55 +01:00
608e51f16d Add obsidianbrick
use Zeg9`s texture
2014-12-12 16:04:27 +01:00
b0fb180e4d Use an overlay over default_dirt.png for soil 2014-12-07 19:46:23 +01:00
2ebd6b3839 Correct node definitons for pine saplings and pine needles 2014-12-07 11:57:37 +01:00
5a06de184c Rewrite furnace
* Move furnace related code into furnace.lua
* Move duplicated code into functions
* Rewrite ABM:
	* Easier to follow strcuture (no returns in the middle)
	* No unnecessary calls to get_craft_result
	* Split logic and "visual feedback" (a bit)
	* Fewer calls to meta:set and meta:get
	* Better feedback on the current state of the furnace
2014-12-06 21:18:02 +01:00
957f94534b Remove remains of finite liquids from bucket mod
This reverts commit 79856c914d.
2014-12-06 20:58:03 +01:00
4ec4672f01 Remove remains of weather 2014-12-06 20:58:03 +01:00
954d64afdc Add a minetest.conf.example with all available settings 2014-12-06 20:56:52 +01:00
ef0eb4d435 Move doc for dyes to game_api.txt 2014-12-06 20:54:53 +01:00
11a7b88434 Fix visibility of global/local dye tables 2014-12-06 20:54:02 +01:00
9ec33f34f1 Set param2 to 1 if player places leaves 2014-12-06 20:36:20 +01:00
2c2edfad04 Move leafdecay doc to game_api.txt 2014-12-06 20:36:20 +01:00
22dd46dcc6 Dont dry out soil if unloaded blocks are nearby 2014-12-06 11:54:56 +01:00
20f938e44a Allow the group book to be placed into bookshelfs 2014-12-06 11:46:04 +01:00
fd34872de8 Fix possible stacking of books in bookshelf
Original author: @MT-Modder
2014-12-06 11:43:07 +01:00
31edc5a9ff Add all saplings to group sapling 2014-12-03 17:26:01 +01:00
19bdcb26f6 Add missing groups to pine sapling 2014-12-03 17:26:01 +01:00
5b7db48372 Fix various fire sound bugs 2014-12-03 16:59:36 +01:00
128f0adb24 Fix some undeclared global variables 2014-11-30 18:02:33 +01:00
6fb072e5ff Pine tree, pine needles, pine sapling and pinewood nodes, including textures by Splizard and Cisoun 2014-11-30 17:47:02 +01:00
8007c142de Added the new door textures 2014-11-30 17:34:35 +01:00
e707ba3cf1 Fix leaked globals. 2014-11-29 18:03:18 +01:00
6680a51988 New ladder texture 2014-11-23 11:54:40 +01:00
3bf3249d71 Fix leaking globals in flowers and default mapgen.lua
Signed-off-by: Craig Robbins <kde.psych@gmail.com>
2014-11-22 00:24:49 +10:00
e71b71c1a9 Default and flowers: only run on-generated functions in mgv6. Remove indev ore definitions 2014-11-16 19:38:04 +01:00
a90338d40d New flower textures 2014-11-08 23:45:18 +01:00
929559fe85 Revert "Fix fire blocking sunlight"
This reverts commit dcce6e9795.
2014-11-08 23:25:40 +01:00
c41762d211 New grass(plant) and leaves textures 2014-11-08 22:54:00 +01:00
f06d4b8547 Vessels: new textures 2014-11-08 17:39:52 +01:00
dcce6e9795 Fix fire blocking sunlight 2014-11-04 16:17:56 -05:00
d57cb0a110 Boats mod improve y motion. Smaller collision box. Reverse turn with negative velocity only. Smooth turning. Enable underwater higher acceleration 2014-10-29 10:54:39 +00:00
ba8cbbcdbd Add new ore blocks textures 2014-10-05 08:49:55 +02:00
56cc4191ca Tweak some textures, new chest texture 2014-10-03 11:29:17 +02:00
6532978a58 Add improved grass textures by @Philipbenr (slightly modified), fixes #323 2014-10-03 11:29:10 +02:00
349a63ed14 Allow only boat driver to be detached from boat (fixes #276) 2014-10-03 03:20:31 +02:00
7f44a49d99 Use new optional framed glasslike drawtype 2014-10-02 11:51:47 +02:00
5047540db2 Make new textures fit existing style 2014-09-27 20:33:17 +02:00
9dfaab7f20 Some new textures (natural beauty texturepack) 2014-09-27 20:10:58 +02:00
8fe62ea7f6 Use new firelike drawtype 2014-09-21 22:25:00 +02:00
c4969665e7 Fix dye stuff, fixes #243 2014-09-16 19:40:50 +02:00
9670c27161 Clean up treegen code 2014-09-16 18:38:11 +02:00
c32957f942 Enable dungeons by default 2014-09-16 18:26:32 +02:00
c95cd8414b Fix xpanes API 2014-09-16 17:11:54 +02:00
cc2573acdf Remove API from player.lua
It's now in game_api.txt
2014-09-16 17:07:43 +02:00
44dc611088 Fix farming unloaded node crash 2014-09-06 20:36:40 -04:00
49a8ddc822 Make sand and some leaves sounds quieter 2014-08-22 11:52:51 +02:00
11c04e984d Localize player_attached 2014-08-21 16:49:30 +02:00
ef1f66a64e Fix some farming stuff 2014-08-21 16:48:48 +02:00
a1aee9a68f Fix door hardness detection for open/close sounds 2014-08-07 13:47:01 +02:00
Jat
5dbc738dbd Add API doors : Sound for door open and close. 2014-08-07 12:42:37 +02:00
5b5aa493b5 Fix boat flying up and some tweaks 2014-08-07 12:27:40 +02:00
6967232619 Fix TNT init for undefined enable_tnt setting 2014-07-25 23:29:44 -04:00
263b6f2fdf Show filled buckets in creative inventory 2014-07-24 13:41:17 +02:00
0ca4520cc2 Rewrite TNT 2014-07-22 12:05:40 -04:00
ea3fcdd077 Pair door with door of any type
Mirror the setup of a door placed next to any door, not just next to
a door of the same type.  This is particularly useful where there are
multiple door types that have the same appearance, but one wants the
doors of a pair to have different behaviour in some other respect.
2014-07-22 13:41:32 +02:00
820e48badc Make open trapdoor climbable
When a trapdoor is mounted upside down, to make its top surface flush
with the floor above when closed, it is necessary to have some way to
climb through the trapdoor node when it's open.  Making it climbable
like a ladder satisfies this need.  It is somewhat realistic, as a real
trapdoor can have a ladder segment mounted on one face.  When the trapdoor
is mounted in its default orientation, making the bottom surface flush
with the ceiling below when closed, the climbability when open is not
strictly necessary, but is still a convenience.
2014-07-22 13:04:45 +02:00
c39b9b29de Improve message about screwdriver control
The message to "hold shift" makes an unwarranted assumption about the
user's keybindings.  Messages from the server should refer to a key's
game function, rather than its extragame identity.
2014-07-22 13:04:20 +02:00
a8ad9bfc9d Consistently use group:stick in tool recipes
The left-handed recipes for axes were using default:stick instead of
the group:stick used by all other tool recipes.
2014-07-22 13:03:45 +02:00
d4c24a30e9 Retain sign text when editing is aborted by <esc> 2014-07-22 13:00:20 +02:00
c8845e8d44 Fix desert_sand_soil dropping itself, and changed the descriptions 2014-07-22 12:56:20 +02:00
5175897cdc Alias string to cotton
Cotton plants used to drop strings, now they drop farming:cotton. Some mods (namely, throwing) still use farming:string, therefore we need farming:string to be equal farming:cotton.
2014-07-13 20:04:14 +02:00
c521cb06bf Better ingot textures 2014-07-13 19:37:01 +02:00
3180bdfe6c Add protection to TNT (by @tenplus1) 2014-07-13 19:24:57 +02:00
c993e14084 Add spaces around operators in boat mod code, fix a problem with boat staticdata, fix a crash that can occur with boat going over unknown nodes. 2014-07-09 09:47:51 +02:00
955f3cf310 Fix crafting recipe for iron bars 2014-07-08 19:10:55 +02:00
814c17631d Fix jump-stacking 2014-07-08 16:50:06 +02:00
ca7f6bb97a Convert spaces to tabs and add unknown node checks to xpanes 2014-07-06 21:49:47 -04:00
926 changed files with 23466 additions and 20948 deletions

25
.gitignore vendored Executable file → Normal file
View File

@ -1,22 +1,7 @@
## Files related to minetest development cycle ## Generic ignorable patterns and files
/*.patch
# GNU Patch reject file
*.rej
## Editors and Development environments
*~ *~
*.swp .*.swp
*.bak* *bak*
*.orig tags
# Vim
*.vim *.vim
# Kate
.*.kate-swp
.swp.*
# Eclipse (LDT)
.project
.settings/
.buildpath
.metadata
# Idea IDE
.idea/*

29
README.txt Executable file → Normal file
View File

@ -1,24 +1,23 @@
Minetest Game [minetest_game] The main game for the Minetest game engine [minetest_game]
============================= ==========================================================
The main subgame for the Minetest engine
========================================
To use this subgame with the Minetest engine, insert this repository as To use this game with Minetest, insert this repository as
/games/minetest_game /games/minetest_game
in the Minetest Engine.
The Minetest engine can be found in: The Minetest Engine can be found in:
https://github.com/minetest/minetest/ https://github.com/minetest/minetest/
Compatibility Compatibility
-------------- --------------
The Minetest Game github master HEAD is generally compatible with the github The minetest_game github master HEAD is generally compatible with the github
master HEAD of the Minetest engine. master HEAD of minetest.
Additionally, when the Minetest engine is tagged to be a certain version (eg. Additionally, when the minetest engine is tagged to be a certain version (eg.
0.4.10), Minetest Game is tagged with the version too. 0.4.10), minetest_game is tagged with the version too.
When stable releases are made, Minetest Game is packaged and made available in When stable releases are made, minetest_game is packaged and made available in
http://minetest.net/download http://minetest.net/download.php
and in case the repository has grown too much, it may be reset. In that sense, and in case the repository has grown too much, it may be reset. In that sense,
this is not a "real" git repository. (Package maintainers please note!) this is not a "real" git repository. (Package maintainers please note!)
@ -50,4 +49,4 @@ Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
http://creativecommons.org/licenses/by-sa/3.0/ http://creativecommons.org/licenses/by-sa/3.0/
License of menu/header.png License of menu/header.png
Copyright (C) 2015 paramat CC BY-SA 3.0 Copyright (C) 2013 BlockMen CC BY-3.0

2
game.conf Executable file → Normal file
View File

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

767
game_api.txt Executable file → Normal file
View File

@ -1,652 +1,277 @@
Minetest Game API minetest_game API
================= ======================
GitHub Repo: https://github.com/minetest/minetest_game GitHub Repo: https://github.com/minetest/minetest_game
Introduction Introduction
------------ ------------
The minetest_game gamemode offers multiple new possibilities in addition to Minetest's built-in API, allowing you to
The Minetest Game subgame offers multiple new possibilities in addition to the Minetest engine's built-in API, add new plants to farming mod, buckets for new liquids, new stairs and custom panes.
allowing you to add new plants to farming mod, buckets for new liquids, new stairs and custom panes.
For information on the Minetest API, visit https://github.com/minetest/minetest/blob/master/doc/lua_api.txt For information on the Minetest API, visit https://github.com/minetest/minetest/blob/master/doc/lua_api.txt
Please note: Please note:
[XYZ] refers to a section the Minetest API
* [XYZ] refers to a section the Minetest API [#ABC] refers to a section in this document
* [#ABC] refers to a section in this document ^ Explanation for line above
* [pos] refers to a position table `{x = -5, y = 0, z = 200}`
Bucket API Bucket API
---------- ----------
The bucket API allows registering new types of buckets for non-default liquids. The bucket API allows registering new types of buckets for non-default liquids.
bucket.register_liquid( bucket.register_liquid(
"default:lava_source", -- name of the source node "default:lava_source", -- Source node name
"default:lava_flowing", -- name of the flowing node "default:lava_flowing", -- Flowing node name
"bucket:bucket_lava", -- name of the new bucket item (or nil if liquid is not takeable) "bucket:bucket_lava", -- Name to be used for bucket
"bucket_lava.png", -- texture of the new bucket item (ignored if itemname == nil) "bucket_lava.png", -- Bucket texture (for wielditem and inventory_image)
"Lava Bucket", -- text description of the bucket item "Lava Bucket" -- Bucket description
{lava_bucket = 1}, -- groups of the bucket item, OPTIONAL
false -- force-renew, OPTIONAL. Force the liquid source to renew if it has
-- a source neighbour, even if defined as 'liquid_renewable = false'.
-- Needed to avoid creating holes in sloping rivers.
) )
The filled bucket item is returned to the player that uses an empty bucket pointing to the given liquid source.
When punching with an empty bucket pointing to an entity or a non-liquid node, the on_punch of the entity or node will be triggered.
Beds API
--------
beds.register_bed(
"beds:bed", -- Bed name
def -- See [#Bed definition]
)
* `beds.read_spawns() ` Returns a table containing players respawn positions
* `beds.kick_players()` Forces all players to leave bed
* `beds.skip_night()` Sets world time to morning and saves respawn position of all players currently sleeping
### Bed definition
{
description = "Simple Bed",
inventory_image = "beds_bed.png",
wield_image = "beds_bed.png",
tiles = {
bottom = {'Tile definition'}, -- the tiles of the bottom part of the bed.
top = {Tile definition} -- the tiles of the bottom part of the bed.
},
nodebox = {
bottom = 'regular nodebox', -- bottom part of bed (see [Node boxes])
top = 'regular nodebox', -- top part of bed (see [Node boxes])
},
selectionbox = 'regular nodebox', -- for both nodeboxes (see [Node boxes])
recipe = { -- Craft recipe
{"group:wool", "group:wool", "group:wool"},
{"group:wood", "group:wood", "group:wood"}
}
}
Creative API
------------
A global string called `creative.formspec_add` was added which allows mods to add additional formspec elements onto the default creative inventory formspec to be drawn after each update.
Doors API Doors API
--------- ---------
The doors mod allows modders to register custom doors.
The doors mod allows modders to register custom doors and trapdoors. doors.register_door(name, def)
^ name: "Door name"
`doors.register_door(name, def)` ^ def: See [#Door definition]
* Registers new door #Door definition
* `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", description = "Door description",
inventory_image = "mod_door_inv.png", inventory_image = "mod_door_inv.png",
groups = {choppy = 2}, groups = {group = 1},
tiles = {"mod_door.png"}, -- UV map. tiles_bottom: [Tile definition],
recipe = craftrecipe, ^ the tiles of the bottom part of the door {front, side}
sounds = default.node_sound_wood_defaults(), -- optional tiles_top: [Tile definition],
sound_open = sound play for open door, -- optional ^ the tiles of the bottom part of the door {front, side}
sound_close = sound play for close door, -- optional node_box_bottom = regular nodebox, see [Node boxes], OPTIONAL,
protected = false, -- If true, only placer can open the door (locked for others) node_box_top = regular nodebox, see [Node boxes], OPTIONAL,
selection_box_bottom = regular nodebox, see [Node boxes], OPTIONAL,
### Trapdoor definition selection_box_top = regular nodebox, see [Node boxes], OPTIONAL,
sound_open_door = sound play for open door, OPTIONAL,
description = "Trapdoor description", sound_close_door = sound play for close door, OPTIONAL,
inventory_image = "mod_trapdoor_inv.png", only_placer_can_open = true/false,
groups = {choppy = 2}, ^ If true, only placer can open the door (locked for others)
tile_front = "doors_trapdoor.png", -- the texture for the front and back of the trapdoor }
tile_side = "doors_trapdoor_side.png", -- the tiles of the four side parts of the trapdoor
sounds = default.node_sound_wood_defaults(), -- optional
sound_open = sound play for open door, -- optional
sound_close = sound play for close door, -- optional
protected = false, -- If true, only placer can open the door (locked for others)
### Fence gate definition
description = "Wooden Fence Gate",
texture = "default_wood.png",
material = "default:wood",
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
sounds = default.node_sound_wood_defaults(), -- optional
Fence API
---------
Allows creation of new fences with "fencelike" drawtype.
`default.register_fence(name, item definition)`
Registers a new fence. Custom fields texture and material are required, as
are name and description. The rest is optional. You can pass most normal
nodedef fields here except drawtype. The fence group will always be added
for this node.
### fence definition
name = "default:fence_wood",
description = "Wooden Fence",
texture = "default_wood.png",
material = "default:wood",
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
sounds = default.node_sound_wood_defaults(),
Walls API
---------
The walls API allows easy addition of stone auto-connecting wall nodes.
walls.register(name, desc, texture, mat, sounds)
^ name = "walls:stone_wall". Node name.
^ desc = "A Stone wall"
^ texture = "default_stone.png"
^ mat = "default:stone". Used to auto-generate crafting recipe.
^ sounds = sounds: see [#Default sounds]
Farming API Farming API
----------- -----------
The farming API allows you to easily register plants and hoes. The farming API allows you to easily register plants and hoes.
`farming.register_hoe(name, hoe definition)` farming.register_hoe(name, hoe definition)
* Register a new hoe, see [#hoe definition] -> Register a new hoe, see [#hoe definition]
farming.register_plant(name, Plant definition)
-> Register a new growing plant, see [#Plant definition]
`farming.register_plant(name, Plant definition)` #Hoe 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
Nyancat API
-----------
`nyancat.place(pos, facedir, length)`
^ Place a cat at `pos` facing `facedir` with tail length `length`
Only accepts facedir 0-3, if facedir > 3 then it will be interpreted as facedir = 0
`nyancat.generate(minp, maxp, seed)`
^ Called by `minetest.register_on_generated`. To disable nyancat generation,
you can redefine nyancat.generate() to be an empty function
TNT API
----------
`tnt.register_tnt(definition)`
^ Register a new type of tnt.
* `name` The name of the node. If no prefix is given `tnt` is used.
* `description` A description for your TNT.
* `radius` The radius within which the TNT can destroy nodes. The default is 3.
* `damage_radius` The radius within which the TNT can damage players and mobs. By default it is twice the `radius`.
* `disable_drops` Disable drops. By default it is set to false.
* `ignore_protection` Don't check `minetest.is_protected` before removing a node.
* `ignore_on_blast` Don't call `on_blast` even if a node has one.
* `tiles` Textures for node
* `side` Side tiles. By default the name of the tnt with a suffix of `_side.png`.
* `top` Top tile. By default the name of the tnt with a suffix of `_top.png`.
* `bottom` Bottom tile. By default the name of the tnt with a suffix of `_bottom.png`.
* `burning` Top tile when lit. By default the name of the tnt with a suffix of `_top_burning_animated.png".
`tnt.boom(position, definition)`
^ Create an explosion.
* `position` The center of explosion.
* `definition` The TNT definion as passed to `tnt.register`
`tnt.burn(position, [nodename])`
^ Ignite TNT at position, nodename isn't required unless already known.
To make dropping items from node inventories easier, you can use the
following helper function from 'default':
default.get_inventory_drops(pos, inventory, drops)
^ Return drops from node inventory "inventory" in drops.
* `pos` - the node position
* `inventory` - the name of the inventory (string)
* `drops` - an initialized list
The function returns no values. The drops are returned in the `drops`
parameter, and drops is not reinitialized so you can call it several
times in a row to add more inventory items to it.
`on_blast` callbacks:
Both nodedefs and entitydefs can provide an `on_blast()` callback
`nodedef.on_blast(pos, intensity)`
^ Allow drop and node removal overriding
* `pos` - node position
* `intensity` - TNT explosion measure. larger or equal to 1.0
^ Should return a list of drops (e.g. {"default:stone"})
^ Should perform node removal itself. If callback exists in the nodedef
^ then the TNT code will not destroy this node.
`entitydef.on_blast(luaobj, damage)`
^ Allow TNT effects on entities to be overridden
* `luaobj` - LuaEntityRef of the entity
* `damage` - suggested HP damage value
^ Should return a list of (bool do_damage, bool do_knockback, table drops)
* `do_damage` - if true then TNT mod wil damage the entity
* `do_knockback` - if true then TNT mod will knock the entity away
* `drops` - a list of drops, e.g. {"wool:red"}
Screwdriver API
--------------- ---------------
{
description = "", -- Description for tooltip
inventory_image = "unknown_item.png", -- Image to be used as wield- and inventory image
max_uses = 30, -- Uses until destroyed
recipe = { -- Craft recipe
{"air", "air", "air"},
{"", "group:stick"},
{"", "group:stick"},
}
}
The screwdriver API allows you to control a node's behaviour when a screwdriver is used on it. #Plant definition
To use it, add the `on_screwdriver` function to the node definition. -----------------
{
`on_rotate(pos, node, user, mode, new_param2)` description = "", -- Description of seed item
inventory_image = "unknown_item.png", -- Image to be used as seed's wield- and inventory image
* `pos` Position of the node that the screwdriver is being used on steps = 8, -- How many steps the plant has to grow, until it can be harvested
* `node` that node ^ Always provide a plant texture for ech step, format: modname_plantname_i.png (i = stepnumber)
* `user` The player who used the screwdriver minlight = 13, -- Minimum light to grow
* `mode` screwdriver.ROTATE_FACE or screwdriver.ROTATE_AXIS maxlight = LIGHT_MAX -- Maximum light to grow
* `new_param2` the new value of param2 that would have been set if on_rotate wasn't there }
* return value: false to disallow rotation, nil to keep default behaviour, true to allow
it but to indicate that changed have already been made (so the screwdriver will wear out)
* use `on_rotate = false` to always disallow rotation
* use `on_rotate = screwdriver.rotate_simple` to allow only face rotation
Sethome API
-----------
The sethome API adds three global functions to allow mods to read a players home position,
set a players home position and teleport a player to home position.
`sethome.get(name)`
* `name` Player who's home position you wish to get
* return value: false if no player home coords exist, position table if true
`sethome.set(name, pos)`
* `name` Player who's home position you wish to set
* `pos` Position table containing coords of home position
* return value: false if unable to set and save new home position, otherwise true
`sethome.go(name)`
* `name` Player you wish to teleport to their home position
* return value: false if player cannot be sent home, otherwise true
Stairs API Stairs API
---------- ----------
The stairs API lets you register stairs and slabs and ensures that they are registered the same way as those The stairs API lets you register stairs and slabs and ensures that they are registered the same way as those
delivered with Minetest Game, to keep them compatible with other mods. delivered with minetest_game, to keep them compatible with other mods.
`stairs.register_stair(subname, recipeitem, groups, images, description, sounds)`
* 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
stairs.register_stair(subname, recipeitem, groups, images, description, sounds)
-> Registers a stair.
-> subname: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname"
-> recipeitem: Item used in the craft recipe, e.g. "default:cobble"
-> groups: see [Known damage and digging time defining groups]
-> images: see [Tile definition]
-> description: used for the description field in the stair's definition
-> sounds: see [#Default sounds]
stairs.register_slab(subname, recipeitem, groups, images, description, sounds)
-> Registers a 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 Xpanes API
---------- ----------
Creates panes that automatically connect to each other Creates panes that automatically connect to each other
`xpanes.register_pane(subname, def)` xpanes.register_pane(subname, def)
-> subname: used for nodename. Result: "xpanes:subname" and "xpanes:subname_{2..15}"
* `subname`: used for nodename. Result: "xpanes:subname" and "xpanes:subname_{2..15}" -> def: See [#Pane definition]
* `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.
#Pane definition
----------------
{
textures = {"texture_Bottom_top", "texture_left_right", "texture_front_back"},
^ 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
}
Default sounds Default sounds
-------------- --------------
Sounds inside the default table can be used within the sounds field of node definitions. Sounds inside the default table can be used within the sounds field of node definitions.
* `default.node_sound_defaults()` default.node_sound_defaults()
* `default.node_sound_stone_defaults()` default.node_sound_stone_defaults()
* `default.node_sound_dirt_defaults()` default.node_sound_dirt_defaults()
* `default.node_sound_sand_defaults()` default.node_sound_sand_defaults()
* `default.node_sound_wood_defaults()` default.node_sound_wood_defaults()
* `default.node_sound_leaves_defaults()` default.node_sound_leaves_defaults()
* `default.node_sound_glass_defaults()` default.node_sound_glass_defaults()
* `default.node_sound_metal_defaults()`
Default constants
-----------------
`default.LIGHT_MAX` The maximum light level (see [Node definition] light_source)
Player API Player API
---------- ----------
The player API can register player models and update the player's appearence The player API can register player models and update the player's appearence
`default.player_register_model(name, def)` default.player_register_model(name, def)
^ Register a new model to be used by players.
-> name: model filename such as "character.x", "foo.b3d", etc.
-> def: See [#Model definition]
* Register a new model to be used by players. default.registered_player_models[name]
* name: model filename such as "character.x", "foo.b3d", etc. ^ Get a model's definition
* def: See [#Model definition] -> see [#Model definition]
`default.registered_player_models[name]` default.player_set_model(player, model_name)
^ Change a player's model
-> player: PlayerRef
-> model_name: model registered with player_register_model()
* Get a model's definition default.player_set_animation(player, anim_name [, speed])
* see [#Model definition] ^ 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_model(player, model_name)` default.player_set_textures(player, textures)
^ Sets player textures
* Change a player's model -> player: PlayerRef
* `player`: PlayerRef -> textures: array of textures
* `model_name`: model registered with player_register_model() ^ If <textures> is nil, the default textures from the model def are used
`default.player_set_animation(player, anim_name [, speed])`
* Applies an animation to a player
* anim_name: name of the animation.
* speed: frames per second. If nil, default from the model is used
`default.player_set_textures(player, textures)`
* Sets player textures
* `player`: PlayerRef
* `textures`: array of textures, If `textures` is nil, the default textures from the model def are used
default.player_get_animation(player) default.player_get_animation(player)
^ Returns a table containing fields "model", "textures" and "animation".
^ Any of the fields of the returned table may be nil.
-> player: PlayerRef
* Returns a table containing fields `model`, `textures` and `animation`. Model Definition
* Any of the fields of the returned table may be nil. ----------------
* player: PlayerRef {
animation_speed = 30, -- Default animation speed, in FPS.
### Model Definition textures = {"character.png", }, -- Default array of textures.
visual_size = {x=1, y=1,}, -- Used to scale the model.
{ animations = {
animation_speed = 30, -- Default animation speed, in FPS. -- <anim_name> = { x=<start_frame>, y=<end_frame>, },
textures = {"character.png", }, -- Default array of textures. foo = { x= 0, y=19, },
visual_size = {x = 1, y = 1}, -- Used to scale the model. bar = { x=20, y=39, },
animations = {
-- <anim_name> = {x = <start_frame>, y = <end_frame>},
foo = {x = 0, y = 19},
bar = {x = 20, y = 39},
-- ... -- ...
}, },
} }
Leafdecay Leafdecay
--------- ---------
To enable leaf decay for a node, add it to the "leafdecay" group.
To enable leaf decay for a node, add it to the `leafdecay` group. The rating of the group determines how far from a node in the group "tree"
The rating of the group determines how far from a node in the group `tree`
the node can be without decaying. the node can be without decaying.
If `param2` of the node is ~= 0, the node will always be preserved. Thus, if If param2 of the node is ~= 0, the node will always be preserved. Thus, if
the player places a node of that kind, you will want to set `param2 = 1` or so. the 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` 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 to set param2 to 1 if the player places the node (should not be used for nodes
that use param2 otherwise (e.g. facedir)). that use param2 otherwise (e.g. facedir)).
If the node is in the `leafdecay_drop` group then it will always be dropped as an If the node is in the leafdecay_drop group then it will always be dropped as an
item. item.
Dyes Dyes
---- ----
To make recipes that will work with any dye ever made by anybody, define 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 them based on groups. You can select any group of groups, based on your need for
amount of colors. amount of colors.
### Color groups #Color groups
-------------
Base color groups: Base color groups:
- basecolor_white
- basecolor_grey
- basecolor_black
- basecolor_red
- basecolor_yellow
- basecolor_green
- basecolor_cyan
- basecolor_blue
- basecolor_magenta
* `basecolor_white` Extended color groups (* = equal to a base color):
* `basecolor_grey` * excolor_white
* `basecolor_black` - excolor_lightgrey
* `basecolor_red` * excolor_grey
* `basecolor_yellow` - excolor_darkgrey
* `basecolor_green` * excolor_black
* `basecolor_cyan` * excolor_red
* `basecolor_blue` - excolor_orange
* `basecolor_magenta` * excolor_yellow
- excolor_lime
Extended color groups ( * means also base color ) * excolor_green
- excolor_aqua
* `excolor_white` * * excolor_cyan
* `excolor_lightgrey` - excolor_sky_blue
* `excolor_grey` * * excolor_blue
* `excolor_darkgrey` - excolor_violet
* `excolor_black` * * excolor_magenta
* `excolor_red` * - excolor_red_violet
* `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: The whole unifieddyes palette as groups:
- unicolor_<excolor>
* `unicolor_<excolor>`
For the following, no white/grey/black is allowed: For the following, no white/grey/black is allowed:
- unicolor_medium_<excolor>
* `unicolor_medium_<excolor>` - unicolor_dark_<excolor>
* `unicolor_dark_<excolor>` - unicolor_light_<excolor>
* `unicolor_light_<excolor>` - unicolor_<excolor>_s50
* `unicolor_<excolor>_s50` - unicolor_medium_<excolor>_s50
* `unicolor_medium_<excolor>_s50` - unicolor_dark_<excolor>_s50
* `unicolor_dark_<excolor>_s50`
Example of one shapeless recipe using a color group: 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'},
})
minetest.register_craft({ #Color lists
type = "shapeless", ------------
output = '<mod>:item_yellow', dye.basecolors
recipe = {'<mod>:item_no_color', 'group:basecolor_yellow'}, ^ Array containing the names of available base colors
})
### Color lists dye.excolors
^ Array containing the names of the available extended colors
* `dye.basecolors` are an array containing the names of available base colors
* `dye.excolors` are an array containing the names of the available extended colors
Trees
-----
* `default.grow_tree(pos, is_apple_tree)`
* Grows a mgv6 tree or apple tree at pos
* `default.grow_jungle_tree(pos)`
* Grows a mgv6 jungletree at pos
* `default.grow_pine_tree(pos)`
* Grows a mgv6 pinetree at pos
* `default.grow_new_apple_tree(pos)`
* Grows a new design apple tree at pos
* `default.grow_new_jungle_tree(pos)`
* Grows a new design jungle tree at pos
* `default.grow_new_pine_tree(pos)`
* Grows a new design pine tree at pos
* `default.grow_new_acacia_tree(pos)`
* Grows a new design acacia tree at pos
* `default.grow_new_aspen_tree(pos)`
* Grows a new design aspen tree at pos
* `default.grow_new_snowy_pine_tree(pos)`
* Grows a new design snowy pine tree at pos

Binary file not shown.

Before

Width:  |  Height:  |  Size: 904 B

After

Width:  |  Height:  |  Size: 152 KiB

BIN
menu/icon.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

9
minetest.conf Executable file → Normal file
View File

@ -1,3 +1,6 @@
# Enable jungles on new worlds, disable biome blend and mud flow (faster, looks better). mg_flags = dungeons
mgv6_spflags = jungles, nobiomeblend, nomudflow mgv6_spflags = biomeblend, jungles
disable_fire = true
movement_liquid_sink = 25
movement_liquid_fluidity = 0.8
movement_liquid_fluidity_smooth = 2

35
minetest.conf.example Executable file → Normal file
View File

@ -1,47 +1,24 @@
# This file contains settings of Minetest Game that can be changed in minetest.conf # This file contains settings of minetest_game that can be changed in
# minetest.conf
#
# By default, all the settings are commented and not functional. # By default, all the settings are commented and not functional.
# Uncomment settings by removing the preceding #. # Uncomment settings by removing the preceding #.
# Whether creative mode (fast digging of all blocks, unlimited resources) should be enabled # Whether creative mode (fast digging of all blocks, unlimited resources) should be enabled
#creative_mode = false #creative_mode = false
# Sets the behaviour of the inventory items when a player dies.
# "bones": Store all items inside a bone node but drop items if inside protected area
# "drop": Drop all items on the ground
# "keep": Player keeps all items
#bones_mode = "bones"
# The time in seconds after which the bones of a dead player can be looted by everyone # The time in seconds after which the bones of a dead player can be looted by everyone
# 0 to disable # 0 to disable
#share_bones_time = 1200 #share_bones_time = 1200
# How much earlier the bones of a dead player can be looted by # Whether fire should be disabled (all fire nodes will instantly disappear)
# everyone if the player dies in a protected area they don't own. #disable_fire = false
# 0 to disable. By default it is "share_bones_time" divide by four.
#share_bones_time_early = 300
# Whether fire should be enabled. If disabled, 'basic flame' nodes will disappear. # Whether steel tools, torches and cobblestone should be given to new players
# 'permanent flame' nodes will remain with either setting.
#enable_fire = true
# Whether the stuff in initial_stuff should be given to new players
#give_initial_stuff = false #give_initial_stuff = false
#initial_stuff = default:pick_steel,default:axe_steel,default:shovel_steel,default:torch 99,default:cobble 99
# Whether the TNT mod should be enabled # Whether the TNT mod should be enabled
#enable_tnt = <true in singleplayer, false in multiplayer> #enable_tnt = <true in singleplayer, false in multiplayer>
# The radius of a TNT explosion # The radius of a TNT explosion
#tnt_radius = 3 #tnt_radius = 3
# Enable the stairs mod ABM that replaces the old 'upside down'
# stair and slab nodes in old maps with the new param2 versions.
#enable_stairs_replace_abm = false
# Whether you allow respawning in beds
# Default value is true
#enable_bed_respawn = true
# Whether players can skip night by sleeping
# Default value is true
#enable_bed_night_skip = true

View File

@ -1,9 +0,0 @@
----------------------------------------
-- Server Misc Mod - pre-default init --
----------------------------------------
local cwd = minetest.get_modpath(minetest.get_current_modname())
-- Inventory refill function override
-- see https://github.com/MinetestForFun/server-minetestforfun/issues/462
dofile(cwd.."/inventory_rotate_node.lua")

View File

@ -1,22 +0,0 @@
--rewrite function minetest.rotate_node(itemstack, placer, pointed_thing) to refill inventory
local old_rotate_node = minetest.rotate_node
function minetest.rotate_node(itemstack, placer, pointed_thing)
local stack_name = itemstack:get_name()
local ret = old_rotate_node(itemstack, placer, pointed_thing)
if ret:get_count() == 0 and not minetest.setting_getbool("creative_mode") then
local index = placer:get_wield_index()
local inv = placer:get_inventory()
if inv:get_list("main") then
for i, stack in ipairs(inv:get_list("main")) do
if i ~= index and stack:get_name() == stack_name then
ret:add_item(stack)
stack:clear()
inv:set_stack("main", i, stack)
minetest.log("action", "Inventory Tweaks: refilled stack("..stack_name..") of " .. placer:get_player_name())
break
end
end
end
end
return ret
end

View File

@ -1,30 +0,0 @@
Minetest Game mod: beds
=======================
by BlockMen (c) 2014-2015
Version: 1.1.1
About
~~~~~
This mod adds a bed to Minetest which allows to skip the night. To sleep rightclick the bed, if playing
in singleplayer mode the night gets skipped imideatly. If playing on server you get shown how many other
players are in bed too. If all players are sleeping the night gets skipped aswell. Also the night skip can be forced
if more than 50% of the players are lying in bed and use this option.
Another feature is a controled respawning. If you have slept in bed (not just lying in it) your respawn point
is set to the beds location and you will respawn there after death.
You can disable the respawn at beds by setting "enable_bed_respawn = false" in minetest.conf
You can also disable the night skip feature by setting "enable_bed_night_skip = false" in minetest.conf or by using
the /set command ingame.
License of source code, textures: WTFPL
---------------------------------------
(c) Copyright BlockMen (2014-2015)
This program is free software. It comes without any warranty, to
the extent permitted by applicable law. You can redistribute it
and/or modify it under the terms of the Do What The Fuck You Want
To Public License, Version 2, as published by Sam Hocevar. See
http://sam.zoy.org/wtfpl/COPYING for more details.

View File

@ -1,113 +0,0 @@
function beds.register_bed(name, def)
minetest.register_node(name .. "_bottom", {
description = def.description,
inventory_image = def.inventory_image,
wield_image = def.wield_image,
drawtype = "nodebox",
tiles = def.tiles.bottom,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
stack_max = 1,
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 1},
sounds = default.node_sound_wood_defaults(),
node_box = {
type = "fixed",
fixed = def.nodebox.bottom,
},
selection_box = {
type = "fixed",
fixed = def.selectionbox,
},
after_place_node = function(pos, placer, itemstack)
local n = minetest.get_node_or_nil(pos)
if not n or not n.param2 then
minetest.remove_node(pos)
return true
end
local dir = minetest.facedir_to_dir(n.param2)
local p = vector.add(pos, dir)
local n2 = minetest.get_node_or_nil(p)
local def = n2 and minetest.registered_items[n2.name]
if not def or not def.buildable_to then
minetest.remove_node(pos)
return true
end
minetest.set_node(p, {name = n.name:gsub("%_bottom", "_top"), param2 = n.param2})
return false
end,
on_destruct = function(pos)
local n = minetest.get_node_or_nil(pos)
if not n then return end
local dir = minetest.facedir_to_dir(n.param2)
local p = vector.add(pos, dir)
local n2 = minetest.get_node(p)
if minetest.get_item_group(n2.name, "bed") == 2 and n.param2 == n2.param2 then
minetest.remove_node(p)
end
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local name = digger:get_player_name()
if not name or name == "" then return end
beds.spawn[name] = nil
beds.save_spawns()
end,
on_rightclick = function(pos, node, clicker)
beds.on_rightclick(pos, clicker)
end,
on_rotate = function(pos, node, user, mode, new_param2)
local dir = minetest.facedir_to_dir(node.param2)
local p = vector.add(pos, dir)
local node2 = minetest.get_node_or_nil(p)
if not node2 or not minetest.get_item_group(node2.name, "bed") == 2 or
not node.param2 == node2.param2 then
return false
end
if minetest.is_protected(p, user:get_player_name()) then
minetest.record_protection_violation(p, user:get_player_name())
return false
end
if mode ~= screwdriver.ROTATE_FACE then
return false
end
local newp = vector.add(pos, minetest.facedir_to_dir(new_param2))
local node3 = minetest.get_node_or_nil(newp)
local def = node3 and minetest.registered_nodes[node3.name]
if not def or not def.buildable_to then
return false
end
if minetest.is_protected(newp, user:get_player_name()) then
minetest.record_protection_violation(newp, user:get_player_name())
return false
end
node.param2 = new_param2
minetest.swap_node(pos, node)
minetest.remove_node(p)
minetest.set_node(newp, {name = node.name:gsub("%_bottom", "_top"), param2 = new_param2})
return true
end,
})
minetest.register_node(name .. "_top", {
drawtype = "nodebox",
tiles = def.tiles.top,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
pointable = false,
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 2},
sounds = default.node_sound_wood_defaults(),
node_box = {
type = "fixed",
fixed = def.nodebox.top,
},
})
minetest.register_alias(name, name .. "_bottom")
-- register recipe
minetest.register_craft({
output = name,
recipe = def.recipe
})
end

View File

@ -1,92 +0,0 @@
for _, colour in pairs({"red", "white", "black", "blue", "green"}) do-- fancy shaped bed
beds.register_bed("beds:fancy_bed_" .. colour, {
description = "Fancy Bed (" .. colour .. ")",
inventory_image = "beds_bed_fancy_" .. colour .. ".png",
wield_image = "beds_bed_fancy_" .. colour .. ".png",
tiles = {
bottom = {
"beds_bed_top1_" .. colour .. ".png",
"default_wood.png",
"beds_bed_side1_" .. colour .. ".png",
"beds_bed_side1_" .. colour .. ".png^[transformFX",
"default_wood.png",
"beds_bed_foot_" .. colour .. ".png",
},
top = {
"beds_bed_top2_" .. colour .. ".png",
"default_wood.png",
"beds_bed_side2_" .. colour .. ".png",
"beds_bed_side2_" .. colour .. ".png^[transformFX",
"beds_bed_head.png",
"default_wood.png",
}
},
nodebox = {
bottom = {
{-0.5, -0.5, -0.5, -0.375, -0.065, -0.4375},
{0.375, -0.5, -0.5, 0.5, -0.065, -0.4375},
{-0.5, -0.375, -0.5, 0.5, -0.125, -0.4375},
{-0.5, -0.375, -0.5, -0.4375, -0.125, 0.5},
{0.4375, -0.375, -0.5, 0.5, -0.125, 0.5},
{-0.4375, -0.3125, -0.4375, 0.4375, -0.0625, 0.5},
},
top = {
{-0.5, -0.5, 0.4375, -0.375, 0.1875, 0.5},
{0.375, -0.5, 0.4375, 0.5, 0.1875, 0.5},
{-0.5, 0, 0.4375, 0.5, 0.125, 0.5},
{-0.5, -0.375, 0.4375, 0.5, -0.125, 0.5},
{-0.5, -0.375, -0.5, -0.4375, -0.125, 0.5},
{0.4375, -0.375, -0.5, 0.5, -0.125, 0.5},
{-0.4375, -0.3125, -0.5, 0.4375, -0.0625, 0.4375},
}
},
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
recipe = {
{"", "", "group:stick"},
{"wool:" .. colour, "wool:" .. colour, "wool:white"},
{"group:wood", "group:wood", "group:wood"},
},
})
-- simple shaped bed
beds.register_bed("beds:bed_" .. colour, {
description = "Simple Bed (" .. colour .. ")",
inventory_image = "beds_bed_" .. colour .. ".png",
wield_image = "beds_bed_" .. colour .. ".png",
tiles = {
bottom = {
"beds_bed_top_bottom_" .. colour .. ".png^[transformR90",
"default_wood.png",
"beds_bed_side_bottom_r_" .. colour .. ".png",
"beds_bed_side_bottom_r_" .. colour .. ".png^[transformfx",
"beds_transparent.png",
"beds_bed_side_bottom_" .. colour .. ".png"
},
top = {
"beds_bed_top_top_" .. colour .. ".png^[transformR90",
"default_wood.png",
"beds_bed_side_top_r_" .. colour .. ".png",
"beds_bed_side_top_r_" .. colour .. ".png^[transformfx",
"beds_bed_side_top.png",
"beds_transparent.png",
}
},
nodebox = {
bottom = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5},
top = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5},
},
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
recipe = {
{"wool:" .. colour, "wool:" .. colour, "wool:white"},
{"group:wood", "group:wood", "group:wood"}
},
})
end
minetest.register_alias("beds:bed", "beds:bed_red")
minetest.register_alias("beds:fancy_bed", "beds:fancy_bed_red")
minetest.register_alias("beds:bed_bottom", "beds:bed_red_bottom")
minetest.register_alias("beds:bed_top", "beds:bed_red_top")
minetest.register_alias("beds:fancy_bed_top", "beds:fancy_bed_red_top")
minetest.register_alias("beds:fancy_bed_bottom", "beds:fancy_bed_red_bottom")

View File

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

View File

@ -1,271 +0,0 @@
local pi = math.pi
local player_in_bed = 0
local is_sp = minetest.is_singleplayer()
local enable_respawn = minetest.setting_getbool("enable_bed_respawn")
if enable_respawn == nil then
enable_respawn = true
end
-- helper functions
local function get_look_yaw(pos)
local n = minetest.get_node(pos)
if n.param2 == 1 then
return pi/2, n.param2
elseif n.param2 == 3 then
return -pi/2, n.param2
elseif n.param2 == 0 then
return pi, n.param2
else
return 0, n.param2
end
end
local function is_night_skip_enabled()
local enable_night_skip = minetest.setting_getbool("enable_bed_night_skip")
if enable_night_skip == nil then
enable_night_skip = true
end
return enable_night_skip
end
local function check_in_beds(players)
local in_bed = beds.player
if not players then
players = minetest.get_connected_players()
end
for n, player in ipairs(players) do
local name = player:get_player_name()
if not in_bed[name] then
return false
end
end
return #players > 0
end
local function lay_down(player, pos, bed_pos, state, skip)
local name = player:get_player_name()
local hud_flags = player:hud_get_flags()
if not player or not name then
return
end
-- stand up
if state ~= nil and not state then
local p = beds.pos[name] or nil
if beds.player[name] ~= nil then
beds.player[name] = nil
player_in_bed = player_in_bed - 1
end
-- skip here to prevent sending player specific changes (used for leaving players)
if skip then
return
end
if p then
player:setpos(p)
end
-- physics, eye_offset, etc
player:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0})
player:set_look_yaw(math.random(1, 180)/100)
default.player_attached[name] = false
player:set_physics_override(1, 1, 1)
hud_flags.wielditem = true
default.player_set_animation(player, "stand" , 30)
-- lay down
else
beds.player[name] = 1
beds.pos[name] = pos
player_in_bed = player_in_bed + 1
-- physics, eye_offset, etc
player:set_eye_offset({x=0,y=-13,z=0}, {x=0,y=0,z=0})
local yaw, param2 = get_look_yaw(bed_pos)
player:set_look_yaw(yaw)
local dir = minetest.facedir_to_dir(param2)
local p = {x=bed_pos.x+dir.x/2,y=bed_pos.y,z=bed_pos.z+dir.z/2}
player:set_physics_override(0, 0, 0)
player:setpos(p)
default.player_attached[name] = true
hud_flags.wielditem = false
default.player_set_animation(player, "lay" , 0)
end
player:hud_set_flags(hud_flags)
end
local function update_formspecs(finished)
local ges = #minetest.get_connected_players()
local form_n = ""
local is_majority = (ges/2) < player_in_bed
if finished then
form_n = beds.formspec ..
"label[2.7,11; Good morning.]"
else
form_n = beds.formspec ..
"label[2.2,11;"..tostring(player_in_bed).." of "..tostring(ges).." players are in bed]"
if is_majority and is_night_skip_enabled() then
form_n = form_n ..
"button_exit[2,8;4,0.75;force;Force night skip]"
end
end
for name,_ in pairs(beds.player) do
minetest.show_formspec(name, "beds_form", form_n)
end
end
-- public functions
function beds.kick_players()
for name,_ in pairs(beds.player) do
local player = minetest.get_player_by_name(name)
lay_down(player, nil, nil, false)
end
end
function beds.skip_night()
minetest.set_timeofday(0.23)
beds.set_spawns()
end
function beds.on_rightclick(pos, player)
local name = player:get_player_name()
local ppos = player:getpos()
local tod = minetest.get_timeofday()
if tod > 0.2 and tod < 0.805 then
if beds.player[name] then
lay_down(player, nil, nil, false)
end
minetest.chat_send_player(name, "You can only sleep at night.")
return
end
-- move to bed
if not beds.player[name] then
lay_down(player, ppos, pos)
else
lay_down(player, nil, nil, false)
end
if not is_sp then
update_formspecs(false)
end
-- skip the night and let all players stand up
if check_in_beds() then
minetest.after(2, function()
if not is_sp then
update_formspecs(is_night_skip_enabled())
end
if is_night_skip_enabled() then
beds.skip_night()
beds.kick_players()
end
end)
end
end
-- callbacks
--[[ --MFF (Crabman) It's useless to read each join player, read only once at load. function moved/called in spawn.lua
minetest.register_on_joinplayer(function(player)
beds.read_spawns()
end)
--]]
local dead_players = {}
local have_areas_mod = false
if (minetest.get_modpath("areas") ~= nil) and areas.getSpawn then
have_areas_mod = true
end
local function teleport_player(player, clear)
local name = player:get_player_name()
if not name or name == "" then return false end
if have_areas_mod and dead_players[name] ~= nil then
local pos = areas:getSpawn(dead_players[name])
if clear then
dead_players[name] = nil
end
if pos then
player:setpos(pos)
return true
end
end
if not enable_respawn then
return false
end
local name = player:get_player_name()
local pos = beds.spawn[name] or nil
if pos then
player:setpos(pos)
return true
end
--if not areas or bed spawnpoint, tp to the spawn
local spawn = minetest.string_to_pos(minetest.setting_get("static_spawnpoint") or "0,0,0")
player:setpos(spawn)
return false
end
minetest.register_on_dieplayer(function(player)
local name = player:get_player_name()
if not name or name == "" then return end
if have_areas_mod then
local pos = player:getpos()
if pos then
dead_players[name] = pos
end
end
minetest.after(0.20, teleport_player, player) -- tp after all others on_dieplayer callback otherwise their pos is wrong
end)
-- respawn player at bed if enabled and valid position is found
minetest.register_on_respawnplayer(function(player)
return teleport_player(player, true)
end)
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
lay_down(player, nil, nil, false, true)
beds.player[name] = nil
if check_in_beds() then
minetest.after(2, function()
update_formspecs(is_night_skip_enabled())
if is_night_skip_enabled() then
beds.skip_night()
beds.kick_players()
end
end)
end
end)
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "beds_form" then
return
end
if fields.quit or fields.leave then
lay_down(player, nil, nil, false)
update_formspecs(false)
end
if fields.force then
update_formspecs(is_night_skip_enabled())
if is_night_skip_enabled() then
beds.skip_night()
beds.kick_players()
end
end
end)

View File

@ -1,16 +0,0 @@
beds = {}
beds.player = {}
beds.pos = {}
beds.spawn = {}
beds.formspec = "size[8,15;true]"..
"bgcolor[#080808BB; true]"..
"button_exit[2,12;4,0.75;leave;Leave Bed]"
local modpath = minetest.get_modpath("beds")
-- load files
dofile(modpath.."/functions.lua")
dofile(modpath.."/api.lua")
dofile(modpath.."/beds.lua")
dofile(modpath.."/spawns.lua")

View File

@ -1,160 +0,0 @@
# 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

View File

@ -1,32 +0,0 @@
# 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

View File

@ -1,60 +0,0 @@
local world_path = minetest.get_worldpath()
local org_file = world_path .. "/beds_spawns"
local file = world_path .. "/beds_spawns"
local bkwd = false
-- check for PA's beds mod spawns
local cf = io.open(world_path .. "/beds_player_spawns", "r")
if cf ~= nil then
io.close(cf)
file = world_path .. "/beds_player_spawns"
bkwd = true
end
function beds.read_spawns()
local spawns = beds.spawn
local input = io.open(file, "r")
if input and not bkwd then
repeat
local x = input:read("*n")
if x == nil then
break
end
local y = input:read("*n")
local z = input:read("*n")
local name = input:read("*l")
spawns[name:sub(2)] = {x = x, y = y, z = z}
until input:read(0) == nil
io.close(input)
elseif input and bkwd then
beds.spawn = minetest.deserialize(input:read("*all"))
input:close()
beds.save_spawns()
os.rename(file, file .. ".backup")
file = org_file
else
spawns = {}
end
end
function beds.save_spawns()
if not beds.spawn then
return
end
local output = io.open(org_file, "w")
for i, v in pairs(beds.spawn) do
output:write(v.x.." "..v.y.." "..v.z.." "..i.."\n")
end
io.close(output)
end
function beds.set_spawns()
for name,_ in pairs(beds.player) do
local player = minetest.get_player_by_name(name)
local p = player:getpos()
beds.spawn[name] = p
end
beds.save_spawns()
end
beds.read_spawns()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 432 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 408 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 343 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 560 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 548 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 609 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 573 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 343 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 495 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 556 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 705 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 969 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 552 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

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

@ -1,6 +1,6 @@
Minetest Game mod: boats Minetest 0.4 mod: boats
======================== =======================
by PilzAdam by PilzAdam, slightly modified for NeXt
License of source code: License of source code:
----------------------- -----------------------

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

View File

@ -1,15 +1,14 @@
-- --
-- Helper functions -- Helper functions
-- --
boats = {} local function is_water(pos)
function boats.is_water(pos)
local nn = minetest.get_node(pos).name local nn = minetest.get_node(pos).name
return minetest.get_item_group(nn, "water") ~= 0 return minetest.get_item_group(nn, "water") ~= 0
end end
function boats.get_sign(i) local function get_sign(i)
if i == 0 then if i == 0 then
return 0 return 0
else else
@ -17,17 +16,34 @@ function boats.get_sign(i)
end end
end end
function boats.get_velocity(v, yaw, y) local function get_velocity(v, yaw, y)
local x = -math.sin(yaw) * v local x = -math.sin(yaw) * v
local z = math.cos(yaw) * v local z = math.cos(yaw) * v
return {x = x, y = y, z = z} return {x = x, y = y, z = z}
end end
function boats.get_v(v) local function get_v(v)
return math.sqrt(v.x ^ 2 + v.z ^ 2) return math.sqrt(v.x ^ 2 + v.z ^ 2)
end end
function boats.on_rightclick(self, clicker) --
-- Boat entity
--
local boat = {
physical = true,
collisionbox = {-0.5, -0.4, -0.5, 0.5, 0.3, 0.5},
visual = "mesh",
mesh = "boat.x",
textures = {"default_wood.png"},
driver = nil,
v = 0,
last_v = 0,
removed = false
}
function boat.on_rightclick(self, clicker)
if not clicker or not clicker:is_player() then if not clicker or not clicker:is_player() then
return return
end end
@ -37,32 +53,18 @@ function boats.on_rightclick(self, clicker)
clicker:set_detach() clicker:set_detach()
default.player_attached[name] = false default.player_attached[name] = false
default.player_set_animation(clicker, "stand" , 30) default.player_set_animation(clicker, "stand" , 30)
local pos = clicker:getpos()
pos = {x = pos.x, y = pos.y + 0.2, z = pos.z}
minetest.after(0.1, function()
clicker:setpos(pos)
end)
elseif not self.driver then elseif not self.driver then
local attach = clicker:get_attach() self.driver = clicker
if attach and attach:get_luaentity() then clicker:set_attach(self.object, "", {x = 0, y = 11, z = -3}, {x = 0, y = 0, z = 0})
local luaentity = attach:get_luaentity() default.player_attached[name] = true
if luaentity.driver then minetest.after(0.2, function()
luaentity.driver = nil default.player_set_animation(clicker, "sit" , 30)
end end)
end self.object:setyaw(clicker:get_look_yaw() - math.pi / 2)
clicker:set_detach()
end end
self.driver = clicker
clicker:set_attach(self.object, "", {x = 0, y = 11, z = -3}, {x = 0, y = 0, z = 0})
default.player_attached[name] = true
minetest.after(0.2, function()
default.player_set_animation(clicker, "sit" , 30)
end)
self.object:setyaw(clicker:get_look_yaw() - math.pi / 2)
end end
function boat.on_activate(self, staticdata, dtime_s)
function boats.on_activate(self, staticdata, dtime_s)
self.object:set_armor_groups({immortal = 1}) self.object:set_armor_groups({immortal = 1})
if staticdata then if staticdata then
self.v = tonumber(staticdata) self.v = tonumber(staticdata)
@ -70,13 +72,11 @@ function boats.on_activate(self, staticdata, dtime_s)
self.last_v = self.v self.last_v = self.v
end end
function boat.get_staticdata(self)
function boats.get_staticdata(self)
return tostring(self.v) return tostring(self.v)
end end
function boat.on_punch(self, puncher, time_from_last_punch, tool_capabilities, direction)
function boats.on_punch(self, puncher)
if not puncher or not puncher:is_player() or self.removed then if not puncher or not puncher:is_player() or self.removed then
return return
end end
@ -92,37 +92,32 @@ function boats.on_punch(self, puncher)
self.object:remove() self.object:remove()
end) end)
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
local inv = puncher:get_inventory() puncher:get_inventory():add_item("main", "boats:boat")
if inv:room_for_item("main", "boats:" .. self.parameters.name) then
inv:add_item("main", "boats:" .. self.parameters.name)
else
minetest.add_item(self.object:getpos(), "boats:" .. self.parameters.name)
end
end end
end end
end end
function boats.on_step(self, dtime) function boat.on_step(self, dtime)
self.v = boats.get_v(self.object:getvelocity()) * boats.get_sign(self.v) self.v = get_v(self.object:getvelocity()) * get_sign(self.v)
if self.driver then if self.driver then
local ctrl = self.driver:get_player_control() local ctrl = self.driver:get_player_control()
local yaw = self.object:getyaw() local yaw = self.object:getyaw()
if ctrl.up then if ctrl.up then
self.v = self.v + self.parameters.controls.up or 0.1 self.v = self.v + 0.1
elseif ctrl.down then elseif ctrl.down then
self.v = self.v - self.parameters.controls.down or 0.08 self.v = self.v - 0.1
end end
if ctrl.left then if ctrl.left then
if self.v < 0 then if self.v < 0 then
self.object:setyaw(yaw - (1 + dtime) * (0.03 * (self.parameters.controls.rotate or 1))) self.object:setyaw(yaw - (1 + dtime) * 0.03)
else else
self.object:setyaw(yaw + (1 + dtime) * (0.03 * (self.parameters.controls.rotate or 1))) self.object:setyaw(yaw + (1 + dtime) * 0.03)
end end
elseif ctrl.right then elseif ctrl.right then
if self.v < 0 then if self.v < 0 then
self.object:setyaw(yaw + (1 + dtime) * (0.03 * (self.parameters.controls.rotate or 1))) self.object:setyaw(yaw + (1 + dtime) * 0.03)
else else
self.object:setyaw(yaw - (1 + dtime) * (0.03 * (self.parameters.controls.rotate or 1))) self.object:setyaw(yaw - (1 + dtime) * 0.03)
end end
end end
end end
@ -131,35 +126,34 @@ function boats.on_step(self, dtime)
self.object:setpos(self.object:getpos()) self.object:setpos(self.object:getpos())
return return
end end
local s = boats.get_sign(self.v) local s = get_sign(self.v)
self.v = self.v - 0.02 * s self.v = self.v - 0.02 * s
if s ~= boats.get_sign(self.v) then if s ~= get_sign(self.v) then
self.object:setvelocity({x = 0, y = 0, z = 0}) self.object:setvelocity({x = 0, y = 0, z = 0})
self.v = 0 self.v = 0
return return
end end
if math.abs(self.v) > 4.5 then if math.abs(self.v) > 4.5 then
self.v = 4.5 * boats.get_sign(self.v) self.v = 4.5 * get_sign(self.v)
end end
local p = self.object:getpos() local p = self.object:getpos()
p.y = p.y - 0.5 p.y = p.y - 0.5
local new_velo = {x = 0, y = 0, z = 0} local new_velo = {x = 0, y = 0, z = 0}
local new_acce = {x = 0, y = 0, z = 0} local new_acce = {x = 0, y = 0, z = 0}
if not boats.is_water(p) then if not is_water(p) then
local nodedef = minetest.registered_nodes[minetest.get_node(p).name] local nodedef = minetest.registered_nodes[minetest.get_node(p).name]
if (not nodedef) or nodedef.walkable then if (not nodedef) or nodedef.walkable then
self.v = 0 self.v = 0
new_acce = {x = 0, y = 1, z = 0} new_acce = {x = 0, y = 1, z = 0}
else else
new_acce = {x = 0, y = -9.8, z = 0} -- freefall in air -9.81 new_acce = {x = 0, y = -9.8, z = 0}
end end
new_velo = boats.get_velocity(self.v, self.object:getyaw(), new_velo = get_velocity(self.v, self.object:getyaw(), self.object:getvelocity().y)
self.object:getvelocity().y)
self.object:setpos(self.object:getpos()) self.object:setpos(self.object:getpos())
else else
p.y = p.y + 1 p.y = p.y + 1
if boats.is_water(p) then if is_water(p) then
local y = self.object:getvelocity().y local y = self.object:getvelocity().y
if y >= 4.5 then if y >= 4.5 then
y = 4.5 y = 4.5
@ -168,7 +162,7 @@ function boats.on_step(self, dtime)
else else
new_acce = {x = 0, y = 5, z = 0} new_acce = {x = 0, y = 5, z = 0}
end end
new_velo = boats.get_velocity(self.v, self.object:getyaw(), y) new_velo = get_velocity(self.v, self.object:getyaw(), y)
self.object:setpos(self.object:getpos()) self.object:setpos(self.object:getpos())
else else
new_acce = {x = 0, y = 0, z = 0} new_acce = {x = 0, y = 0, z = 0}
@ -176,10 +170,9 @@ function boats.on_step(self, dtime)
local pos = self.object:getpos() local pos = self.object:getpos()
pos.y = math.floor(pos.y) + 0.5 pos.y = math.floor(pos.y) + 0.5
self.object:setpos(pos) self.object:setpos(pos)
new_velo = boats.get_velocity(self.v, self.object:getyaw(), 0) new_velo = get_velocity(self.v, self.object:getyaw(), 0)
else else
new_velo = boats.get_velocity(self.v, self.object:getyaw(), new_velo = get_velocity(self.v, self.object:getyaw(), self.object:getvelocity().y)
self.object:getvelocity().y)
self.object:setpos(self.object:getpos()) self.object:setpos(self.object:getpos())
end end
end end
@ -188,143 +181,31 @@ function boats.on_step(self, dtime)
self.object:setacceleration(new_acce) self.object:setacceleration(new_acce)
end end
boats.register_boat = function(parameters) minetest.register_entity("boats:boat", boat)
minetest.register_entity("boats:" .. parameters.name, {
physical = true,
collisionbox = {-0.5, -0.35, -0.5, 0.5, 0.3, 0.5},
visual = "mesh",
mesh = "boat.obj",
textures = {parameters.texture or "default_wood.png"},
parameters = parameters, minetest.register_craftitem("boats:boat", {
driver = nil, description = "Boat",
v = 0, inventory_image = "boat_inventory.png",
last_v = 0, wield_image = "boat_wield.png",
removed = false, wield_scale = {x = 2, y = 2, z = 1},
liquids_pointable = true,
on_rightclick = boats.on_rightclick, on_place = function(itemstack, placer, pointed_thing)
on_activate = boats.on_activate, if pointed_thing.type ~= "node" then
get_staticdata = boats.get_staticdata, return
on_punch = boats.on_punch, end
on_step = boats.on_step if not is_water(pointed_thing.under) then
}) return
end
minetest.register_craftitem("boats:" .. parameters.name, { pointed_thing.under.y = pointed_thing.under.y + 0.5
description = parameters.description or "Boat", minetest.add_entity(pointed_thing.under, "boats:boat")
inventory_image = "boats_" .. parameters.name .. "_inventory.png", if not minetest.setting_getbool("creative_mode") then
wield_image = "boats_" .. parameters.name .. "_wield.png", itemstack:take_item()
wield_scale = {x = 2, y = 2, z = 1}, end
liquids_pointable = true, return itemstack
end,
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return
end
if not boats.is_water(pointed_thing.under) then
return
end
pointed_thing.under.y = pointed_thing.under.y + 0.5
minetest.add_entity(pointed_thing.under, "boats:"..parameters.name)
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return itemstack
end,
})
end
boats.register_boat({
name = "boat",
texture = "default_wood.png",
controls = {
up = 0.1,
down = 0.08,
rotate = 0.75
},
description = "Boat"
}) })
boats.register_boat({
name = "race",
texture = "default_gravel.png",
controls = {
up = 0.2,
down = 0.18,
rotate = 1
},
description = "Race boat"
})
boats.register_boat({
name = "expert_race",
texture = "default_desert_stone.png",
controls = {
up = 0.25,
down = 0.25,
rotate = 4
},
description = "Expert race boat"
})
boats.register_boat({
name = "water",
texture = "default_water.png",
controls = {
up = 0.3,
down = 0.24,
rotate = 4
},
description = "Water boat"
})
boats.register_boat({
name = "moon",
texture = "boats_moon.png",
controls = {
up = 0.5,
down = 0.1,
rotate = 8
},
description = "Moon boat"
})
-- Craft registrations
minetest.register_craft({
output = "boats:moon",
recipe = {
{"default:obsidian", "", "default:obsidian"},
{"default:dirt", "default:leaves", "default:dirt"},
},
})
minetest.register_craft({
output = "boats:expert_race",
recipe = {
{"default:desert_stone", "", "default:desert_stone"},
{"default:desert_stone", "default:mese", "default:desert_stone"},
},
})
minetest.register_craft({
output = "boats:race",
recipe = {
{"default:gravel", "", "default:gravel"},
{"default:gravel", "default:steelblock", "default:gravel"},
},
})
minetest.register_craft({
output = "boats:water",
recipe = {
{"default:glass", "", "default:glass"},
{"default:glass", "bucket:bucket_water", "default:glass"},
},
})
minetest.register_craft({ minetest.register_craft({
output = "boats:boat", output = "boats:boat",
recipe = { recipe = {
@ -333,3 +214,4 @@ minetest.register_craft({
{"group:wood", "group:wood", "group:wood"}, {"group:wood", "group:wood", "group:wood"},
}, },
}) })

File diff suppressed because it is too large Load Diff

11110
mods/boats/models/boat.x Normal file

File diff suppressed because it is too large Load Diff

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 847 B

After

Width:  |  Height:  |  Size: 847 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

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