Skip to content

Commit

Permalink
Effects System: lord_effect: add mod backbone & register our effect…
Browse files Browse the repository at this point in the history
…s for `speed`,`jump`,`health`. Relates to #1676
  • Loading branch information
alek13 committed Sep 17, 2024
1 parent f6fdf4c commit a47c01b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mods/lord/Game/lord_effects/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


minetest.mod(function(mod)
require("lord_effects").init(mod)
end)
2 changes: 2 additions & 0 deletions mods/lord/Game/lord_effects/mod.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name = lord_effects
depends = builtin, effects, physics, damage
47 changes: 47 additions & 0 deletions mods/lord/Game/lord_effects/src/lord_effects.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@


_G.lord_effects = {
SPEED = 'speed',
JUMP = 'jump',
HEALTH = 'health',
-- BREATH = 'breath', TODO: #1678
}


local function register_effects()
effects.register(
effects.Effect:new(lord_effects.SPEED)
:on_start(function(self, player, amount)
physics.for_player(player):set({ speed = amount })
end)
:on_stop(function(self, player)
physics.for_player(player):set({ speed = 1 })
end)
)
effects.register(
effects.Effect:new(lord_effects.JUMP)
:on_start(function(self, player, amount)
physics.for_player(player):set({ jump = amount })
end)
:on_stop(function(self, player)
physics.for_player(player):set({ jump = 1 })
end)
)
effects.register(
effects.Effect:new(lord_effects.HEALTH)
:on_start(function(self, player, amount, duration)
damage.Periodical:for_player(player):start(damage.Type.FLESHY, amount, duration)
end)
:on_stop(function(self, player)
-- Periodical Damage stops itself.
end)
)
end


return {
--- @param mod minetest.Mod
init = function(mod)
register_effects()
end,
}

0 comments on commit a47c01b

Please sign in to comment.