-
-
Save Andrey2470T/54a1b88ac25540e09f92d01bb766012b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[There is an error on line 6: AsyncError: ServerThread::run Lua: Runtime error from mod 'particlespawner_lib' in callback on_chat_message(): ...pt/minetest/bin/../mods/particlespawner_lib/init.lua:45: attempt to index field '?' (a nil value) | |
2018-09-24 22:39:34: ERROR[Main]: stack traceback: | |
2018-09-24 22:39:34: ERROR[Main]: ...pt/minetest/bin/../mods/particlespawner_lib/init.lua:45: in function 'create_particle_spawner' | |
2018-09-24 22:39:34: ERROR[Main]: ...pt/minetest/bin/../mods/particlespawner_lib/init.lua:298: in function 'func' | |
2018-09-24 22:39:34: ERROR[Main]: ...er/opt/minetest/bin/../builtin/game/chatcommands.lua:30: in function '?' | |
2018-09-24 22:39:34: ERROR[Main]: ...e/user/opt/minetest/bin/../builtin/game/register.lua:419: in function <...e/user/opt/minetest/bin/../builtin/game/register.lua:399>]] | |
particles_spawner = {} | |
function particles_spawner.create_particle_spawner(particlespawners_amount, player, min_and_max_pos_incr, particles_spawners_def, particlespawner_id) | |
if type(particlespawners_amount) == "number" and particlespawners_amount > 0 then | |
math.abs(math.ceil(particlespawners_amount)) | |
local particles_spawner_def = {} | |
local playermeta = player:get_meta() | |
if particles_spawner.is_player_has_the_particlespawner(player, particlespawner_id) then | |
error("Can not add particlespawner with same id!", 1) | |
return | |
else | |
playermeta:set_string("active_particlespawners[" .. particlespawner_id .. "]", minetest.serialize({mode = "active", | |
particles_amount = particlespawners_amount, | |
particles_def = particles_spawners_def, | |
particles_pos_incr = min_and_max_pos_incr, | |
particles_time = {start = 0, end_ = particles_spawner.max_table_value(particles_spawners_def[2])}, | |
standard_particles_list = {}})) | |
local max_table_index = table.maxn(particles_spawners_def) | |
for table_index = 1, max_table_index do | |
particles_spawner_def[table_index] = {} | |
if table_index >=3 and table_index <= 7 then | |
particles_spawner_def[table_index][1] = {} | |
particles_spawner_def[table_index][2] = {} | |
end | |
end | |
for particles_spawner = 1, particlespawners_amount do | |
for particles_spawner_param = 1, max_table_index do | |
if particles_spawner_param >= 3 and particles_spawner_param <= 5 then | |
for min_or_max_param = 1, 2 do | |
particles_spawner_def[particles_spawner_param][min_or_max_param][particles_spawner] = {} | |
for point = 1, 3 do | |
minetest.debug(particles_spawners_def[particles_spawner_param][min_or_max_param][particles_spawner][point]) | |
particles_spawner_def[particles_spawner_param][min_or_max_param][particles_spawner][point] = particles_spawners_def[particles_spawner_param][min_or_max_param][particles_spawner][point] | |
end | |
end | |
elseif particles_spawner_param < 3 or particles_spawner_param > 7 then | |
particles_spawner_def[particles_spawner_param][particles_spawner] = particles_spawners_def[particles_spawner_param][particles_spawner] | |
if particles_spawner_param == 2 then | |
time = particles_spawner_def[particles_spawner_param][particles_spawner] | |
end | |
elseif particles_spawner_param == 5 or particles_spawner_param == 6 then | |
for min_or_maxparam = 1, 2 do | |
particles_spawner_def[particles_spawner_param][min_or_maxparam][particles_spawner] = particles_spawners_def[particles_spawner_param][min_or_maxparam][particles_spawner] | |
end | |
end | |
end | |
local meta = minetest.deserialize(playermeta:get_string("active_particlespawners["..particlespawner_id.."]")) | |
meta.standard_particles_list.particlespawner_id = minetest.add_particlespawner({ | |
amount = particles_spawner_def[1][particles_spawner], | |
time = particles_spawner_def[2][particles_spawner], | |
minpos = {x = particles_spawner_def[3][1][particles_spawner][1], y = particles_spawner_def[3][1][particles_spawner][2], z = particles_spawner_def[3][1][particles_spawner][3]}, | |
maxpos = {x = particles_spawner_def[3][2][particles_spawner][1], y = particles_spawner_def[3][2][particles_spawner][2], z = particles_spawner_def[3][2][particles_spawner][3]}, | |
minvel = {x = particles_spawner_def[4][1][particles_spawner][1], y = particles_spawner_def[4][1][particles_spawner][2], z = particles_spawner_def[4][1][particles_spawner][3]}, | |
maxvel = {x = particles_spawner_def[4][2][particles_spawner][1], y = particles_spawner_def[4][2][particles_spawner][2], z = particles_spawner_def[4][2][particles_spawner][3]}, | |
minacc = {x = particles_spawner_def[5][1][particles_spawner][1], y = particles_spawner_def[5][1][particles_spawner][2], z = particles_spawner_def[5][1][particles_spawner][3]}, | |
maxacc = {x = particles_spawner_def[5][2][particles_spawner][1], y = particles_spawner_def[5][2][particles_spawner][2], z = particles_spawner_def[5][2][particles_spawner][3]}, | |
minexptime = particles_spawner_def[6][1][particles_spawner], | |
maxexptime = particles_spawner_def[6][2][particles_spawner], | |
minsize = particles_spawner_def[7][1][particles_spawner], | |
maxsize = particles_spawner_def[7][2][particles_spawner], | |
collisiondetection = particles_spawner_def[8][particles_spawner], | |
vertical = particles_spawner_def[9][particles_spawner], | |
texture = particles_spawner_def[10][particles_spawner], | |
playername = particles_spawner_def[11][particles_spawner] | |
}) | |
playermeta:set_string("active_particlespawners["..particlespawner_id.."]", minetest.serialize(meta)) | |
end | |
--[[local particlespawner_def = playermeta:get_string("active_particlespawners["..particlespawner_id.."]") | |
particlespawner_def.particles_time.start = | |
playermeta:set_string("active_particlespawners["..particlespawner_id.."][time]", minetest.serialize({start = 0, end_ = particles_spawners_def[2][1]}))]] | |
local timer = 0 | |
minetest.register_globalstep(function (dtime) | |
local particlespawner_mode = minetest.deserialize(player:get_meta():get_string("active_particlespawners["..particlespawner_id.."]")).mode | |
if player:get_hp() > 0 and player:is_player_connected(player:get_player_name()) and particlespawner_mode == "active" then | |
local particlespawner_def = minetest.deserialize(playermeta:get_string("active_particlespawners["..particlespawner_id.."]")) | |
particlespawner_def.particles_time.start = particlespawner_def.particles_time.start + dtime | |
timer = timer + dtime | |
local get_min_exptime_table = minetest.deserialize(playermeta:get_string("active_particlespawners["..particlespawner_id.."]")).particles_def[6][1] | |
if math.floor(timer) == particles_spawner.min_table_value(get_min_exptime_table) then | |
minetest.debug(particles_spawner.min_table_value(get_min_exptime_table)) | |
timer = 0 | |
local get_playermeta = minetest.deserialize(playermeta:get_string("active_particlespawners["..particlespawner_id.."]")) | |
local get_pos_table = get_playermeta.particles_def[3] | |
local get_particles_pos_incr_table = minetest.deserialize(playermeta:get_string("active_particlespawners["..particlespawner_id.."]")).particles_pos_incr | |
for ind1, pos1 in pairs(get_pos_table) do | |
for ind2, pos2 in pairs(pos1) do | |
get_pos_table[ind1][ind2] = {player:get_pos().x + get_particles_pos_incr_table[ind1][ind2][1], | |
player:get_pos().y + get_particles_pos_incr_table[ind1][ind2][2], | |
player:get_pos().z + get_particles_pos_incr_table[ind1][ind2][3] | |
} | |
end | |
end | |
playermeta:set_string("active_particlespawners["..particlespawner_id.."]", minetest.serialize(get_playermeta)) | |
end | |
--[[for particlespawner_index, particlespawner_time in ipairs(particlespawner_def.particles_def[2]) do | |
particles_spawners_def[2][particlespawner_index] = particles_spawners_def[2][particlespawner_index] - dtime | |
playermeta:set_string("active_particlespawners["..particlespawner_id.."]", particlespawner_def) | |
end | |
playermeta:set_string("active_particlespawners["..particlespawner_id.."]", minetest.serialize(particlespawner_def))]] | |
--^^ playermeta:get_string("active_particlespawners["..particlespawner_id.."][time][start]") gets a nil value!!! | |
elseif player:get_hp() <= 0 then | |
particles_spawner.remove_particle_spawner(player, particlespawner_id) | |
end | |
end) | |
minetest.after(particles_spawner.max_table_value(particles_spawners_def[2]), function (playermeta) | |
particles_spawner.remove_particle_spawner(player, particlespawner_id) | |
end, playermeta) | |
end | |
else | |
return | |
end | |
end | |
minetest.register_chatcommand("particlespawner", { | |
params = "", | |
description = "Adds particlespawner", | |
func = function (name, param) | |
local player = minetest.get_player_by_name(name) | |
particles_spawner.create_particle_spawner(7, player, | |
{{{0.2, 1.5, 0.2}, | |
{-0.2, 1.5, -0.2}, | |
{-0.2, 1.5, 0.2}, | |
{0.2, 1.5, -0.2} | |
}, | |
{{0.5, 1.5, 0.5}, | |
{-0.5, 1.5, -0.5}, | |
{-0.5, 1.5, 0.5}, | |
{0.5, 1.5, -0.5} | |
} | |
}, | |
{ | |
{5, 5, 5, 5}, | |
{7, 7, 7, 7}, | |
{{{player:get_pos().x + 0.2, player:get_pos().y + 1.5, player:get_pos().z + 0.2}, | |
{player:get_pos().x + 0.2, player:get_pos().y + 1.5, player:get_pos().z - 0.2}, | |
{player:get_pos().x - 0.2, player:get_pos().y + 1.5, player:get_pos().z + 0.2}, | |
{player:get_pos().x + 0.2, player:get_pos().y + 1.5, player:get_pos().z - 0.2} | |
}, | |
{{player:get_pos().x + 0.5, player:get_pos().y + 1.5, player:get_pos().z + 0.5}, | |
{player:get_pos().x - 0.5, player:get_pos().y + 1.5, player:get_pos().z - 0.5}, | |
{player:get_pos().x - 0.5, player:get_pos().y + 1.5, player:get_pos().z + 0.5}, | |
{player:get_pos().x + 0.5, player:get_pos().y + 1.5, player:get_pos().z - 0.5} | |
} | |
}, | |
{{{0, 0.2, 0}, | |
{0, 0.2, 0}, | |
{0, 0.2, 0}, | |
{0, 0.2, 0} | |
}, | |
{{0, 0.4, 0}, | |
{0, 0.4, 0}, | |
{0, 0.4, 0}, | |
{0, 0.4, 0} | |
} | |
}, | |
{{{0, 0.2, 0}, | |
{0, 0.2, 0}, | |
{0, 0.2, 0}, | |
{0, 0.2, 0} | |
}, | |
{{0, 0.4, 0}, | |
{0, 0.4, 0}, | |
{0, 0.4, 0}, | |
{0, 0.4, 0} | |
} | |
}, | |
{{4, 4, 4, 4}, | |
{4, 4, 4, 4} | |
}, | |
{{10, 10, 10, 10}, | |
{12, 12, 12, 12} | |
}, | |
{true, true, true, true}, | |
{true, true, true, true}, | |
{"healing_effect.png", "healing_effect.png", "healing_effect.png", "healing_effect.png"}, | |
{player:get_player_name(), player:get_player_name(), player:get_player_name(), player:get_player_name()} | |
}, "particlespawner") | |
end | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment