1
0
mirror of https://github.com/pandorabox-io/banners.git synced 2025-06-30 23:30:41 +02:00

1 Commits

Author SHA1 Message Date
ea0a0fe6c4 On move support aka jumpdrive compat (#9)
* whitespace and minetest. -> core.

- use same whitespace style throughout and fix some indents.
- change from minetest. to core. namespace.

* Update Readme: Minetest -> Luanti

* add luacheck

* update optional depends

* luacheck cleanups

- unused arguments
- shaddowed vars
- var redeclarations
- some whitespace involved in above lines

* clean close of file after reading

* avoid duplicate code

save some lines and some extra method calls.

* avoid error: "unknown global"

* stray whitespace fixups

* whitespace: switch all files to same indent character

tabs -> spaces

* refactor weird declaration

* whitespace: two stray spaces

...that slipped through the cracks on previous whitespace edit

* fix shaddowing global table

* reduce amount of times transformation string is calculated

* use ipairs feature

or use the faster repeat-until-loop

* cap max amount of layers

fixes #5

* fix #5 make transform history non-global

fixes #5
transformation history was shared by all users and kept growing as it
was never truely reset. Every time a user
used a banner a white background was dumped on top of the
stack making it possible to crash the server through an
overflow to core.serialize() function.

* minimize metadata size

also changed banners.max_transformations to
banners.max_undo_levels and lowered the value substantially.

* add versioning

* add recoverable per player history with saved colour

* rename update_all -> update_preview_inv

since it isn't updating everything, only
the preview and the inventory item

* dynamically update masks

to reflect the currently selected colour.

* banner always exists

even if only "" it exists and there isn't an error.
not adding "" or texture string, causes a non critical error.

* use same function declaration style throughout

* remove set_banner_texture()

only used once and is easy enough to have inline

* preserve player undo-history over joins

player could have timed-out and thus lost their history.
It isn't crucial to remove their history, so let's give
them this feature.

* refactor: reusable transformation string creation

unfortunately the git diff is a bit messy on this one.
Nothing changed with:
- banners.Banner
- banners.Banner:new
- banners.Banner:push_transform
- banners.Banner:pop_transform

content of banners.Banner:get_transform_string was moved
to banners.transform_table_to_string with very few changes

* add transform_string_to_table

allows us to add more features such as:
- clean existing banners to slim down data
- read transforms from items in inventory -> allow players
  to change existing patterns without having to start from
  scratch.

* cleanup old banners when their entities are generated

* read item meta allowing players to edit existing banners

* version bump

* oopsie fixes

* remove stray debug point

* add chatcommand banners_fix

fixes #7
provides a work-around for the engine problem with entities.

* sensitive github luacheck syntax

* version bump

* cleanup: compact node definitions

* adds [jumpdrive] compat

github.com/mt-mods/jumpdrive

closes https://github.com/mt-mods/jumpdrive/issues/90

* also make factions banners jump-able

just for completeness sake
2024-12-09 12:19:40 +01:00
3 changed files with 23 additions and 38 deletions

View File

@ -143,12 +143,8 @@ core.register_node("banners:power_banner", {
stack_max = 1, stack_max = 1,
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
after_place_node = function (pos, player, itemstack, pointed_thing) after_place_node = banners.after_powerbanner_placed,
banners.after_powerbanner_placed(pos, player, itemstack, pointed_thing) on_destruct = banners.banner_on_destruct,
end,
on_destruct = function(pos)
banners.banner_on_destruct(pos)
end,
on_dig = function(pos, n, p) on_dig = function(pos, n, p)
if core.is_protected(pos, p:get_player_name()) then if core.is_protected(pos, p:get_player_name()) then
return return
@ -163,6 +159,7 @@ core.register_node("banners:power_banner", {
end end
banners.banner_on_dig(pos, n, p) banners.banner_on_dig(pos, n, p)
end, end,
on_movenode = banners.banner_on_movenode,
}) })
core.register_node("banners:death_banner", { core.register_node("banners:death_banner", {
@ -176,12 +173,8 @@ core.register_node("banners:death_banner", {
stack_max = 1, stack_max = 1,
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
after_place_node = function (pos, player, itemstack, pointed_thing) after_place_node = banners.after_deathbanner_placed,
banners.after_deathbanner_placed(pos, player, itemstack, pointed_thing) on_destruct = banners.banner_on_destruct,
end,
on_destruct = function(pos)
banners.banner_on_destruct(pos)
end,
-- (pos, node, player) -- (pos, node, player)
on_dig = function(pos, _, player) on_dig = function(pos, _, player)
if core.is_protected(pos, player:get_player_name()) then if core.is_protected(pos, player:get_player_name()) then
@ -198,6 +191,7 @@ core.register_node("banners:death_banner", {
end end
core.remove_node(pos) core.remove_node(pos)
end, end,
on_movenode = banners.banner_on_movenode,
}) })
-- (pos, player, itemstack, pointed_thing) -- (pos, player, itemstack, pointed_thing)

View File

@ -2,7 +2,7 @@ local MP = core.get_modpath("banners") .. "/"
dofile(MP .. "smartfs.lua") dofile(MP .. "smartfs.lua")
banners = { banners = {
version = 20241129.1232 version = 20241130.1920
} }
banners.masks = { banners.masks = {
@ -305,6 +305,12 @@ function banners.banner_after_place(pos, _, itemstack, pointed_thing)
core.add_entity(pos, "banners:banner_ent") core.add_entity(pos, "banners:banner_ent")
end end
-- [jumpdrive] compat
-- (from_pos, to_pos, additional_info)
function banners.banner_on_movenode(_, to_pos)
core.add_entity(to_pos, "banners:banner_ent")
end
-- banner entity -- banner entity
function banners:banner_on_activate() function banners:banner_on_activate()

View File

@ -10,18 +10,11 @@ core.register_node("banners:wooden_banner", {
stack_max = 1, stack_max = 1,
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
after_place_node = function (pos, player, itemstack, pointed_thing) after_place_node = banners.banner_after_place,
banners.banner_after_place(pos, player, itemstack, pointed_thing) on_destruct = banners.banner_on_destruct,
end, on_use = banners.banner_on_use,
on_destruct = function(pos) on_dig = banners.banner_on_dig,
banners.banner_on_destruct(pos) on_movenode = banners.banner_on_movenode,
end,
on_use = function(i, p, pt)
banners.banner_on_use(i, p, pt)
end,
on_dig = function(pos, n, p)
banners.banner_on_dig(pos, n, p)
end
}) })
-- steel banner -- steel banner
@ -36,18 +29,10 @@ core.register_node("banners:steel_banner", {
stack_max = 1, stack_max = 1,
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
after_place_node = function (pos, player, itemstack, pointed_thing) after_place_node = banners.banner_after_place,
banners.banner_after_place(pos, player, itemstack, pointed_thing) on_destruct = banners.banner_on_destruct,
end, on_use = banners.banner_on_use,
on_destruct = function(pos) on_dig = banners.banner_on_dig,
banners.banner_on_destruct(pos) on_movenode = banners.banner_on_movenode,
end,
on_use = function(i, p, pt)
banners.banner_on_use(i, p, pt)
end,
on_dig = function(pos, n, p)
banners.banner_on_dig(pos, n, p)
end
}) })