2019-12-30 07:19:46 -08:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
|
|
|
local math, minetest
|
|
|
|
= math, minetest
|
|
|
|
local math_random
|
|
|
|
= math.random
|
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
local modname = minetest.get_current_modname()
|
|
|
|
|
|
|
|
local blackdot = "[combine:1x1^[noalpha"
|
|
|
|
local bdesc = blackdot:gsub("%^", "\\^"):gsub(":", "\\:")
|
|
|
|
local frame = "[combine:16x16:0,0=" .. bdesc .. ":15,0=" .. bdesc
|
|
|
|
.. ":0,15=" .. bdesc .. ":15,15=" .. bdesc
|
|
|
|
|
2019-12-30 07:59:13 -08:00
|
|
|
local function regdemo(num, desc, func)
|
2019-12-30 07:19:46 -08:00
|
|
|
return minetest.register_node(modname .. ":demo" .. num, {
|
2019-12-30 07:59:13 -08:00
|
|
|
description = desc,
|
2019-12-30 07:19:46 -08:00
|
|
|
drawtype = "allfaces",
|
|
|
|
tiles = {{name = frame, backface_culling = false}},
|
|
|
|
groups = {[modname] = 1},
|
2019-12-30 07:33:54 -08:00
|
|
|
paramtype = "light",
|
|
|
|
sunlight_propagates = true,
|
2019-12-30 07:59:13 -08:00
|
|
|
on_construct = function(pos)
|
|
|
|
return minetest.get_meta(pos):set_string("infotext", desc)
|
|
|
|
end,
|
2019-12-30 07:19:46 -08:00
|
|
|
on_punch = function(pos) return minetest.remove_node(pos) end,
|
|
|
|
on_demo = func
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"group:" .. modname},
|
|
|
|
interval = 2,
|
|
|
|
chance = 1,
|
|
|
|
action = function(pos, node)
|
|
|
|
local def = minetest.registered_nodes[node.name]
|
|
|
|
if def and def.on_demo then return def.on_demo(pos, node) end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2019-12-30 07:59:13 -08:00
|
|
|
regdemo(1, "ASMD ShockRifle Effect", function(pos)
|
2019-12-30 07:19:46 -08:00
|
|
|
local endpos = {
|
|
|
|
x = pos.x + math_random() * 20 - 10,
|
|
|
|
y = pos.y + math_random() * 20 - 10,
|
|
|
|
z = pos.z + math_random() * 20 - 10,
|
|
|
|
}
|
|
|
|
minetest.add_particlespawner_advanced({
|
|
|
|
amount = 25,
|
|
|
|
time = 0.25,
|
|
|
|
pos = {
|
|
|
|
x = {pos.x, endpos.x - pos.x},
|
|
|
|
y = {pos.y, endpos.y - pos.y},
|
|
|
|
z = {pos.z, endpos.z - pos.z}
|
|
|
|
},
|
|
|
|
velocity = {
|
|
|
|
x = {(endpos.x - pos.x) / 2, -(endpos.x - pos.x) / 2},
|
|
|
|
y = {(endpos.y - pos.y) / 2, -(endpos.y - pos.y) / 2},
|
|
|
|
z = {(endpos.z - pos.z) / 2, -(endpos.z - pos.z) / 2}
|
|
|
|
},
|
|
|
|
expirationtime = {2, -0.25},
|
|
|
|
texture = blackdot,
|
|
|
|
size = {1, 4}
|
|
|
|
})
|
|
|
|
end)
|
|
|
|
|
2019-12-30 07:59:13 -08:00
|
|
|
regdemo(2, "Implosion / Teleport Arrive", function(pos)
|
2019-12-30 07:19:46 -08:00
|
|
|
minetest.add_particlespawner_advanced({
|
2019-12-30 07:59:13 -08:00
|
|
|
amount = 100,
|
2019-12-30 07:19:46 -08:00
|
|
|
time = 0,
|
|
|
|
pos = {
|
|
|
|
x = {pos.x, -10, 20},
|
|
|
|
y = {pos.y, -10, 0, 20},
|
|
|
|
z = {pos.z, -10, 0, 0, 20}
|
|
|
|
},
|
|
|
|
velocity = {
|
|
|
|
x = {0, 20, -40},
|
|
|
|
y = {0, 20, 0, -40},
|
|
|
|
z = {0, 20, 0, 0, -40}
|
|
|
|
},
|
|
|
|
acceleration = {
|
|
|
|
x = {0, -20, 40},
|
|
|
|
y = {0, -20, 0, 40},
|
|
|
|
z = {0, -20, 0, 0, 40}
|
|
|
|
},
|
|
|
|
expirationtime = {1},
|
|
|
|
texture = blackdot,
|
|
|
|
size = {1, 0, 0, 0, 0, 4}
|
|
|
|
})
|
|
|
|
end)
|
2019-12-30 07:33:54 -08:00
|
|
|
|
2019-12-30 07:59:13 -08:00
|
|
|
regdemo(3, "Tornado", function(pos)
|
2019-12-30 07:33:54 -08:00
|
|
|
minetest.add_particlespawner_advanced({
|
|
|
|
amount = 200,
|
2019-12-30 07:59:13 -08:00
|
|
|
time = 2,
|
2019-12-30 07:33:54 -08:00
|
|
|
pos = {
|
2019-12-30 07:59:13 -08:00
|
|
|
x = {pos.x - 10, 0, 20},
|
|
|
|
y = {pos.y, 0, 0, 10},
|
|
|
|
z = {pos.z - 10, 0, 0, 0, 20}
|
2019-12-30 07:33:54 -08:00
|
|
|
},
|
|
|
|
velocity = {
|
2019-12-30 07:59:13 -08:00
|
|
|
x = {-5, 0, 0, 0, 10},
|
|
|
|
y = {0, 0, 0, 10},
|
|
|
|
z = {5, 0, -10}
|
2019-12-30 07:33:54 -08:00
|
|
|
},
|
2019-12-30 07:59:13 -08:00
|
|
|
acceleration = {
|
|
|
|
x = {2.5, 0, -5},
|
|
|
|
y = {5},
|
|
|
|
z = {2.5, 0, 0, 0, -5}
|
|
|
|
},
|
|
|
|
expirationtime = {2},
|
2019-12-30 07:33:54 -08:00
|
|
|
texture = blackdot,
|
|
|
|
size = {1, 0, 0, 0, 0, 4}
|
|
|
|
})
|
|
|
|
end)
|