Commit graph

43 commits

Author SHA1 Message Date
trans_soup
3316dcba15 improve blockgame.attempt_place utility.
it now takes an optional argument that specifies what nodes may be
replaced (besides air).
2023-10-19 15:27:38 +02:00
trans_soup
6bb71aa341 add opt-in falling_node collision for non-walkable nodes.
make falling_node entities land on nodes with `supports_falling = true`
in their definitions.
2023-10-19 14:07:47 +02:00
trans_soup
8d94fb9c70 minor rename.
look for `after_land` instead of `after_landing` in node defs when
handling falling nodes landing.
2023-10-19 12:46:38 +02:00
trans_soup
96ebbe8e0e improve fall_fix.
make the position passed to callbacks be the position where the
falling_node entity landed, rather than the position it tries to land
on/in.

note that if the node it lands on has its `paramtype2` set to
`"leveled"` then this new position might be empty after a landing.
2023-10-19 11:25:12 +02:00
trans_soup
a09dc62101 add hook for falling_node stepping.
and use this to keep track of their falling velocity.
2023-10-19 11:21:27 +02:00
trans_soup
becfb37402 provide more data to landing node callbacks.
specifically, give them the falling_node entity that landed as third
argument.
2023-10-19 11:19:32 +02:00
trans_soup
e1103a07e4 create fall_fix.
modify the builtin `falling_node` entity to make it possible for mods to
register callbacks to be called when they land and turn into a node.

also register such a callback that checks if the landed node has an
entry `after_landing`, and if so calls that.
2023-10-18 23:30:00 +02:00
trans_soup
07781855ad make loose node settling use an increasing ABM.
loose nodes will now take some time to settle, instead of doing so
completely randomly.
2023-10-17 21:03:34 +02:00
trans_soup
5df44d2b24 rework loose node registration.
loose nodes are now automatically registrered when their settled
counterparts are. also rewrite a small amount of wrapper code and node
registration to work with this.
2023-10-17 20:52:06 +02:00
trans_soup
968ae04b3a make blockgame.register_node wrapper emit events.
the api function `blockgame.register_node` will now emit events before
and after registering a node, allowing for other code to react to and
affect node registration.
2023-10-17 20:39:13 +02:00
trans_soup
09bcf2260b integrate bg_api_event into bg_api. 2023-10-17 20:38:43 +02:00
trans_soup
75e66075d0 simplify node registration.
make the wrapper `blockgame.register_node` make reasonable assumptions
that make node registration more convenient.

change other code to take advantage of that change.

also remove the `blockgame.reg_simple_node` utility since it's now
redundant.
2023-10-17 20:20:42 +02:00
trans_soup
47e7e4fb0b remove bg_api_fall again.
as it turns out that minetest already handles falling nodes.
2023-10-17 19:19:35 +02:00
trans_soup
0c9f6a7119 move falling node code to own mod.
create `bg_api_fall` mod, and move files `falling_node.lua` and `loose_node.lua` to there from `bg_api`.

update dependencies in other mods to account for this change.
2023-10-17 18:54:23 +02:00
trans_soup
3459e94de8 improve flood_fill api function.
make `flood_fill` able to be interrupted if its callback returns false;
the meaning that was previously indicated by this return value is now
indicated by nil instead.

update code that uses this function to account for this change.
2023-10-17 15:48:57 +02:00
trans_soup
aae1beea64 refactor grass spreading and related api function. 2023-10-17 15:40:49 +02:00
trans_soup
d197e1f1e3 move item_matches into api.
move function `item_matches` from `bg_crafting` into `bg_api`, since
it'll be useful in many other places.
2023-10-17 15:02:39 +02:00
trans_soup
7df5d33d02 refactor: extract repeated code into api function.
move function `starts_with`, which was declared twice in separate files,
to the api, and make those files use that function instead.
2023-10-17 14:58:15 +02:00
trans_soup
cca53e76b3 add flood fill utility to api.
add api function for walking through the nodes surrounding a given
position.
2023-10-17 13:40:04 +02:00
trans_soup
5a3d81787c add several utility functions related to tables.
create api functions `any`, `every`, and `underride`.

`any` and `every` checks if a condition is true for any and every item
in a table, respectively.
`underride` returns a table that defaults to a provided table, for
items that aren't specified in the other provided table.
2023-10-17 11:19:55 +02:00
trans_soup
33fbd7c35e move get_neighbors from util_node to util_vector. 2023-10-17 11:19:03 +02:00
trans_soup
d753612f0b separate falling node and loose node handling. 2023-10-17 11:18:14 +02:00
trans_soup
5879ecbd67 add get_sides_of utility to api. 2023-10-17 10:16:12 +02:00
trans_soup
9a3afd6d5a add support for group air_flowable.
replace the placeholder api functionality for checking whether air flows
through a node, with something that relies on a dedicated group (instead
of a hard-coded list in the api code).
2023-10-16 21:40:57 +02:00
trans_soup
453add021d implement increasing ABM:s.
create public api function that registers "increasing ABM:s"; these
abstract over using numerical values associated with individual nodes in
ABM:s, allowing for straightforward creation of processes that occur
over time.
2023-10-16 21:27:59 +02:00
trans_soup
6478e66ef7 add get_neighbors function to api. 2023-10-16 19:17:52 +02:00
trans_soup
263e98d526 add basic api support for loose nodes.
expose an api function to register "loose" versions of existing nodes,
and implement some behaviour for such nodes; they will fall down if
there is air below them, and will eventually become their non-loose
counterparts if there is not air below them.
2023-10-16 10:46:32 +02:00
trans_soup
20b29c833f complete cleanup after rename.
clean up things that were broken after renaming `bg_core` to
`bg_terrain`.

also clean up after global rename that added `bg_` prefix to every mod
name.
2023-10-16 10:14:34 +02:00
trans_soup
7755583fa4 rename mods and add hacky cleanup thing.
rename mods; add `bg_` prefix.

add hacky cleanup ABM (couldn't get LBM:s to work), that converts old
nodes into new ones according to this rename.

the cleanup doesn't do anything for items, though.
2023-10-15 18:22:13 +02:00
trans_soup
7f3535ca27 make util_stringify more robust. 2023-10-15 17:46:08 +02:00
trans_soup
d1a8ad952b fix random tick crash possibility. 2023-10-15 17:38:11 +02:00
trans_soup
24ec93cd50 fix name fields in mod.conf files. 2023-10-15 17:23:37 +02:00
trans_soup
9585a7a4b3 add random ticks.
every server step, mapblocks near online players will have randomly
selected nodes within them receive a "random tick", the behaviour of
which is determined in node definitions.
2023-10-13 13:22:56 +02:00
trans_soup
6040e73f6c add debug utility to api. 2023-10-13 13:17:47 +02:00
trans_soup
a2ab91c992 fix math.random usage.
fix usage of `math.random` in various places to provide both a minimum
and a maximum number, instead of just maximum.

also renamed some files very slightly.
2023-10-13 13:17:14 +02:00
trans_soup
2e32ca82ba add register_lbm wrapper. 2023-10-13 09:55:09 +02:00
trans_soup
568e8059f9 refactor: more wrappers
create more wrappers for built-in functions and use them instead.
2023-10-13 09:31:55 +02:00
trans_soup
ccd059aa29 generalize creating wrappers for built-ins.
create utility for creating wrapper functions for `minetest` methods.
2023-10-13 09:19:13 +02:00
trans_soup
91807870fe miscellaneous refactors & fixes.
move several functions into the api.

fix root growth directions.

clean up root and grass growth code.
2023-10-12 11:09:40 +02:00
trans_soup
7b86727e4b create grass mod.
create a new mod that implements basic grass growth and death.
2023-10-12 08:26:37 +02:00
trans_soup
850d397a97 refactor: minor code style change.
change the way some functions are declared.
2023-10-11 19:12:47 +02:00
trans_soup
6fb3f5fde3 refactor and fix errors.
move vector utilities out of tree api into own generic api. fix related
issues.
2023-10-11 10:01:54 +02:00
trans_soup
a973bbdbf8 initial commit.
created a few proof-of-concept mechanics. took some textures from
minetest game. implemented basic tree growth and stacking in-world
crafting.
2023-10-11 09:17:21 +02:00