Compare commits

...

119 Commits

Author SHA1 Message Date
Lars
a1ab186c6e Fix possible invalid object reference in TNT mod 2024-06-05 00:47:29 -04:00
451b2994fe mod - firefly - fix wrong check for object on place 2024-04-26 17:33:24 -04:00
60ac7cccc9 mods doors - fix error on sounds that xpected table on new engines
* backported commit 201cf5f for newer engines mostly 5.3
2024-04-26 17:30:03 -04:00
77484db3a4 mod - torch - Fix Warning spam about use_texture_alpha 2024-04-24 15:40:24 -04:00
10e85eb910 mod creative - fix check for newer lang on engine, commit f757878 2024-04-24 15:13:43 -04:00
46ce26ded2 Fix Warning spam about use_texture_alpha
* Previously the alpha value in the nodedef indicated the transparency
  the water was actually rendered with. Now only the alpha in the texture
  is respected.
* Closes and fixes https://github.com/minetest/minetest_game/issues/2819
* Backported https://github.com/minetest/minetest_game/pull/2822
* this is the same as https://github.com/minetest/minetest_game/pull/2729
2024-04-24 13:01:57 -04:00
99e163dd82 mods boats/carts - fix player api compatibility with older api 2024-04-23 13:20:19 -04:00
b2b66a6fa7 mods - fix miscpelled line of conditional on nodes 2024-04-23 13:15:29 -04:00
6ed6ce1317 improve warning message definition about old api vs newer one of 3d_armor
* backported commit 94de1bf2bc75071526d1a68d29bc9c4ed9da5dd0 from upstream
2024-04-23 13:03:41 -04:00
d0edf57d46 Beds: Replace hardcoded values of day interval with constants
* backported https://github.com/minetest/minetest_game/pull/2990
* backported commit 2e8ac46120
2024-04-18 16:54:53 -04:00
55189a57f8 Fix some placer nil checks
* backported upstream 70cf7a26fd
2024-04-18 14:22:36 -04:00
da0cad8af7 Fix flammable item entities crashing
* https://github.com/minetest/minetest_game/issues/2657
* https://github.com/minetest/minetest_game/pull/2659
* partial fix from upstream
2024-04-18 13:37:49 -04:00
4901df3c95 mods - default - backported Override builtin item entity the portable way
* closes https://codeberg.org/minenux/minetest-game-minetest/issues/16
2024-04-17 22:19:22 -04:00
c2c28d5e2a mods - default - crafting : fix bad commit, miscpelled - in line 42 2024-04-17 22:18:46 -04:00
ddfec19a2b mods - default - ingtegrated sunglasses with CC-BY-SA-NC over source code and art
* original author not found and minietest developers are so petty to respond
* closes https://codeberg.org/minenux/minetest-game-minetest/issues/14
2024-03-31 22:54:33 -04:00
a3a271b21f stairs - fix multiengine protocol loading of sound table 2023-08-13 19:32:15 -04:00
a110849017 default/player_Api dinamically set the model player on client conection
* improves previous commit 13cd243a031ca6c52457032e0bffc8576b549b3a ,
  the problem is that both server and client must be equal protocol, so
  this ugly hack check if this was loaded into FinalMinetest or Multicraft
  to dinamically check client nature and re-registering the model when
  server and client do not have same player models due the colisionbox check
* NOTE: the check already need to check if the engine is old and the server not,
  so the conditional just try to do exact check agains TRUE boolean.
* Closed https://codeberg.org/minenux/minetest-game-minetest/issues/12
  fixed the problem of collisionbox for the lufix player in ugly way but
  much more effectivelly due can be mixed in FinalMinetest and Multicraft
2023-08-13 19:31:31 -04:00
23eb8437f4 default - revent knockback for attached players
* backported from default game
  fbbc7fc996
2023-08-06 13:21:45 -04:00
d77ba194d4 update player model remove vertial 1 node offset on newer engines only
* Player model: Remove vertical 1 node offset for new engines, but
  Required due to the settable player collision box engine feature
  change for MT/MTG v0.5.0 that breaks compatibility with old client
  so due that this commit will added backguard compatibility
* Autodetec minetest versoin engine and provide right model
  character, update player code to provide compatibility with player_api
2023-08-06 12:36:03 -04:00
a6073f034d mods hudbars+hbarmor+hbhunger - make check for max_hp witout segfault old engines
* optimize checks, only set once, upgrade upstream
* use right supported check for version string
* do not make redundant checks and set of hp_max
* property set log warning notification when parts of mod are not used
* autodetect armor mod and able to work without it
2023-07-26 01:20:32 -04:00
2de5aaeeff mods - hudbars+hbhunger+hbarmor - featured upgrade
* fix workaroun about ssettings not configurable
* do not hardcoded hp_max from other mods, unless configured here
* provide settings for hbhunger steps
* provide settings for auto hide or not hbarmor
* document those missing features
* mark mod with version 2.3.5.0 and using redo flag
* detection of original mods and bypass build-in own features
* optimize loading of hubar for armor, bad initialization
* real check player becouse of wrong implementation at engine
2023-07-24 15:27:25 -04:00
a3f7816526 backguard compatibility of hp_max in older clients, (missing breath_max)
* honoring customizations of hp_max its not so valid in older
  clients becouse of a bug in older clients of hardcoded healt player
  long time ago user requested https://github.com/minetest/minetest/issues/2246
  the value was hardcoded into engine and do not allow to be
  customized by mods until the commit above, this patch
  takes that into consideration and set the value to 20.
* NOTE: as side effect if you started a server that support
  hp_max modification and try to connect using a older client,
  client will perfectly supports the already configured healt
  from client, but will start at 20 initialy, of course with
  max_hp supported over the value of 20
2023-07-19 00:44:11 -04:00
918bb6e8bb mods - hudbars : not hardcoded the hb.init_hudbar max values
* real fix for missing format_string_config.textdomain
  backpoted from c219b708f8
* fix the backguard compatibility for format_string_config.format_string
* add configuration settings for hp_max of player and breath_max
* do not hardcoded hp_max neither breath_max and honor customizations
* real fix of get_properties when join players
* set alternate honored max values before get_properties when join players
* increase default ticks of updates for hud bar, to avoid performance
  issues in low end devices
* optimize and fix texture images
2023-07-17 01:16:50 -04:00
mckayshirou
b4c29033c9 fix creative mode mod backguard compatibility for all engines
* dont follow the creative upstream mod,
  its just wrapper around get_bool(creative) setting, so create a check privilegie
  function and provide backguard compatibility checks
* backported fix from c770d5cb43
  same backported from c770d5cb43
2023-07-13 23:03:51 -04:00
fd5ca024e6 integrated nice hudbars into our default minetest game
* checkout facc2cffb8
* version 2.3.4 with many backported fixeds
2023-06-20 00:42:50 -04:00
336ce1c8db sfinv - sfinv_home set better text for home button 2023-06-18 04:58:26 -04:00
8196401ab8 fireflies - fix wrong conditional 2023-06-18 04:33:29 -04:00
c624fef6f3 Merge sync 'stable-4.0' to stay in sync with featured fireflies mod
* integrate creative new mod
* featured fireflies with ethereal support
2023-06-18 03:17:30 -04:00
9836d04755 fireflies - sync with oiginal and add support for ethereal
* sync with fireflies of upstream original mod and from minenux
* Add vessels group to firefly vessel
* Detect creative mode and creative privilegies, using creative mod
* Detect ethereal mod and provide more biomes of place
2023-06-18 03:17:07 -04:00
ee13c9f46a fireflies - sync with oiginal and add support for ethereal
* sync with fireflies of upstream original mod and from minenux
* Add vessels group to firefly vessel
* Detect creative mode and creative privilegies, using creative mod
* Detect ethereal mod and provide more biomes of place
2023-06-18 03:14:10 -04:00
ea2069d30e fireflies - allow to spawn/put the net fireflies on more biomes if ethereal
* if the etherealmod is detected allow to spawn/put the net/fireflies
  in more biomes
2023-06-17 10:25:47 -04:00
1624147edc included the reduced and external mantanied fireflies mod for older engines
* the mt5 game already has a improved version of fireflies with timer nodes
  that hide the fireflies at day
2023-06-17 09:59:47 -04:00
f208b6312d updated upgraded simplified creative and provide privilegie feature
* register privilegie of creative for older or newer engines
* enhanced the formspec of the creative player to 4 rows
* try to upgrade most close to track upstream original
* return back text button, remove extra media
  check https://notabug.org/TenPlus1/creative/issues/2
* update readme information to diference features
2023-06-16 00:36:33 -04:00
ae8c3f8eba sfinv - upgrade sfinv and integrated sfinv_home to sfinv 2023-06-12 00:32:55 -04:00
729e344fc8 sethome - update mod to upstream 2023-06-12 00:02:51 -04:00
8e59006dc8 sethome - update mod to upstream 2023-06-12 00:02:10 -04:00
284eb28d6c toolranks - fix mt 5.X depends 2023-06-11 23:21:20 -04:00
901fb492c1 Fix many workbench and enchanting table bugs from MT-Eurythmia
* fix crash https://github.com/Mynetest/Mynetest-server/issues/105
* detect that hammer is present and detect if that mese list are mese
* backported https://github.com/MT-Eurythmia/xdecor/commit/59a65c60611ebe8ef3ced2e406968f049>
* backported https://github.com/MT-Eurythmia/xdecor/commit/28a24a805be109eb8ab32b8633b1dfef5>
2023-06-11 21:46:20 -04:00
13a6891758 xdecor - crash avoiting: Added further sanity check and update formspecs
* update xdecir minenux up to 20230611
* backporting https://notabug.org/minenux/minetest-mod-xdecor/commit/3e0ca1304d454297739d6f8>
* backporting https://github.com/0siribix/xdecor/commit/c7e756afc7d246817209c415c6e9a9dda533>
* backporting https://github.com/0siribix/xdecor/commit/3823fce1e05a9472e7cf798c8346ba95ead1>
* backporting https://notabug.org/minenux/minetest-mod-xdecor/commit/9f4002b749920a6aa906ce7>
2023-06-11 19:57:23 -04:00
dab09dfd32 mods - add tenplus1 toolranks with some backported changes features
* toolranks from minenux with spanish translation and featured description
* backguard compatibility
2023-06-11 14:50:11 -04:00
ebdf4427d3 creative - fix mistake on privs 2023-06-11 06:29:33 -04:00
4a9e24b2f2 provide minetest.is_creative_enabled and backguard compatibilty 2023-06-11 06:19:33 -04:00
aa9f63cb3f farming - make apples 3d backporting the 3d_apples mod 2023-06-07 17:21:20 -04:00
115c85ce40 xdecor - fix possible bad array on enchanting code, related to some bugs
* update mod to f6d0f0b2a5c1d435217bb3409a76da9eb36fe889 with last README info nodes
2023-06-07 16:32:25 -04:00
00bad47eed incorporate xdecor a more light respect homedecor 2023-06-06 15:12:23 -04:00
c23219729c update farming mod for mt game v4, need test compatibility 2023-06-06 11:28:47 -04:00
07d4778ffb update information and references.. use git.minetest.org as mirror
* update game info and release focused version
* modernize the game.conf but mantanin compatibility
* provide LICENSE clarification about real autor historicaly (blockmen)
2022-08-23 11:20:42 -04:00
d82008a256 tnt - update to fix MT5 game detectio engine api
* backported fca1999990
* closes https://notabug.org/TenPlus1/tnt/issues/2
* closes https://codeberg.org/minenux/minetest-mod-tnt/issues/2
2022-08-05 22:47:04 -04:00
e02a31343a v 20220728 - update boats mod, fix missing global minetest object access
* property detect the feature using the namespace global var
2022-07-27 01:56:38 -04:00
36427dada6 merge fix for misc error (fix misc error on boat contidional)
* recommit 58c2cb6d89 after upgrade boats
* sync merge with 5.2 stable brach from codeberg repo
2022-07-27 01:53:03 -04:00
b6d93e76d3 Added detection of mod player_api agains default
* use aliasing sustitution to use player_api when detected
* backported those to legacy.lua
2022-04-14 21:11:48 -04:00
812bb323f6 Verify object is player before checking privs backported for mt 0.4.17 game
* backported 3a3f71aa50
* prevents a crash when a 'nil' digger is passed by the engine to minetest.node_dig
2022-04-14 21:04:28 -04:00
d18f9b4251 Do not crash when a skeleton key is used on an unknown node
* backported from default MT 5.1+
2022-04-14 20:57:56 -04:00
574d6cc65c Fix flammable item entities crashing
* backported from https://github.com/minetest/minetest_game/pull/2659
* fix to close https://codeberg.org/minenux/minetest-game-minetest/issues/11
2022-04-14 20:45:16 -04:00
b1440d887d mod: farming - lower refill time, add player check, fix de locale, add trellis
* Import upstream changes from upstream tenplus1 as
  00e4b3cb89
* lower refill time, add player check
  2e90959a6c
* fix de translations due update translations
  a19f852ddf
* fix spanish translations due typos
  35c5245b3c
* add trellis setting to registered_crops
  https://codeberg.org/minenux/minetest-mod-farming/commit/3cbbb3678e
2022-03-09 12:14:28 -04:00
2f97407591 upgrade beds,boats,bucket,carts,creative,doors,farming,fire,stairs,tnt,wool
* beds 7b6fae96d5
* boats 3832de08f7
* bucket 1d9f32295a
* carts dcbca916cf
* creative ca09e77370
* doors a89ab0454d
* farming 10de84d12d
* fire 4e5f7ad553
* stairs c3a5af6c45
* tnt 8195861f90
* wool de642a08e8
2022-03-01 23:26:11 -04:00
c7cb79422b improve README and api documentation 2022-02-28 23:44:55 -04:00
c23bd322f7 docs - fix missing colon in sintax game_api 2022-02-28 23:17:14 -04:00
18aed0219b * document, configure and improve the give_initial_stuff
* This mod provides some stuff per player at initial play when first join only
* set initial_stuff = default:wood 2,farming:bread 2,default:furnace 1,default:torch 5
* the initial_stuff is only configured per config files not at menu
2021-12-13 20:12:36 -06:00
f1e7172fe1 adapted from player_api: Set eye height property for player model
* backported d4e1bd053e
* Player API: Set eye height property for new player model
2021-12-10 17:35:02 -04:00
SmallJoker
74702c6ada Carts: Replace old, deprecated function names 2021-12-10 17:23:59 -04:00
Lars Hofhansl
d37c1d2312 Creative: Do not give creative priv to admin 2021-12-10 17:20:34 -04:00
be96530e20 Mushroom spread: make overridable and reduce spread
* Move mushroom spread ABM action into a global and overridable function.
  but do not optimise spread code
* backported bcf98df5fac3eb59b02d9fdb066ab92c6228d787
* Reduce spread range to reduce spread through walls.
2021-12-10 15:24:32 -04:00
paramat
535204298e Farming: Make cotton look like cotton, add crafted string item
Remove string -> cotton alias.
2021-12-10 15:11:15 -04:00
657f7cee6e set art and game default, use minenux name and logo venenux
* backported d5cc8c46f6
* now we are into minenux so minetest4 stable-4.0 branch for engine
2021-12-10 13:11:24 -04:00
95e70da3a6 Default: Increase the maximum level of the diamond axe to 3
* backported https://github.com/minetest/minetest_game/pull/1854
* This is the maximum level of the other diamond tools and makes the
  number of uses similar to them.
* fixed https://github.com/minetest/minetest_game/issues/1456
  Diamond axe breaks earlier than mese axe
2021-12-09 16:54:51 -04:00
e07ad71d11 Improve node descriptions for most default items and nodes
* backported https://github.com/minetest/minetest_game/pull/1834
* addressed consistency issues previously discussed in:
* https://github.com/minetest/minetest_game/issues/1473
  Bad item descriptions: Too generic descriptions among specific descriptions
  also cos has a strong tendency towards mixing generic item names
* https://github.com/minetest/minetest_game/issues/1817
  Add tree species to descriptions for appletree and jungletree
  No change to node technical names though. Normal wood is obviously an appletree
2021-12-09 16:26:54 -04:00
paramat
9cf3c953f1 Flowers: More flowers 2021-12-09 15:34:31 -04:00
ezhh
4a1fc02e82 Descriptions: Make capitalization consistent 2021-12-09 15:31:52 -04:00
2b6de659cb Floatland biomes: Add ocean biomes to fix missing sandstone
* Update biome lists for blob ores.
* backported bdc09d2313e5734400d2283549c4906d77a546d0
2021-12-09 15:30:08 -04:00
Ezhh
aa7f6cd060 Make sapling, leaves and fence descriptions consistent
* backported https://github.com/minetest/minetest_game/pull/1795
2021-12-09 15:07:47 -04:00
John Cole
fb610ffa59 Allow mossy cobble slabs to combine
* backported https://github.com/minetest/minetest_game/pull/1791
* fixed https://github.com/minetest/minetest_game/issues/1790
2021-12-09 15:03:29 -04:00
tenplus1
fea78bdf54 Creative: Add 'creative' privilege for survival servers
* This adds a 'creative' privilege to survival servers which OPs can bestow
 on admin or competent builders to give access to the creative inventory.
* backported from 0157175346f9af8cf9ea5ffeb5f3d91fa474d044
2021-12-09 13:00:48 -04:00
sofar
d6a66860af Prevent divide by zero (#2106)
This forces all explosions to damage entities within the 1 node
range. If that needs to be disabled, the damage_radius needs to
be set to 0.
2018-05-18 12:50:47 +02:00
paramat
6d850f23a5 Flower spread ABM: Optimise
Match maximum spread density to maximum mapgen density for flowers.
Place 3 flora nodes at once instead of 1.
Change ABM chance value to 300 to match previous spread rate.
ABM becomes 3 times less intensive.
2018-05-18 12:50:47 +02:00
paramat
2c1af0861f Doors: Avoid crash on nil player in 'can dig door' 2018-05-18 12:50:47 +02:00
Jat15
d2ae721235 Stairs: unbind table groups (#2036)
Unbind table groups for base block, stairs, slabs.
2018-05-18 12:50:18 +02:00
paramat
01db55cee5 default:dirt_with_snow: Re-add to soil group
Previously, saplings were not growing if the dirt they are on turned to
'dirt with snow' before growth.
Also for consistency with other dirt nodes.
2018-05-06 20:44:30 +02:00
Ekdohibs
4ba2b5179e Furnace: Fix being able to cook items without enough fuel
This was triggered when too much time had elapsed when timer was called.
Also, fix timer resolution giving free fuel time.
2018-05-06 20:44:30 +02:00
Diego Martínez
a5092c0df6 creative: Add missing tooltips. 2018-05-06 20:44:30 +02:00
paramat
575c098bae Book textures: Reset colour profiles to remove warnings 2018-05-06 20:44:22 +02:00
paramat
cddd59b578 Book textures: Replace with more original textures 2018-05-06 20:40:45 +02:00
ezhh
7a4b1e0ce1 Default: Make burntimes more rational and consistent 2017-12-05 21:24:02 +01:00
DTA7
0216fa08ec Add nil checks for placer 2017-11-19 23:03:38 +01:00
raymoo
ca3e807d35 Creative: Make the placenode registration check for non-player placers 2017-11-19 23:03:38 +01:00
raymoo
ca38bb2390 Creative: Make handle_node_drops override work for non-player diggers 2017-11-19 23:03:38 +01:00
Coder12a
7d07c52d09 Books: Convert \r to \n
Some files or editors may use \r instand of \n like notepad++. If you copy
text written in notepad++ and pasted into the book. The book will only have
one page.
2017-11-19 23:03:38 +01:00
SmallJoker
532013a032 Creative: Cache inventory items on load 2017-11-19 23:03:38 +01:00
tenplus1
a52622669f TNT: Add tnt.boom defaults
This adds def, def.radius and def.damage_radius defaults to the
tnt.boom() function if they aren't specified on call.
2017-11-19 23:03:38 +01:00
SmallJoker
ce5e668681 Bones: Return bones when taking the last ItemStack 2017-11-19 23:03:38 +01:00
tenplus1
6530fa914b Flowers: Add waterlily right-click checks
Check for on_rightclick functions of nodes when holding a waterlily.
2017-11-19 23:03:38 +01:00
rubenwardy
86eb0e1617 Sfinv: Remove possibility of infinite loop when homepage doesn't exist 2017-11-19 23:03:38 +01:00
rubenwardy
93fb9b36ce Sfinv: Rename navigation tabs to reduce chance of a conflict 2017-11-19 23:03:38 +01:00
danielmeek32
09e3505ea1 Chests: Fix locked chest protection against explosions (#1886)
Fixes #1885
2017-11-19 23:03:38 +01:00
tenplus1
cecbfc1676 Chests: Fix open chest after player leave (#1884)
This should fix the chest staying open when a player disconnects while inside.
2017-11-19 23:03:38 +01:00
tenplus1
fba6f6a4cf TNT: Add explode_center flag
Add 'explode_centre' flag which when false explodes as normal and when true runs on_blast on centre node as well as dropping items.
2017-11-19 23:03:38 +01:00
tenplus1
6053456af1 Mushroom spread: Optimise and make overridable
Move mushroom spread ABM action into a global and overridable function.
Optimise spread code.
Reduce spread range to reduce spread through walls.
2017-11-19 23:03:38 +01:00
Hybrid Dog
cc2f75b2f9 Register fence: Allow setting nodedefs to 'false' 2017-11-19 23:03:38 +01:00
tenplus1
b6ef71c92e TNT's tnt:boom cleanup (#1868)
The tnt:boom node doesn't actually need the on_construct and on_timer functions to remove the node after 0.4 seconds as the tnt_explode function already does this beforehand.
2017-11-19 23:03:38 +01:00
SmallJoker
876da2fbc6 Beds: Do not crash when placing in an unknown node 2017-11-19 23:03:38 +01:00
paramat
ea45ca57a5 Lava cooling: Increase interval to 2
An excessive load has been reported caused by the node searching, so even
when no lava is present.
2017-11-19 23:03:34 +01:00
SmallJoker
6fa3ebfa75 Carts: Check for last pathfinder predition too Minor fix to reduce cart jitter slightly 2017-11-19 22:57:28 +01:00
SmallJoker
efe6fb6dfb TNT: Only burn visually connected powder (#1857) 2017-11-19 22:57:28 +01:00
SmallJoker
1aeb2baa91 Creative: Prevent unauthorized item access (#1840) 2017-11-19 22:57:28 +01:00
Ezhh
e4d6425846 Correct farming/stairs dependency (#1838) 2017-11-19 22:57:28 +01:00
Paramat
81f885795d Crafting: Remove duplicate reversed recipes (#1777)
For axes and hoes only use one recipe that matches the appearance of the texture and in inventory.
2017-11-19 22:53:53 +01:00
paramat
f3e29bc2cc Saplings: Reduce grow time to ABM equivalent
Previous times were chosen using statistical maths, but reports suggested
this was too long.
I tested by timing an ABM acting on 100 nodes, with interval and chance equal
to the old sapling ABM.
50 at 4m59s.
99 at 24m58s.
100 at 26m58s.
So choose a grow time between 5 and 25 min for tree and bush saplings.
If 'can grow' is false at grow time the timer is reset to 5 min.
2017-11-19 22:53:53 +01:00
DS-Minetest
3a72f7b84b Add backface_culling to open chests and fencegates 2017-11-19 22:53:53 +01:00
Foz
20bd4560f8 TNT: Track TNT owner in metadata for protection mods
It is useful for protection mods to know who owns an exploding
TNT block. This allows the blocks destroyed by the TNT to be
limited to the same ones the owner could destroy without using
TNT.

TNT placed within a protected area by the area owner, and later
ignited by another player will destroy within the protected area
nodes the igniter may not otherwise be able to interact with. Any
player could significantly increase the size of an explosion by
placing more TNT in an adjacent unprotected area if the original
TNT block was placed withing 1 node of such a boundary. This
feature sounds dangerous, but we are talking about TNT. Players
should use it carefully.
2017-11-19 22:53:53 +01:00
SmallJoker
8991b9fe54 Carts: Do not connect rails with gunpowder (#1812) 2017-11-19 22:53:53 +01:00
Johannes Fritz
aea6c5dd1d Stairs: Add backface culling to stair meshes
If backface culling is not specified for a tile in 'images' it is set to true.
Slabs already have backface culling due to being defined as nodeboxes (which
are then converted to meshnodes).
2017-11-19 22:53:53 +01:00
paramat
da41caca66 Chests: Check 'def' of node above chest to avoid crash
In 'chest_lid_obstructed(pos)' check for nil 'def' to avoid a crash caused by
an unknown node above the chest.
2017-11-19 22:53:14 +01:00
red-001
103af98864 Books: Also limit the max size of the title
This limits the max size of the full title of the book to `80` letters and
the size of the part thats displayed in the tooltip to `35` letters.
2017-11-19 22:53:14 +01:00
red-001
26606b0520 Books: Limit the size of books
Really large books just waste hard drive space and the engine is not designed to
handle that much data in item metadata, this can cause strange things to happen.
2017-11-19 22:52:00 +01:00
red-001
706844e8bf Books: Add nil value checks to the book formspec handler 2017-11-19 22:52:00 +01:00
paramat
a56274c230 Stairs: Use one recipe matching inventory appearence
No longer have 2 recipes for stairs, choose the one that matches the appearence
in inventory (stair rising toward the right).
Helps to reduce recipe count now that an increasing number of stairs are
being registered.
2017-11-19 22:52:00 +01:00
vorunbekannt75@web.de
3512226867 Default: Revert "Default: Shorter and better ABMs"
This reverts commit e523c3a2965afe76b9102b67992e15fafba1594a to re-enable
the overriding and redefinition of these global functions.
2017-11-19 17:16:32 +01:00
ShadowNinja
d5b9fee6fe Merge 0.4.16 into stable-0.4 2017-06-03 17:22:59 -04:00
sfan5
437860feff Merge tag '0.4.15' into stable-0.4
0.4.15
2016-12-22 23:00:57 +01:00
1027 changed files with 28893 additions and 3318 deletions

View File

@ -12,6 +12,7 @@ Copyright (C) 2015 paramat CC BY-SA 3.0
License of source code License of source code
---------------------- ----------------------
Copyright (C) 2010-2012 Blockmen
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com> Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
See README.txt in each mod directory for information about other authors. See README.txt in each mod directory for information about other authors.

63
README.md Normal file
View 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.

View File

@ -1,28 +1,85 @@
Minetest Game [minetest_game] Minetest4 Game
============================= ==============
The main subgame for the Minetest engine
========================================
To use this subgame with the Minetest engine, insert this repository as The default game for the Minetest4 engine.
/games/minetest_game
The Minetest engine can be found in: This is a fork from minetest default game, this
https://github.com/minetest/minetest/ are made from minenux project https://codeberg.org/minenux
for minetest v5 and minetest v4 or 0.4.
Compatibility Introduction
-------------- ------------
The Minetest Game github master HEAD is generally compatible with the github
master HEAD of the Minetest engine.
Additionally, when the Minetest engine is tagged to be a certain version (eg. This is the branch `stable-4.0` of minetest game for minetest4 a version
0.4.10), Minetest Game is tagged with the version too. 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 This are focused to provide minimal default game featured for minetest4
http://minetest.net/download to be playable, with an [api](game_api.md) for more aditions (in the form of mods)
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!)
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`

View File

@ -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
View 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)

View File

@ -1,19 +1,69 @@
Minetest Game API 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 Introduction
------------ ------------
The Minetest Game subgame offers multiple new possibilities in addition to the Minetest engine's built-in API, The Minetest4 Game game offers multiple new possibilities in addition to
allowing you to add new plants to farming mod, buckets for new liquids, new stairs and custom panes. the Minetest engine's built-in API, allowing you to add new plants to farming mod,
For information on the Minetest API, visit https://github.com/minetest/minetest/blob/master/doc/lua_api.txt 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: Please note:
* [XYZ] refers to a section the Minetest API * [XYZ] refers to a section the Minetest API
* [#ABC] refers to a section in this document * [#ABC] refers to a section in this document
* [pos] refers to a position table `{x = -5, y = 0, z = 200}` * [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 Bucket API
---------- ----------
@ -155,7 +205,8 @@ The doors mod allows modders to register custom doors and trapdoors.
### Fence gate definition ### Fence gate definition
description = "Wooden Fence Gate", 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", material = "default:wood",
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
sounds = default.node_sound_wood_defaults(), -- optional 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`. * `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`. * `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`. * `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. ^ Create an explosion.
* `position` The center of explosion. * `position` The center of explosion.
* `definition` The TNT definion as passed to `tnt.register` * `definition` The TNT definion as passed to `tnt.register` 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])` `tnt.burn(position, [nodename])`
@ -643,6 +695,7 @@ default.player_get_animation(player)
bar = {x = 20, y = 39}, bar = {x = 20, y = 39},
-- ... -- ...
}, },
eye_height = 1.47, -- In nodes above feet position
} }
Leafdecay Leafdecay
@ -862,3 +915,48 @@ for the wielded skeleton key.
if `nil` is returned, it is assumed that the wielder did not have 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. 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)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -31,8 +31,11 @@
#enable_lavacooling = true #enable_lavacooling = true
# Whether the stuff in initial_stuff should be given to new players # Whether the stuff in initial_stuff should be given to new players
#give_initial_stuff = false # its depends of the configured at the initital_stuff_mod
#initial_stuff = default:pick_steel,default:axe_steel,default:shovel_steel,default:torch 99,default:cobble 99 #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 # Whether the TNT mod should be enabled
#enable_tnt = <true in singleplayer, false in multiplayer> #enable_tnt = <true in singleplayer, false in multiplayer>

55
mods/README.md Normal file
View 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
View 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
View 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)

View File

@ -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.

View File

@ -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) 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, description = def.description,
inventory_image = def.inventory_image, inventory_image = def.inventory_image,
wield_image = def.wield_image, wield_image = def.wield_image,
drawtype = "nodebox", drawtype = "mesh",
tiles = def.tiles.bottom, mesh = def.mesh or new_mesh,
tiles = new_tiles or def.tiles,
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
is_ground_content = false,
stack_max = 1, stack_max = 1,
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 1}, groups = {
sounds = def.sounds or default.node_sound_wood_defaults(), choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 1,
node_box = { fall_damage_add_percent = -40, bouncy = 85
type = "fixed",
fixed = def.nodebox.bottom,
}, },
sounds = default.node_sound_wood_defaults(),
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = def.selectionbox, fixed = def.selectionbox
},
collision_box = {
type = "fixed",
fixed = def.collisionbox
}, },
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
local under = pointed_thing.under local under = pointed_thing.under
local node = minetest.get_node(under) local node = minetest.get_node(under)
local udef = minetest.registered_nodes[node.name] 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, return udef.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack pointed_thing) or itemstack
end end
local pos local pos
if minetest.registered_items[minetest.get_node(under).name].buildable_to then
if udef and udef.buildable_to then
pos = under pos = under
else else
pos = pointed_thing.above pos = pointed_thing.above
end end
if minetest.is_protected(pos, placer:get_player_name()) and local player_name = placer and placer:get_player_name() or ""
not minetest.check_player_privs(placer, "protection_bypass") then
minetest.record_protection_violation(pos, placer:get_player_name()) 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 return itemstack
end end
local node_def = minetest.registered_nodes[minetest.get_node(pos).name] local node_def = minetest.registered_nodes[minetest.get_node(pos).name]
if not node_def or not node_def.buildable_to then if not node_def or not node_def.buildable_to then
return itemstack return itemstack
end 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)) local botpos = vector.add(pos, minetest.facedir_to_dir(dir))
if minetest.is_protected(botpos, placer:get_player_name()) and if minetest.is_protected(botpos, player_name)
not minetest.check_player_privs(placer, "protection_bypass") then and not minetest.check_player_privs(player_name, "protection_bypass") then
minetest.record_protection_violation(botpos, placer:get_player_name())
minetest.record_protection_violation(botpos, player_name)
return itemstack return itemstack
end end
local botdef = minetest.registered_nodes[minetest.get_node(botpos).name] local botdef = minetest.registered_nodes[minetest.get_node(botpos).name]
if not botdef or not botdef.buildable_to then if not botdef or not botdef.buildable_to then
return itemstack return itemstack
end end
minetest.set_node(pos, {name = name .. "_bottom", param2 = dir}) minetest.set_node(pos, {name = name, param2 = dir})
minetest.set_node(botpos, {name = name .. "_top", param2 = dir})
if not (creative and creative.is_enabled_for if not beds.is_creative(player_name) then
and creative.is_enabled_for(placer:get_player_name())) then
itemstack:take_item() itemstack:take_item()
end end
return itemstack return itemstack
end, end,
on_destruct = function(pos) on_rightclick = function(pos, node, clicker)
destruct_bed(pos, 1)
end,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
beds.on_rightclick(pos, clicker) beds.on_rightclick(pos, clicker)
return itemstack
end, 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) on_destruct = function(pos)
destruct_bed(pos, 2) beds.remove_spawns_at(pos)
end, 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({ minetest.register_craft({
output = name, output = name,
recipe = def.recipe recipe = def.recipe

View File

@ -1,87 +1,65 @@
local S = beds.get_translator
-- Fancy shaped bed -- Fancy shaped bed
beds.register_bed("beds:fancy_bed", { beds.register_bed("beds:fancy_bed", {
description = "Fancy Bed", description = S("Fancy Bed"),
inventory_image = "beds_bed_fancy.png", inventory_image = "beds_bed_fancy.png",
wield_image = "beds_bed_fancy.png", wield_image = "beds_bed_fancy.png",
tiles = { tiles = {"beds_fancy_bed.png", "default_wood.png"},
bottom = { mesh = "beds_fancy_bed.obj",
"beds_bed_top1.png", selectionbox = {-0.5, -0.5, -0.5, 0.5, -0.06, 1.5},
"default_wood.png", collisionbox = {-0.5, -0.5, -0.5, 0.5, -0.06, 1.5},
"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},
recipe = { recipe = {
{"", "", "group:stick"}, {"", "", "group:stick"},
{"wool:red", "wool:red", "wool:white"}, {"wool:white", "wool:white", "wool:white"},
{"group:wood", "group:wood", "group:wood"}, {"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 -- Simple shaped bed
beds.register_bed("beds:bed", { beds.register_bed("beds:bed", {
description = "Simple Bed", description = S("Simple Bed"),
inventory_image = "beds_bed.png", inventory_image = "beds_bed.png",
wield_image = "beds_bed.png", wield_image = "beds_bed.png",
tiles = { tiles = {"beds_simple_bed.png"},
bottom = { mesh = "beds_simple_bed.obj",
"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},
},
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5}, selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
recipe = { recipe = {
{"wool:red", "wool:red", "wool:white"}, {"wool:white", "wool:white", "wool:white"},
{"group:wood", "group:wood", "group:wood"} {"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 -- Aliases for PilzAdam's beds mod
@ -93,12 +71,12 @@ minetest.register_alias("beds:bed_top_red", "beds:bed_top")
minetest.register_craft({ minetest.register_craft({
type = "fuel", type = "fuel",
recipe = "beds:fancy_bed_bottom", recipe = "beds:fancy_bed",
burntime = 13, burntime = 13
}) })
minetest.register_craft({ minetest.register_craft({
type = "fuel", type = "fuel",
recipe = "beds:bed_bottom", recipe = "beds:bed",
burntime = 12, burntime = 12
}) })

View File

@ -1,2 +1,4 @@
default default
wool wool
pova?
intllib?

View File

@ -0,0 +1 @@
beds which allows sleep, featured to (auto) skip the night.

View File

@ -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 pi = math.pi
local player_in_bed = 0
local is_sp = minetest.is_singleplayer() local is_sp = minetest.is_singleplayer()
local enable_respawn = minetest.settings:get_bool("enable_bed_respawn") local enable_respawn = minetest.settings:get_bool("enable_bed_respawn")
if enable_respawn == nil then if enable_respawn == nil then
enable_respawn = true enable_respawn = true
end end
@ -9,34 +13,49 @@ end
-- Helper functions -- Helper functions
local function get_look_yaw(pos) local function get_look_yaw(pos)
local n = minetest.get_node(pos)
if n.param2 == 1 then local rotation = minetest.get_node(pos).param2
return pi / 2, n.param2
elseif n.param2 == 3 then if rotation > 3 then
return -pi / 2, n.param2 rotation = rotation % 4 -- Mask colorfacedir values
elseif n.param2 == 0 then end
return pi, n.param2
if rotation == 1 then
return pi / 2, rotation
elseif rotation == 3 then
return -pi / 2, rotation
elseif rotation == 0 then
return pi, rotation
else else
return 0, n.param2 return 0, rotation
end end
end end
local function is_night_skip_enabled() local function is_night_skip_enabled()
local enable_night_skip = minetest.settings:get_bool("enable_bed_night_skip") local enable_night_skip = minetest.settings:get_bool("enable_bed_night_skip")
if enable_night_skip == nil then if enable_night_skip == nil then
enable_night_skip = true enable_night_skip = true
end end
return enable_night_skip return enable_night_skip
end end
local function check_in_beds(players) local function check_in_beds(players)
local in_bed = beds.player local in_bed = beds.player
if not players then if not players then
players = minetest.get_connected_players() players = minetest.get_connected_players()
end end
for n, player in ipairs(players) do for n, player in ipairs(players) do
local name = player:get_player_name() local name = player:get_player_name()
if not in_bed[name] then if not in_bed[name] then
return false return false
end end
@ -45,7 +64,9 @@ local function check_in_beds(players)
return #players > 0 return #players > 0
end end
local function lay_down(player, pos, bed_pos, state, skip) local function lay_down(player, pos, bed_pos, state, skip)
local name = player:get_player_name() local name = player:get_player_name()
local hud_flags = player:hud_get_flags() local hud_flags = player:hud_get_flags()
@ -55,61 +76,156 @@ local function lay_down(player, pos, bed_pos, state, skip)
-- stand up -- stand up
if state ~= nil and not state then if state ~= nil and not state then
local p = beds.pos[name] or nil
if beds.player[name] ~= nil then if not beds.player[name] then
beds.player[name] = nil return false -- player not in bed, do nothing
player_in_bed = player_in_bed - 1
end end
beds.bed_position[name] = nil
-- skip here to prevent sending player specific changes (used for leaving players) -- skip here to prevent sending player specific changes (used for leaving players)
if skip then if skip then
return return
end end
if p then
player:setpos(p) player:set_pos(beds.pos[name])
end
-- physics, eye_offset, etc -- 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_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
player:set_look_horizontal(math.random(1, 180) / 100) 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
else player_api.player_attached[name] = false
beds.player[name] = 1 player_api.set_animation(player, "stand" , 30)
else
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 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 -- physics, eye_offset, etc
player:set_eye_offset({x = 0, y = -13, z = 0}, {x = 0, y = 0, z = 0}) player:set_eye_offset({x = 0, y = -13, z = 0}, {x = 0, y = 0, z = 0})
local yaw, param2 = get_look_yaw(bed_pos) local yaw, param2 = get_look_yaw(bed_pos)
player:set_look_horizontal(yaw) player:set_look_horizontal(yaw)
local dir = minetest.facedir_to_dir(param2) 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) -- p.y is just above the nodebox height of the 'Simple Bed' (the highest bed),
player:setpos(p) -- to avoid sinking down through the bed.
default.player_attached[name] = true 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
default.player_set_animation(player, "lay" , 0)
end
hud_flags.wielditem = false hud_flags.wielditem = false
default.player_set_animation(player, "lay" , 0)
end end
player:hud_set_flags(hud_flags) player:hud_set_flags(hud_flags)
end 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 function update_formspecs(finished)
local ges = #minetest.get_connected_players() 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 is_majority = (ges / 2) < player_in_bed
local form_n
local esc = minetest.formspec_escape
if finished then 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 else
form_n = beds.formspec .. "label[2.2,11;" .. tostring(player_in_bed) .. form_n = beds.formspec .. "label[2.2,9;" ..
" of " .. tostring(ges) .. " players are in bed]" esc(S("@1 of @2 players are in bed", player_in_bed, ges)) .. "]"
if is_majority and is_night_skip_enabled() then if is_majority and is_night_skip_enabled() then
form_n = form_n .. "button_exit[2,8;4,0.75;force;Force night skip]" form_n = form_n .. "button_exit[2,6;4,0.75;force;" ..
esc(S("Force night skip")) .. "]"
end end
end end
@ -118,36 +234,46 @@ local function update_formspecs(finished)
end end
end end
-- Public functions -- Public functions
function beds.kick_players() function beds.kick_players()
for name, _ in pairs(beds.player) do for name, _ in pairs(beds.player) do
local player = minetest.get_player_by_name(name) local player = minetest.get_player_by_name(name)
lay_down(player, nil, nil, false) lay_down(player, nil, nil, false)
end end
end end
function beds.skip_night() function beds.skip_night()
minetest.set_timeofday(0.23) minetest.set_timeofday(0.23)
end end
function beds.on_rightclick(pos, player) function beds.on_rightclick(pos, player)
local name = player:get_player_name() local name = player:get_player_name()
local ppos = player:getpos() local ppos = player:get_pos()
local tod = minetest.get_timeofday() 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 if beds.player[name] then
lay_down(player, nil, nil, false) lay_down(player, nil, nil, false)
end 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 return
end end
-- move to bed -- move to bed
if not beds.player[name] then if not beds.player[name] then
lay_down(player, ppos, pos) lay_down(player, ppos, pos)
beds.set_spawns() -- save respawn positions when entering bed beds.set_spawns() -- save respawn positions when entering bed
else else
lay_down(player, nil, nil, false) 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 -- skip the night and let all players stand up
if check_in_beds() then if check_in_beds() then
minetest.after(2, function() minetest.after(2, function()
if not is_sp then if not is_sp then
update_formspecs(is_night_skip_enabled()) update_formspecs(is_night_skip_enabled())
end end
if is_night_skip_enabled() then if is_night_skip_enabled() then
beds.skip_night() beds.skip_night()
beds.kick_players() beds.kick_players()
@ -172,27 +301,56 @@ function beds.on_rightclick(pos, player)
end 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 -- Callbacks
-- Only register respawn callback if respawn enabled -- Only register respawn callback if respawn enabled
if enable_respawn then if enable_respawn then
-- respawn player at bed if enabled and valid position is found -- respawn player at bed if enabled and valid position is found
minetest.register_on_respawnplayer(function(player) minetest.register_on_respawnplayer(function(player)
if not player then return end
local name = player:get_player_name() local name = player:get_player_name()
local pos = beds.spawn[name] local pos = beds.spawn[name]
if pos then if pos then
player:setpos(pos) player:set_pos(pos)
return true return true
end end
end) end)
end end
minetest.register_on_leaveplayer(function(player) minetest.register_on_leaveplayer(function(player)
if not player then return end
local name = player:get_player_name() local name = player:get_player_name()
lay_down(player, nil, nil, false, true) lay_down(player, nil, nil, false, true)
beds.player[name] = nil beds.player[name] = nil
if check_in_beds() then if check_in_beds() then
minetest.after(2, function() minetest.after(2, function()
update_formspecs(is_night_skip_enabled()) update_formspecs(is_night_skip_enabled())
if is_night_skip_enabled() then if is_night_skip_enabled() then
beds.skip_night() beds.skip_night()
beds.kick_players() beds.kick_players()
@ -201,20 +359,54 @@ minetest.register_on_leaveplayer(function(player)
end end
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) minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "beds_form" then if formname ~= "beds_form" then
return return
end 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 if fields.quit or fields.leave then
lay_down(player, nil, nil, false) lay_down(player, nil, nil, false)
update_formspecs(false) update_formspecs(false)
end end
if fields.force then 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.skip_night()
beds.kick_players() beds.kick_players()
else
update_formspecs(false)
end end
end end
end) end)

View File

@ -1,17 +1,67 @@
beds = {} local is_50 = nil
beds.player = {} local is_53 = minetest.has_feature("object_step_has_moveresult")
beds.pos = {} local is_54 = minetest.has_feature("direct_velocity_on_players")
beds.spawn = {}
beds.formspec = "size[8,15;true]" .. -- Load support for MT game translation.
"bgcolor[#080808BB; true]" .. local S
"button_exit[2,12;4,0.75;leave;Leave Bed]" 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") 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 -- Load files
dofile(modpath .. "/functions.lua") dofile(modpath .. "/functions.lua")
dofile(modpath .. "/api.lua") dofile(modpath .. "/api.lua")
dofile(modpath .. "/beds.lua") dofile(modpath .. "/beds.lua")
dofile(modpath .. "/spawns.lua") dofile(modpath .. "/spawns.lua")
print("[MOD] Beds loaded")

View File

@ -30,6 +30,7 @@ Licenses of media (textures)
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
Copyright (C) 2014-2016 BlockMen Copyright (C) 2014-2016 BlockMen
Copyright (C) 2018 TumeniNodes
You are free to: You are free to:
Share — copy and redistribute the material in any medium or format. Share — copy and redistribute the material in any medium or format.

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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=Встать с кровати

View 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

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

View 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=离开床

View 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=離開床

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

View File

@ -0,0 +1,160 @@
# Blender v2.69 (sub 0) OBJ File: ''
# www.blender.org
mtllib fancy_bed.mtl
o mattress_Mattress_nodebox-6_none.001_fancy_bed.png.001
v 0.437500 -0.312500 -0.437501
v 0.437500 -0.062500 -0.437501
v 0.437500 -0.062500 1.437499
v 0.437500 -0.312500 1.437499
v -0.437500 -0.312500 -0.437501
v -0.437500 -0.312500 1.437499
v -0.437500 -0.062500 1.437499
v -0.437500 -0.062500 -0.437501
v 0.437500 -0.176793 -0.437501
v -0.437500 -0.176793 -0.437501
vt 0.000171 0.499972
vt 0.000161 0.000182
vt 0.999791 0.000253
vt 0.999873 0.500022
vt 0.749576 0.000208
vt 0.749876 0.499854
vt 0.999848 0.999750
vt 0.000152 0.999750
vt 0.749276 0.130648
vt 0.000112 0.130648
g mattress_Mattress_nodebox-6_none.001_fancy_bed.png.001_none.001_fancy_bed.png.001
usemtl none.001_fancy_bed.png.001
s off
f 1/1 2/2 3/3 4/4
f 5/2 6/3 7/4 8/1
f 4/5 3/2 7/1 6/6
f 1/1 4/4 6/7 5/8
f 2/1 8/2 7/3 3/4
f 8/2 2/5 9/9 10/10
o wood_structure_Wood_structure_nodebox-4.001_none.002
v 0.374999 -0.375000 1.437499
v 0.374999 -0.125000 1.437499
v 0.374999 -0.125000 1.499999
v 0.374999 -0.375000 1.499999
v -0.374999 -0.375000 1.437499
v -0.374999 -0.375000 1.499999
v -0.374999 -0.125000 1.499999
v -0.374999 -0.125000 1.437499
v -0.375000 -0.500000 1.437499
v -0.375000 0.187500 1.437499
v -0.375000 0.187500 1.499999
v -0.375000 -0.500000 1.499999
v -0.500000 -0.500000 1.437499
v -0.500000 -0.500000 1.499999
v -0.500000 0.187500 1.499999
v -0.500000 0.187500 1.437499
v -0.437500 -0.375000 -0.437501
v -0.437500 -0.125000 -0.437501
v -0.437500 -0.125000 1.437498
v -0.437500 -0.375000 1.437498
v -0.500000 -0.375000 -0.437501
v -0.500000 -0.375000 1.437498
v -0.500000 -0.125000 1.437498
v -0.500000 -0.125000 -0.437501
v 0.375001 -0.000000 1.437499
v 0.375001 0.125000 1.437499
v 0.375001 0.125000 1.499999
v 0.375001 -0.000000 1.499999
v -0.375001 -0.000000 1.437499
v -0.375001 -0.000000 1.499999
v -0.375001 0.125000 1.499999
v -0.375001 0.125000 1.437499
v 0.500000 -0.500000 1.437499
v 0.500000 0.187500 1.437499
v 0.500000 0.187500 1.499999
v 0.500000 -0.500000 1.499999
v 0.375000 -0.500000 1.437499
v 0.375000 -0.500000 1.499999
v 0.375000 0.187500 1.499999
v 0.375000 0.187500 1.437499
v 0.500000 -0.375000 -0.437501
v 0.500000 -0.125000 -0.437501
v 0.500000 -0.125000 1.437499
v 0.500000 -0.375000 1.437499
v 0.437500 -0.375000 -0.437501
v 0.437500 -0.375000 1.437499
v 0.437500 -0.125000 1.437499
v 0.437500 -0.125000 -0.437501
v -0.375000 -0.500000 -0.500000
v -0.375000 -0.065000 -0.500000
v -0.375000 -0.065000 -0.437500
v -0.375000 -0.500000 -0.437500
v -0.500000 -0.500000 -0.500000
v -0.500000 -0.500000 -0.437500
v -0.500000 -0.065000 -0.437500
v -0.500000 -0.065000 -0.500000
v 0.375006 -0.375000 -0.500000
v 0.375006 -0.125000 -0.500000
v 0.375006 -0.125000 -0.437500
v 0.375006 -0.375000 -0.437500
v -0.375006 -0.375000 -0.500000
v -0.375006 -0.375000 -0.437500
v -0.375006 -0.125000 -0.437500
v -0.375006 -0.125000 -0.500000
v 0.500000 -0.500000 -0.500000
v 0.500000 -0.065000 -0.500000
v 0.500000 -0.065000 -0.437500
v 0.500000 -0.500000 -0.437500
v 0.375000 -0.500000 -0.500000
v 0.375000 -0.500000 -0.437500
v 0.375000 -0.065000 -0.437500
v 0.375000 -0.065000 -0.500000
vt 0.377610 0.378205
vt 0.622484 0.378175
vt 0.622515 0.623120
vt 0.377671 0.623151
g wood_structure_Wood_structure_nodebox-4.001_none.002_none.002
usemtl none.002
s off
f 59/11 60/12 61/13 62/14
f 63/14 64/11 65/12 66/13
f 59/11 63/14 66/13 60/12
f 62/14 61/13 65/12 64/11
f 59/11 62/14 64/13 63/12
f 60/12 66/11 65/14 61/13
f 67/11 71/12 74/13 68/14
f 70/14 69/11 73/12 72/13
f 67/11 70/12 72/13 71/14
f 68/11 74/12 73/13 69/14
f 75/11 76/12 77/13 78/14
f 79/14 80/11 81/12 82/13
f 75/14 79/11 82/12 76/13
f 78/11 77/12 81/13 80/14
f 75/11 78/12 80/13 79/14
f 76/11 82/12 81/13 77/14
g wood_structure_Wood_structure_nodebox-4.001_none.002_none.003
usemtl none.003
f 15/11 16/12 17/13 18/14
f 11/13 15/14 18/11 12/12
f 14/14 13/11 17/12 16/13
f 11/14 14/11 16/12 15/13
f 12/11 18/12 17/13 13/14
f 19/11 20/12 21/13 22/14
f 23/14 24/11 25/12 26/13
f 19/14 23/11 26/12 20/13
f 22/11 21/12 25/13 24/14
f 19/11 22/12 24/13 23/14
f 20/11 26/12 25/13 21/14
f 27/14 28/11 29/12 30/13
f 31/11 32/12 33/13 34/14
f 27/11 30/12 32/13 31/14
f 28/14 34/11 33/12 29/13
f 35/11 39/12 42/13 36/14
f 38/14 37/11 41/12 40/13
f 35/14 38/11 40/12 39/13
f 36/11 42/12 41/13 37/14
f 43/11 44/12 45/13 46/14
f 47/14 48/11 49/12 50/13
f 43/14 47/11 50/12 44/13
f 46/11 45/12 49/13 48/14
f 43/11 46/12 48/13 47/14
f 44/11 50/12 49/13 45/14
f 51/14 52/11 53/12 54/13
f 55/13 56/14 57/11 58/12
f 51/11 54/12 56/13 55/14
f 52/14 58/11 57/12 53/13

View File

@ -0,0 +1,32 @@
# Blender v2.69 (sub 0) OBJ File: ''
# www.blender.org
mtllib simple_bed.mtl
o Simple_Bed
v 0.500000 -0.500000 -0.500000
v 0.500000 0.060000 -0.500000
v 0.500000 0.060000 1.500000
v 0.500000 -0.500000 1.500000
v -0.500000 -0.500000 -0.500000
v -0.500000 -0.500000 1.500000
v -0.500000 0.060000 1.500000
v -0.500000 0.060000 -0.500000
vt 0.000112 0.780442
vt 0.000110 0.999969
vt 0.780324 0.999889
vt 0.780377 0.780471
vt 0.780636 0.390284
vt 0.999906 0.780382
vt 0.999906 0.390284
vt 0.780636 0.000047
vt 0.999906 0.000094
vt 0.390235 0.780320
vt 0.390235 0.000071
vt 0.000142 0.000142
usemtl none.002
s off
f 1/1 2/2 3/3 4/4
f 5/1 6/4 7/3 8/2
f 1/5 5/4 8/6 2/7
f 4/8 3/9 7/7 6/5
f 1/8 4/4 6/10 5/11
f 2/11 8/12 7/1 3/10

BIN
mods/beds/screenshot.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

View 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

View File

@ -3,30 +3,44 @@ local org_file = world_path .. "/beds_spawns"
local file = world_path .. "/beds_spawns" local file = world_path .. "/beds_spawns"
local bkwd = false local bkwd = false
-- check for PA's beds mod spawns -- check for PA's beds mod spawns
local cf = io.open(world_path .. "/beds_player_spawns", "r") local cf = io.open(world_path .. "/beds_player_spawns", "r")
if cf ~= nil then if cf ~= nil then
io.close(cf) io.close(cf)
file = world_path .. "/beds_player_spawns" file = world_path .. "/beds_player_spawns"
bkwd = true bkwd = true
end end
function beds.read_spawns() function beds.read_spawns()
local spawns = beds.spawn local spawns = beds.spawn
local input = io.open(file, "r") local input = io.open(file, "r")
if input and not bkwd then if input and not bkwd then
repeat repeat
local x = input:read("*n") local x = input:read("*n")
if x == nil then if x == nil then
break break
end end
local y = input:read("*n") local y = input:read("*n")
local z = input:read("*n") local z = input:read("*n")
local name = input:read("*l") local name = input:read("*l")
spawns[name:sub(2)] = {x = x, y = y, z = z} spawns[name:sub(2)] = {x = x, y = y, z = z}
until input:read(0) == nil until input:read(0) == nil
io.close(input) io.close(input)
elseif input and bkwd then elseif input and bkwd then
beds.spawn = minetest.deserialize(input:read("*all")) beds.spawn = minetest.deserialize(input:read("*all"))
input:close() input:close()
beds.save_spawns() beds.save_spawns()
@ -35,29 +49,53 @@ function beds.read_spawns()
end end
end end
beds.read_spawns() beds.read_spawns()
function beds.save_spawns() function beds.save_spawns()
if not beds.spawn then if not beds.spawn then
return return
end end
local data = {} local data = {}
local output = io.open(org_file, "w") local output = io.open(org_file, "w")
for k, v in pairs(beds.spawn) do for k, v in pairs(beds.spawn) do
table.insert(data, string.format("%.1f %.1f %.1f %s\n", v.x, v.y, v.z, k)) table.insert(data, string.format("%.1f %.1f %.1f %s\n", v.x, v.y, v.z, k))
end end
output:write(table.concat(data)) output:write(table.concat(data))
io.close(output) io.close(output)
end end
function beds.set_spawns() function beds.set_spawns()
for name,_ in pairs(beds.player) do for name,_ in pairs(beds.player) do
local player = minetest.get_player_by_name(name) local player = minetest.get_player_by_name(name)
local p = player:getpos() local p = player:get_pos()
-- but don't change spawn location if borrowing a bed -- but don't change spawn location if borrowing a bed
if not minetest.is_protected(p, name) then if not minetest.is_protected(p, name) then
beds.spawn[name] = p beds.spawn[name] = p
end end
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() beds.save_spawns()
end end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 540 B

After

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 537 B

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 561 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 611 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 583 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 495 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 556 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 555 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 632 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 B

77
mods/boats/README.md Normal file
View 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)

View File

@ -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)

View File

@ -1 +1,3 @@
default default
player_api?
creative?

View File

@ -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 -- Helper functions
-- --
@ -8,15 +38,6 @@ local function is_water(pos)
end 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 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
@ -28,23 +49,41 @@ 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
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 -- Boat entity
-- --
local boat = { local boat = {
physical = true, initial_properties = {
-- Warning: Do not change the position of the collisionbox top surface, physical = true,
-- lowering it causes the boat to fall through the world if underwater -- Warning: Do not change the position of the collisionbox top surface,
collisionbox = {-0.5, -0.35, -0.5, 0.5, 0.3, 0.5}, -- lowering it causes the boat to fall through the world if underwater
visual = "mesh", collisionbox = {-0.5, -0.35, -0.5, 0.5, 0.3, 0.5},
mesh = "boats_boat.obj", visual = "mesh",
textures = {"default_wood.png"}, mesh = "boats_boat.obj",
textures = {"default_wood.png"}
},
driver = nil, driver = nil,
v = 0, v = 0,
last_v = 0, last_v = 0,
removed = false removed = false,
auto = false
} }
@ -53,39 +92,58 @@ function boat.on_rightclick(self, clicker)
return return
end end
local name = clicker:get_player_name() local name = clicker:get_player_name()
if self.driver and clicker == self.driver then if self.driver and name == self.driver then
self.driver = nil -- Cleanup happens in boat.on_detach_child
clicker:set_detach() clicker:set_detach()
default.player_attached[name] = false if is_pa then
default.player_set_animation(clicker, "stand" , 30) player_api.set_animation(clicker, "stand", 30)
local pos = clicker:getpos() else
default.player_set_animation(clicker, "stand", 30)
end
local pos = clicker:get_pos()
pos = {x = pos.x, y = pos.y + 0.2, z = pos.z} pos = {x = pos.x, y = pos.y + 0.2, z = pos.z}
minetest.after(0.1, function() minetest.after(0.1, function()
clicker:setpos(pos) clicker:set_pos(pos)
end) end)
elseif not self.driver then elseif not self.driver then
local attach = clicker:get_attach()
if attach and attach:get_luaentity() then
local luaentity = attach:get_luaentity()
if luaentity.driver then
luaentity.driver = nil
end
clicker:set_detach()
end
self.driver = clicker
clicker:set_attach(self.object, "", clicker:set_attach(self.object, "",
{x = 0, y = 11, z = -3}, {x = 0, y = 0, z = 0}) {x = 0.5, y = 1, z = -3}, {x = 0, y = 0, z = 0})
default.player_attached[name] = true
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() minetest.after(0.2, function()
default.player_set_animation(clicker, "sit" , 30) if is_pa then
player_api.set_animation(clicker, "sit", 30)
else
default.player_set_animation(clicker, "sit", 30)
end
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
end end
function boat.on_activate(self, staticdata, dtime_s) 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 if staticdata then
self.v = tonumber(staticdata) self.v = tonumber(staticdata)
end end
@ -102,21 +160,26 @@ function boat.on_punch(self, puncher)
if not puncher or not puncher:is_player() or self.removed then if not puncher or not puncher:is_player() or self.removed then
return return
end end
if self.driver and puncher == self.driver then
local name = puncher:get_player_name()
if self.driver and name == self.driver then
self.driver = nil self.driver = nil
puncher:set_detach() 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 end
if not self.driver then if not self.driver then
self.removed = true self.removed = true
local inv = puncher:get_inventory() local inv = puncher:get_inventory()
if not (creative and creative.is_enabled_for if not is_creative_enabled(name)
and creative.is_enabled_for(puncher:get_player_name()))
or not inv:contains_item("main", "boats:boat") then or not inv:contains_item("main", "boats:boat") then
local leftover = inv:add_item("main", "boats:boat") local leftover = inv:add_item("main", "boats:boat")
-- if no room in inventory add a replacement boat to the world -- if no room in inventory add a replacement boat to the world
if not leftover:is_empty() then if not leftover:is_empty() then
minetest.add_item(self.object:getpos(), leftover) minetest.add_item(self.object:get_pos(), leftover)
end end
end end
-- delay remove to ensure player is detached -- delay remove to ensure player is detached
@ -128,46 +191,73 @@ end
function boat.on_step(self, dtime) function boat.on_step(self, dtime)
self.v = get_v(self.object:getvelocity()) * get_sign(self.v)
if self.driver then -- after 10 seconds remove boat and drop as item if not boarded
local ctrl = self.driver:get_player_control() self.count = (self.count or 0) + dtime
local yaw = self.object:getyaw()
if ctrl.up then if self.count > 10 then
self.v = self.v + 0.1 minetest.add_item(self.object:get_pos(), "boats:boat")
elseif ctrl.down then self.object:remove()
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())
return return
end 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 p.y = p.y - 0.5
local new_velo local new_velo
local new_acce = {x = 0, y = 0, z = 0} local new_acce = {x = 0, y = 0, z = 0}
@ -179,13 +269,13 @@ function boat.on_step(self, dtime)
else else
new_acce = {x = 0, y = -9.8, z = 0} new_acce = {x = 0, y = -9.8, z = 0}
end end
new_velo = get_velocity(self.v, self.object:getyaw(), new_velo = get_velocity(self.v, self.object:get_yaw(),
self.object:getvelocity().y) self.object:get_velocity().y)
self.object:setpos(self.object:getpos()) self.object:set_pos(self.object:get_pos())
else else
p.y = p.y + 1 p.y = p.y + 1
if is_water(p) then if is_water(p) then
local y = self.object:getvelocity().y local y = self.object:get_velocity().y
if y >= 5 then if y >= 5 then
y = 5 y = 5
elseif y < 0 then elseif y < 0 then
@ -193,24 +283,48 @@ function boat.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 = get_velocity(self.v, self.object:getyaw(), y) new_velo = get_velocity(self.v, self.object:get_yaw(), y)
self.object:setpos(self.object:getpos()) self.object:set_pos(self.object:get_pos())
else else
new_acce = {x = 0, y = 0, z = 0} new_acce = {x = 0, y = 0, z = 0}
if math.abs(self.object:getvelocity().y) < 1 then if math.abs(self.object:get_velocity().y) < 1 then
local pos = self.object:getpos() local pos = self.object:get_pos()
pos.y = math.floor(pos.y) + 0.5 pos.y = math.floor(pos.y) + 0.5
self.object:setpos(pos) self.object:set_pos(pos)
new_velo = get_velocity(self.v, self.object:getyaw(), 0) new_velo = get_velocity(self.v, self.object:get_yaw(), 0)
else else
new_velo = get_velocity(self.v, self.object:getyaw(), new_velo = get_velocity(self.v, self.object:get_yaw(),
self.object:getvelocity().y) self.object:get_velocity().y)
self.object:setpos(self.object:getpos()) self.object:set_pos(self.object:get_pos())
end end
end end
end end
self.object:setvelocity(new_velo) self.object:set_velocity(new_velo)
self.object:setacceleration(new_acce) 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 end
@ -218,7 +332,7 @@ minetest.register_entity("boats:boat", boat)
minetest.register_craftitem("boats:boat", { minetest.register_craftitem("boats:boat", {
description = "Boat", description = S("Boat"),
inventory_image = "boats_inventory.png", inventory_image = "boats_inventory.png",
wield_image = "boats_wield.png", wield_image = "boats_wield.png",
wield_scale = {x = 2, y = 2, z = 1}, wield_scale = {x = 2, y = 2, z = 1},
@ -230,7 +344,8 @@ minetest.register_craftitem("boats:boat", {
local node = minetest.get_node(under) local node = minetest.get_node(under)
local udef = minetest.registered_nodes[node.name] local udef = minetest.registered_nodes[node.name]
if udef and udef.on_rightclick and 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, return udef.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack pointed_thing) or itemstack
end end
@ -244,9 +359,11 @@ minetest.register_craftitem("boats:boat", {
pointed_thing.under.y = pointed_thing.under.y + 0.5 pointed_thing.under.y = pointed_thing.under.y + 0.5
boat = minetest.add_entity(pointed_thing.under, "boats:boat") boat = minetest.add_entity(pointed_thing.under, "boats:boat")
if boat then if boat then
boat:setyaw(placer:get_look_horizontal()) if placer then
if not (creative and creative.is_enabled_for boat:set_yaw(placer:get_look_horizontal())
and creative.is_enabled_for(placer:get_player_name())) then end
local player_name = placer and placer:get_player_name() or ""
if not is_creative_enabled(player_name) then
itemstack:take_item() itemstack:take_item()
end end
end end
@ -269,3 +386,6 @@ minetest.register_craft({
recipe = "boats:boat", recipe = "boats:boat",
burntime = 20, burntime = 20,
}) })
print ("[MOD] Boats loaded")

View File

@ -33,6 +33,7 @@ Copyright (C) 2012-2016 Zeg9
Copyright (C) 2012-2016 thetoon Copyright (C) 2012-2016 thetoon
Copyright (C) 2012-2016 PavelS(SokolovPavel) Copyright (C) 2012-2016 PavelS(SokolovPavel)
Copyright (C) 2016 sofar (sofar@foo-projects.org) Copyright (C) 2016 sofar (sofar@foo-projects.org)
Copyright (C) 2019 Bartosz (gang65@poczta.onet.pl)
You are free to: You are free to:
Share — copy and redistribute the material in any medium or format. Share — copy and redistribute the material in any medium or format.

3
mods/boats/mod.conf Normal file
View File

@ -0,0 +1,3 @@
name = boats
depends = default, creative
optional_depends = player_api

BIN
mods/boats/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

View File

@ -68,6 +68,12 @@ minetest.register_node("bones:bones", {
on_metadata_inventory_take = function(pos, listname, index, stack, player) on_metadata_inventory_take = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
if meta:get_inventory():is_empty("main") then 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) minetest.remove_node(pos)
end end
end, end,

56
mods/bucket/README.md Normal file
View 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)

View File

@ -1,13 +1,56 @@
Minetest Game mod: bucket minetest mod Bucket
========================= =========================
See license.txt for license information.
Authors of source code This mod is just bucket, but compatible with any engine
----------------------
Kahrl <kahrl@gmx.net> (LGPL 2.1) Information
celeron55, Perttu Ahola <celeron55@gmail.com> (LGPL 2.1) -----------
Various Minetest developers and contributors (LGPL 2.1)
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) ElementW (CC BY-SA 3.0)
Check [license.txt](license.txt)

View File

@ -1,2 +1,2 @@
default default
intllib?

View File

@ -0,0 +1 @@
handle liquids in a tool named bucket

View File

@ -1,15 +1,39 @@
-- Minetest 0.4 mod: bucket -- Minetest mod: bucket
-- See README.txt for licensing and other information. -- 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", "bucket:bucket_empty")
minetest.register_alias("bucket_water", "bucket:bucket_water") minetest.register_alias("bucket_water", "bucket:bucket_water")
minetest.register_alias("bucket_lava", "bucket:bucket_lava") minetest.register_alias("bucket_lava", "bucket:bucket_lava")
minetest.register_craft({ minetest.register_craft({
output = 'bucket:bucket_empty 1', output = "bucket:bucket_empty 1",
recipe = { 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 end
local node = minetest.get_node_or_nil(pointed_thing.under) 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] local ndef = node and minetest.registered_nodes[node.name]
-- Call on_rightclick if the pointed node defines it -- Call on_rightclick if the pointed node defines it
if ndef and ndef.on_rightclick and 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( return ndef.on_rightclick(
pointed_thing.under, pointed_thing.under,
node, user, node, user,
@ -110,9 +136,9 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
end end
minetest.register_craftitem("bucket:bucket_empty", { minetest.register_craftitem("bucket:bucket_empty", {
description = "Empty Bucket", description = S("Empty Bucket"),
inventory_image = "bucket.png", inventory_image = "bucket.png",
stack_max = 99, groups = {tool = 1},
liquids_pointable = true, liquids_pointable = true,
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type == "object" then if pointed_thing.type == "object" then
@ -124,6 +150,7 @@ minetest.register_craftitem("bucket:bucket_empty", {
end end
-- Check if pointing to a liquid source -- Check if pointing to a liquid source
local node = minetest.get_node(pointed_thing.under) local node = minetest.get_node(pointed_thing.under)
if not node then return end
local liquiddef = bucket.liquids[node.name] local liquiddef = bucket.liquids[node.name]
local item_count = user:get_wielded_item():get_count() 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 if inv:room_for_item("main", {name=liquiddef.itemname}) then
inv:add_item("main", liquiddef.itemname) inv:add_item("main", liquiddef.itemname)
else else
local pos = user:getpos() local pos = user:get_pos()
pos.y = math.floor(pos.y + 0.5) pos.y = math.floor(pos.y + 0.5)
minetest.add_item(pos, liquiddef.itemname) minetest.add_item(pos, liquiddef.itemname)
end end
@ -184,17 +211,23 @@ bucket.register_liquid(
"default:water_flowing", "default:water_flowing",
"bucket:bucket_water", "bucket:bucket_water",
"bucket_water.png", "bucket_water.png",
"Water Bucket", S("Water Bucket"),
{water_bucket = 1} {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( bucket.register_liquid(
"default:river_water_source", "default:river_water_source",
"default:river_water_flowing", "default:river_water_flowing",
"bucket:bucket_river_water", "bucket:bucket_river_water",
"bucket_river_water.png", "bucket_river_water.png",
"River Water Bucket", S("River Water Bucket"),
{water_bucket = 1}, {tool = 1, water_bucket = 1},
true true
) )
@ -203,7 +236,8 @@ bucket.register_liquid(
"default:lava_flowing", "default:lava_flowing",
"bucket:bucket_lava", "bucket:bucket_lava",
"bucket_lava.png", "bucket_lava.png",
"Lava Bucket" S("Lava Bucket"),
{tool = 1}
) )
minetest.register_craft({ minetest.register_craft({
@ -213,3 +247,16 @@ minetest.register_craft({
replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}}, 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

View File

@ -0,0 +1,5 @@
# textdomain: bucket
Empty Bucket=Leerer Eimer
Water Bucket=Wassereimer
River Water Bucket=Flusswassereimer
Lava Bucket=Lavaeimer

View 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

View 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

View 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

View 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

View 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

View File

@ -0,0 +1,5 @@
# textdomain: bucket
Empty Bucket=空のバケツ
Water Bucket=水入りバケツ
River Water Bucket=川の水入りバケツ
Lava Bucket=溶岩入りバケツ

View 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

View 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

View 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

View File

@ -0,0 +1,5 @@
# textdomain: bucket
Empty Bucket=Пустое Ведро
Water Bucket=Ведро с Водой
River Water Bucket=Ведро с Речной Водой
Lava Bucket=Ведро с Лавой

View 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

View File

@ -0,0 +1,5 @@
# textdomain: bucket
Empty Bucket=Tom hink
Water Bucket=Vattenhink
River Water Bucket=Flodvattenshink
Lava Bucket=Lavahink

View File

@ -0,0 +1,5 @@
# textdomain: bucket
Empty Bucket=Пусте Відро
Water Bucket=Відро З Водою
River Water Bucket=Відро З Річною Водою
Lava Bucket=Відро З Лавою

View File

@ -0,0 +1,5 @@
# textdomain: bucket
Empty Bucket=空桶
Water Bucket=水桶
River Water Bucket=河水桶
Lava Bucket=岩浆桶

View File

@ -0,0 +1,5 @@
# textdomain: bucket
Empty Bucket=空桶
Water Bucket=水桶
River Water Bucket=河水桶
Lava Bucket=岩漿桶

View File

@ -0,0 +1,5 @@
# textdomain: bucket
Empty Bucket=
Water Bucket=
River Water Bucket=
Lava Bucket=

4
mods/bucket/mod.conf Normal file
View 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
View File

Before

Width:  |  Height:  |  Size: 205 B

After

Width:  |  Height:  |  Size: 205 B

74
mods/carts/README.md Normal file
View 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)

View File

@ -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

View File

@ -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 = { local cart_entity = {
physical = false, -- otherwise going uphill breaks initial_properties = {
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, physical = false, -- otherwise going uphill breaks
visual = "mesh", collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
mesh = "carts_cart.b3d", visual = "mesh",
visual_size = {x=1, y=1}, mesh = "carts_cart.b3d",
textures = {"carts_cart.png"}, visual_size = {x=1, y=1},
textures = {"carts_cart.png"},
},
driver = nil, driver = nil,
punched = false, -- used to re-send velocity and position punched = false, -- used to re-send velocity and position
@ -22,43 +35,49 @@ function cart_entity:on_rightclick(clicker)
end end
local player_name = clicker:get_player_name() local player_name = clicker:get_player_name()
if self.driver and player_name == self.driver then if self.driver and player_name == self.driver then
self.driver = nil
carts:manage_attachment(clicker, nil) carts:manage_attachment(clicker, nil)
elseif not self.driver then elseif not self.driver then
self.driver = player_name
carts:manage_attachment(clicker, self.object) carts:manage_attachment(clicker, self.object)
self.driver = player_name
end end
end end
function cart_entity:on_activate(staticdata, dtime_s) function cart_entity:on_activate(staticdata, dtime_s)
self.object:set_armor_groups({immortal=1}) 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 if string.sub(staticdata, 1, string.len("return")) ~= "return" then
return return
end end
local data = minetest.deserialize(staticdata) local data = minetest.deserialize(staticdata)
if not data or type(data) ~= "table" then if type(data) ~= "table" then
return return
end end
self.railtype = data.railtype self.railtype = data.railtype
if data.old_dir then if data.old_dir then
self.old_dir = data.old_dir self.old_dir = data.old_dir
end end
if data.old_vel then
self.old_vel = data.old_vel
end
end end
function cart_entity:get_staticdata() function cart_entity:get_staticdata()
return minetest.serialize({ return minetest.serialize({
railtype = self.railtype, railtype = self.railtype,
old_dir = self.old_dir, old_dir = self.old_dir
old_vel = self.old_vel
}) })
end 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) function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
local pos = self.object:getpos() local pos = self.object:get_pos()
if not self.railtype then 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 local node = minetest.get_node(pos).name
self.railtype = minetest.get_item_group(node, "connect_to_raillike") self.railtype = minetest.get_item_group(node, "connect_to_raillike")
end end
@ -80,12 +99,12 @@ function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities,
-- Detach driver and items -- Detach driver and items
if self.driver then if self.driver then
if self.old_pos then if self.old_pos then
self.object:setpos(self.old_pos) self.object:set_pos(self.old_pos)
end end
local player = minetest.get_player_by_name(self.driver) local player = minetest.get_player_by_name(self.driver)
carts:manage_attachment(player, nil) carts:manage_attachment(player, nil)
end end
for _,obj_ in ipairs(self.attached_items) do for _, obj_ in ipairs(self.attached_items) do
if obj_ then if obj_ then
obj_:set_detach() obj_:set_detach()
end end
@ -98,14 +117,13 @@ function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities,
local leftover = inv:add_item("main", "carts:cart") local leftover = inv:add_item("main", "carts:cart")
-- If no room in inventory add a replacement cart to the world -- If no room in inventory add a replacement cart to the world
if not leftover:is_empty() then if not leftover:is_empty() then
minetest.add_item(self.object:getpos(), leftover) minetest.add_item(self.object:get_pos(), leftover)
end end
end end
self.object:remove() self.object:remove()
return return
end end
-- Player punches cart to alter velocity -- Player punches cart to alter velocity
local vel = self.object:getvelocity()
if puncher:get_player_name() == self.driver then if puncher:get_player_name() == self.driver then
if math.abs(vel.x + vel.z) > carts.punch_speed_max then if math.abs(vel.x + vel.z) > carts.punch_speed_max then
return return
@ -120,7 +138,8 @@ function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities,
end end
local punch_interval = 1 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 punch_interval = tool_capabilities.full_punch_interval
end end
time_from_last_punch = math.min(time_from_last_punch or punch_interval, punch_interval) 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 self.sound_handle = nil
minetest.after(0.2, minetest.sound_stop, handle) minetest.after(0.2, minetest.sound_stop, handle)
end 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) local speed = vector.length(vel)
if speed > 0 then if speed > 0 then
self.sound_handle = minetest.sound_play( self.sound_handle = minetest.sound_play(
@ -169,32 +191,42 @@ local function get_railparams(pos)
return carts.railparams[node.name] or {} return carts.railparams[node.name] or {}
end end
local v3_len = vector.length
local function rail_on_step(self, dtime) 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 if self.punched then
vel = vector.add(vel, self.velocity) vel = vector.add(vel, self.velocity)
self.object:setvelocity(vel) self.object:set_velocity(vel)
self.old_dir.y = 0 self.old_dir.y = 0
elseif vector.equals(vel, {x=0, y=0, z=0}) then elseif vector.equals(vel, {x=0, y=0, z=0}) then
return return
end 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 = {} local update = {}
-- stop cart if velocity vector flips if self.old_pos and not self.punched and same_dir then
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
local flo_pos = vector.round(pos) local flo_pos = vector.round(pos)
local flo_old = vector.round(self.old_pos) local flo_old = vector.round(self.old_pos)
if vector.equals(flo_pos, flo_old) then if vector.equals(flo_pos, flo_old) then
@ -213,20 +245,29 @@ local function rail_on_step(self, dtime)
end end
end end
if self.old_pos then local stop_wiggle = false
-- Detection for "skipping" nodes if self.old_pos and same_dir then
local found_path = carts:pathfinder( -- Detection for "skipping" nodes (perhaps use average dtime?)
pos, self.old_pos, self.old_dir, ctrl, self.old_switch, self.railtype -- 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 if new_pos then
-- No rail found: reset back to the expected position -- No rail found: set to the expected position
pos = vector.new(self.old_pos) pos = new_pos
update.pos = true update.pos = true
cart_dir = new_dir
end end
elseif self.old_pos and self.old_dir.y ~= 1 and not self.punched then
-- Stop wiggle
stop_wiggle = true
end end
local cart_dir = carts:velocity_to_dir(vel)
local railparams local railparams
-- dir: New moving direction of the cart -- 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( local dir, switch_keys = carts:get_rail_direction(
pos, cart_dir, ctrl, self.old_switch, self.railtype 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} 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} 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.pos = true
update.vel = true update.vel = true
else else
-- Direction change detected -- 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)) vel = vector.multiply(dir, math.abs(vel.x + vel.z))
update.vel = true update.vel = true
if dir.y ~= self.old_dir.y then 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) new_acc = vector.multiply(dir, acc)
end end
-- mesecon detector rail
if HAVE_MESECONS_ENABLED then
carts:signal_detector_rail(vector.round(pos))
end
-- Limits -- Limits
local max_vel = carts.speed_max local max_vel = carts.speed_max
for _, v in pairs({"x","y","z"}) do for _, v in pairs({"x","y","z"}) do
@ -294,9 +349,9 @@ local function rail_on_step(self, dtime)
end end
end end
self.object:setacceleration(new_acc) self.object:set_acceleration(new_acc)
self.old_pos = vector.new(pos) self.old_pos = vector.round(pos)
if not vector.equals(dir, {x=0, y=0, z=0}) then if not vector.equals(dir, {x=0, y=0, z=0}) and not stop_wiggle then
self.old_dir = vector.new(dir) self.old_dir = vector.new(dir)
end end
self.old_switch = switch_keys 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 for _, obj_ in pairs(minetest.get_objects_inside_radius(pos, 1)) do
if not obj_:is_player() and if not obj_:is_player() and
obj_:get_luaentity() 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_:get_luaentity().name == "__builtin:item" then
obj_:set_attach(self.object, "", {x=0, y=0, z=0}, {x=0, y=0, z=0}) 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 elseif self.old_dir.z < 0 then
yaw = 1 yaw = 1
end end
self.object:setyaw(yaw * math.pi) self.object:set_yaw(yaw * math.pi)
local anim = {x=0, y=0} local anim = {x=0, y=0}
if dir.y == -1 then if dir.y == -1 then
@ -342,9 +397,15 @@ local function rail_on_step(self, dtime)
end end
self.object:set_animation(anim, 1, 0) 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 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 end
-- call event handler -- call event handler
@ -359,15 +420,17 @@ end
minetest.register_entity("carts:cart", cart_entity) minetest.register_entity("carts:cart", cart_entity)
minetest.register_craftitem("carts:cart", { minetest.register_craftitem("carts:cart", {
description = "Cart (Sneak+Click to pick up)", description = S("Cart") .. "\n" .. S("(Sneak+Click to pick up)"),
inventory_image = minetest.inventorycube("carts_cart_top.png", "carts_cart_side.png", "carts_cart_side.png"), inventory_image = minetest.inventorycube(
"carts_cart_top.png", "carts_cart_front.png", "carts_cart_side.png"),
wield_image = "carts_cart_side.png", wield_image = "carts_cart_side.png",
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
local under = pointed_thing.under local under = pointed_thing.under
local node = minetest.get_node(under) local node = minetest.get_node(under)
local udef = minetest.registered_nodes[node.name] local udef = minetest.registered_nodes[node.name]
if udef and udef.on_rightclick and 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, return udef.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack pointed_thing) or itemstack
end end
@ -384,10 +447,11 @@ minetest.register_craftitem("carts:cart", {
end end
minetest.sound_play({name = "default_place_node_metal", gain = 0.5}, 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 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() itemstack:take_item()
end end
return itemstack return itemstack

View File

@ -1 +1,4 @@
default default
intllib?
mesecons?
dungeon_loot?

75
mods/carts/detector.lua Normal file
View 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"},
},
})

View File

@ -1,3 +1,5 @@
local is_50 = minetest.get_translator
function carts:get_sign(z) function carts:get_sign(z)
if z == 0 then if z == 0 then
return 0 return 0
@ -12,14 +14,28 @@ function carts:manage_attachment(player, obj)
end end
local status = obj ~= nil local status = obj ~= nil
local player_name = player:get_player_name() local player_name = player:get_player_name()
if default.player_attached[player_name] == status then if obj and player:get_attach() == obj then
return return
end end
default.player_attached[player_name] = status
if is_50 then
player_api.player_attached[player_name] = status
else
default.player_attached[player_name] = status
end
if status then 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: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 else
player:set_detach() player:set_detach()
player:set_eye_offset({x=0, y=0, z=0},{x=0, y=0, z=0}) 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 right.z = -dir.x
end 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 ctrl then
if old_switch == 1 then if old_switch == 1 then
left_check = false left_check = false
@ -106,14 +132,14 @@ function carts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
right_check = false right_check = false
end end
if ctrl.left and left_check then 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 if cur then
return cur, 1 return cur, 1
end end
left_check = false left_check = false
end end
if ctrl.right and right_check then 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 if cur then
return cur, 2 return cur, 2
end end
@ -122,9 +148,11 @@ function carts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
end end
-- Normal -- Normal
cur = carts:check_front_up_down(pos, dir, true, railtype) if not straight_priority then
if cur then cur = self:check_front_up_down(pos, dir, true, railtype)
return cur if cur then
return cur
end
end end
-- Left, if not already checked -- Left, if not already checked
@ -158,27 +186,37 @@ function carts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
return {x=0, y=0, z=0} return {x=0, y=0, z=0}
end end
function carts:pathfinder(pos_, old_pos, old_dir, ctrl, pf_switch, railtype) function carts:pathfinder(pos_, old_pos, old_dir, distance, ctrl,
pf_switch, railtype)
local pos = vector.round(pos_) local pos = vector.round(pos_)
if vector.equals(old_pos, pos) then
return
end
local pf_pos = vector.round(old_pos) local pf_pos = vector.round(old_pos)
local pf_dir = vector.new(old_dir) local pf_dir = vector.new(old_dir)
distance = math.min(carts.path_distance_max,
math.floor(distance + 1))
for i = 1, 3 do for i = 1, distance do
if vector.equals(pf_pos, pos) then pf_dir, pf_switch = self:get_rail_direction(
-- Success! Cart moved on correctly pf_pos, pf_dir, ctrl, pf_switch or 0, railtype)
return true
end
pf_dir, pf_switch = carts:get_rail_direction(pf_pos, pf_dir, ctrl, pf_switch, railtype)
if vector.equals(pf_dir, {x=0, y=0, z=0}) then if vector.equals(pf_dir, {x=0, y=0, z=0}) then
-- No way forwards -- No way forwards
return false return pf_pos, pf_dir
end end
pf_pos = vector.add(pf_pos, pf_dir) pf_pos = vector.add(pf_pos, pf_dir)
if vector.equals(pf_pos, pos) then
-- Success! Cart moved on correctly
return
end
end end
-- Cart not found -- Not found. Put cart to predicted position
return false return pf_pos, pf_dir
end end
function carts:register_rail(name, def_overwrite, railparams) function carts:register_rail(name, def_overwrite, railparams)
@ -211,7 +249,12 @@ end
function carts:get_rail_groups(additional_groups) function carts:get_rail_groups(additional_groups)
-- Get the default rail groups and add more when a table is given -- 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 if type(additional_groups) == "table" then
for k, v in pairs(additional_groups) do for k, v in pairs(additional_groups) do
groups[k] = v groups[k] = v

View File

@ -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 = {}
carts.modpath = minetest.get_modpath("carts") carts.modpath = minetest.get_modpath("carts")
carts.railparams = {} carts.railparams = {}
carts.get_translator = S
-- Maximal speed of the cart in m/s (min = -1) -- Maximal speed of the cart in m/s (min = -1)
carts.speed_max = 7 carts.speed_max = 7
-- Set to -1 to disable punching the cart from inside (min = -1) -- Set to -1 to disable punching the cart from inside (min = -1)
carts.punch_speed_max = 5 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.."/functions.lua")
dofile(carts.modpath.."/rails.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") 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

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