Add color swappers, color swapping, and color targets.

This commit is contained in:
Signal 2025-11-19 11:43:24 -05:00
parent 9acd605c86
commit 5fd67703c0
34 changed files with 688 additions and 29 deletions

View file

@ -41,7 +41,7 @@ function ns.apply_vix(m)
end
end
function ns.swap_character(m)
function ns._swap_character(m)
if m.character == "vix" then
artifact.sidekick.character = "vix"
m:set_character("key")
@ -103,6 +103,45 @@ function ns.swap_character(m)
artifact.sidekick.save()
end
function ns.swap_character(m)
if m._swapping_character then return end
if artifact.sidekick.ref then
artifact.sidekick.ref._no_interact = true
end
m._swapping_character = true
local fade = artifact.hud_add(m, {
type = "image",
pos = {x=0.5,y=1},
offset = {x=0,y=0},
align = {x=0,y=0},
scale = {x=50000,y=50000},
opacity = 0,
image = "[fill:1x1:0,0:#000",
})
fade:animate {
opacity = {
value = 256,
duration = 0.3
}
}
minetest.after(0.3, function()
ns._swap_character(m)
fade:animate {
opacity = {
value = 0,
duration = 0.3
}
}
minetest.after(0.3, function()
m._swapping_character = nil
if artifact.sidekick.ref then
artifact.sidekick.ref._no_interact = nil
end
end)
end)
end
include "key.lua"

View file

@ -6,7 +6,7 @@ minetest.register_entity(":artifact:burst", {
textures = {"blank.png"},
pointable = false,
physical = true,
-- collide_with_objects = false,
collide_with_objects = false,
collisionbox = {
-0.2, -0.2, -0.2,
0.2, 0.2, 0.2
@ -22,7 +22,20 @@ minetest.register_entity(":artifact:burst", {
end
end,
on_step = function(e, dtime, movement)
if movement.collides then
-- Minetest's collision is rather bad, but we also shouldn't collide with players,
-- hence we must implement our own rudimentary collision detection.
-- In this case, any intersection on the segment betwee our last position and our
-- current one should be considered a collision and result in detonation (and
-- at the exact intersection point, if available).
local collision
for x in minetest.raycast(e.old_pos or e.object:get_pos(), e.object:get_pos(), true, true, {nodes = {}, objects = {playser = false}}) do
collision = x
break
end
if collision or movement.collides then
if collision then
e.object:set_pos(collision.intersection_point)
end
minetest.add_particlespawner {
pos = e.object:get_pos(),
radius = 0.1,
@ -49,14 +62,16 @@ minetest.register_entity(":artifact:burst", {
time = 0.1,
}
e.object:remove()
if movement.collisions[1].type == "node" then
if movement and movement.collisions[1] and movement.collisions[1].type == "node" then
local pos = movement.collisions[1].node_pos
local name = minetest.get_node(pos).name
if minetest.registered_nodes[name].on_impact then
minetest.registered_nodes[name].on_impact(pos)
end
end
return
end
e.old_pos = e.object:get_pos()
end,
impulse = function(e, vel)
-- The documentation said that `vel` is relative to the parent entity...
@ -90,7 +105,7 @@ minetest.register_entity(":artifact:burst", {
pos = vector.zero(),
vel = vel,
texture = "[fill:16x16:0,0:#fff",
size = 3,
size_tween = {3, 0},
glow = 14,
amount = 150,
time = 0,