goodbye shadow realm :(
This commit is contained in:
parent
d2484ceb3a
commit
ad57d39c8d
1
init.lua
1
init.lua
@ -2,7 +2,6 @@
|
||||
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
dofile(modpath.."/realm.lua")
|
||||
dofile(modpath.."/items.lua")
|
||||
dofile(modpath.."/mobs.lua")
|
||||
dofile(modpath.."/nodes.lua")
|
||||
|
27
items.lua
27
items.lua
@ -1,30 +1,3 @@
|
||||
-- Shadow Realm Items
|
||||
|
||||
minetest.register_craftitem("shadowrealm:shadow_elixir", {
|
||||
description = "Shadow Elixir",
|
||||
inventory_image = "shadowrealm_shadow_elixir.png",
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack, user)
|
||||
if user and user:is_player() then
|
||||
realm.enter_shadow_realm(user)
|
||||
return "shadowrealm:escape_elixir"
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("shadowrealm:escape_elixir", {
|
||||
description = "Escape Elixir",
|
||||
inventory_image = "shadowrealm_escape_elixir.png",
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack, user)
|
||||
if user and user:is_player() and realm.is_in_shadow_realm(user:get_player_name()) then
|
||||
realm.exit_shadow_realm(user)
|
||||
end
|
||||
return ""
|
||||
end,
|
||||
on_drop = function() return end,
|
||||
})
|
||||
|
||||
-- used to craft Asptooth Sword
|
||||
minetest.register_craftitem("shadowrealm:asp_tooth", {
|
||||
description = "Asp Tooth",
|
||||
|
106
realm.lua
106
realm.lua
@ -1,106 +0,0 @@
|
||||
-- Shadow Realm Mod
|
||||
|
||||
-- Depth allowed before being injured due to dark magic
|
||||
-- prior to defeating the boss
|
||||
local DEPTH_ALLOWED = -200
|
||||
|
||||
local modstorage = minetest.get_mod_storage()
|
||||
|
||||
-- If player has defeated the boss (0 = false, 1 = true)
|
||||
local defeated = modstorage:get_int("defeated") == 1
|
||||
|
||||
realm = {
|
||||
mobs = {}, -- Mobs are spawned when the player enters the realm
|
||||
players = {}, -- Players which are in the realm; list of playernames
|
||||
-- ^ As particlespawners have to be created per-player
|
||||
indices = {}, -- Indices of particlespawners for the shadow effect.
|
||||
-- ^ Key is player name, value is list of particlespawner indices.
|
||||
}
|
||||
|
||||
-- reset
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
players[player:get_player_name()] = nil
|
||||
end)
|
||||
|
||||
-- Returns the particlespawner definition, attached to a provided
|
||||
-- object, for use with minetest.add_particlespawner
|
||||
realm.get_spawner_definition = function(object, playername)
|
||||
return {
|
||||
amount = 10,
|
||||
time = 0,
|
||||
attached = object,
|
||||
playername = playername,
|
||||
texture = "shadowrealm_sparkle.png",
|
||||
minpos = {x=0, y=1, z=0},
|
||||
maxpos = {x=0, y=1, z=0},
|
||||
}
|
||||
end
|
||||
|
||||
realm.enter_shadow_realm = function(player)
|
||||
player:set_properties({
|
||||
visual_size = {x=0,y=0,z=0},
|
||||
})
|
||||
local name = player:get_player_name()
|
||||
realm.indices[name] = {}
|
||||
-- Add particlespawners for all mobs in the shadow realm
|
||||
for _, object in pairs(realm.mobs) do
|
||||
local def = realm.get_spawner_definition(object, name)
|
||||
local index = minetest.add_particlespawner(def)
|
||||
realm.indices[name][#realm.indices[name]] = index
|
||||
end
|
||||
for playername, _ in pairs(realm.players) do
|
||||
local object = minetest.get_player_by_name(playername)
|
||||
if not object then return end
|
||||
local def = realm.get_spawner_definition(object, name)
|
||||
local index = minetest.add_particlespawner(def)
|
||||
realm.indices[name][#realm.indices[name]] = index
|
||||
-- now show this player to the other shadow realm players
|
||||
def = realm.get_spawner_definition(player, playername)
|
||||
index = minetest.add_particlespawner(def)
|
||||
realm.indices[playername][#realm.indices[playername]] = index
|
||||
end
|
||||
realm.players[name] = true -- okay I guess
|
||||
end
|
||||
|
||||
realm.exit_shadow_realm = function(object)
|
||||
if object:is_player() then
|
||||
object:set_properties({
|
||||
visual_size = {x=1,y=1,z=1},
|
||||
})
|
||||
local name = object:get_player_name()
|
||||
realm.players[name] = nil
|
||||
if realm.indices[name] then
|
||||
for _, index in pairs(realm.indices[name]) do
|
||||
minetest.delete_particlespawner(index)
|
||||
end
|
||||
-- We don't need those particlespawner indices now
|
||||
realm.indices[name] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
realm.is_in_shadow_realm = function(playername)
|
||||
return realm.players[playername] ~= nil
|
||||
end
|
||||
|
||||
realm.allow_underground = function()
|
||||
defeated = true
|
||||
modstorage:set_int("defeated", 1)
|
||||
end
|
||||
|
||||
-- Increment variable
|
||||
local underground_timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
if not defeated and dtime then
|
||||
underground_timer = underground_timer + dtime
|
||||
if underground_timer >= 1 then
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
-- If player is too deep
|
||||
if player:get_pos().y < DEPTH_ALLOWED then
|
||||
player:set_hp(player:get_hp()-1)
|
||||
end
|
||||
end
|
||||
underground_timer = 0
|
||||
end
|
||||
end
|
||||
end)
|
Loading…
x
Reference in New Issue
Block a user