namespace settings, alternative rainbow staff

This commit is contained in:
Tai Kedzierski 2018-12-23 01:55:33 +00:00
parent 0fa121024c
commit 2c5d2ebee6
3 changed files with 76 additions and 47 deletions

View File

@ -1,8 +1,9 @@
local path = minetest.get_modpath("nssm") local path = minetest.get_modpath("nssm")
nssm = {} nssm = {}
nssm.mymapgenis = tonumber(minetest.setting_get('mymapgenis')) or 7 nssm.mymapgenis = tonumber(minetest.settings:get('nssm.mymapgenis')) or 7
nssm.multimobs = tonumber(minetest.setting_get('multimobs')) or 1000 nssm.multimobs = tonumber(minetest.settings:get('nssm.multimobs')) or 1000
nssm.init_rainbow_staff = minetest.settings:get_bool('nssm.classic_rainbow_staff')
dofile(path.."/spawn.lua") dofile(path.."/spawn.lua")

View File

@ -1,46 +1,72 @@
--rainbow! -- The Rainbow Staff is a reward for defeating the final boss
minetest.register_entity("nssm:rainbow", { -- Classic implementation produces ranbow blocks in any direction it is pointed at and used
textures = {"transparent.png"}, -- This tends to be problematic on servers, so is replaced with a powerful tool instead
velocity = 10, -- if classic rainbow staff is not enabled
hp_max = 50,
on_step = function (self, pos, node, dtime)
self.timer = self.timer or os.time()
local pos = self.object:getpos() if nssm.classic_rainbow_staff then
if minetest.is_protected(pos, "") then minetest.register_entity("nssm:rainbow", {
return textures = {"transparent.png"},
end velocity = 10,
hp_max = 50,
on_step = function (self, pos, node, dtime)
self.timer = self.timer or os.time()
if os.time() - self.timer > 10 then local pos = self.object:getpos()
minetest.set_node(pos, {name="nyancat:nyancat"}) if minetest.is_protected(pos, "") then
self.object:remove() return
end end
if minetest.get_node(pos) then if os.time() - self.timer > 10 then
local n = minetest.get_node(pos).name minetest.set_node(pos, {name="nyancat:nyancat"})
if n ~= "nyancat:nyancat_rainbow" then self.object:remove()
if n=="air" then end
minetest.set_node(pos, {name="nyancat:nyancat_rainbow"})
else
minetest.chat_send_all("Nome:"..n)
minetest.set_node(pos, {name="nyancat:nyancat"})
self.object:remove()
end
end
end
end
})
minetest.register_tool("nssm:rainbow_staff", { if minetest.get_node(pos) then
description = "Rainbow Staff", local n = minetest.get_node(pos).name
inventory_image = "rainbow_staff.png", if n ~= "nyancat:nyancat_rainbow" then
on_use = function(itemstack, placer, pointed_thing) if n=="air" then
local dir = placer:get_look_dir(); minetest.set_node(pos, {name="nyancat:nyancat_rainbow"})
local playerpos = placer:getpos(); else
local obj = minetest.add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+2+dir.y,z=playerpos.z+0+dir.z}, "nssm:rainbow") minetest.chat_send_all("Nome:"..n)
local vec = {x=dir.x*6,y=dir.y*6,z=dir.z*6} minetest.set_node(pos, {name="nyancat:nyancat"})
obj:setvelocity(vec) self.object:remove()
return itemstack end
end, end
groups = {not_in_creative_inventory=1,} end
}) end
})
minetest.register_tool("nssm:rainbow_staff", {
description = "Rainbow Staff",
inventory_image = "rainbow_staff.png",
on_use = function(itemstack, placer, pointed_thing)
local dir = placer:get_look_dir();
local playerpos = placer:getpos();
local obj = minetest.add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+2+dir.y,z=playerpos.z+0+dir.z}, "nssm:rainbow")
local vec = {x=dir.x*6,y=dir.y*6,z=dir.z*6}
obj:setvelocity(vec)
return itemstack
end,
groups = {not_in_creative_inventory=1,}
})
else
minetest.register_tool("nssm:rainbow_staff", {
description = "Rainbow Bludgeon",
inventory_image = "rainbow_staff.png",
tool_capabilities = {
full_punch_interval = 0.2,
max_drop_level=1,
groupcaps={
snappy={times={[1]=0.80, [2]=0.40, [3]=0.20}, uses=70, maxlevel=1},
crumbly={times={[1]=0.80, [2]=0.40, [3]=0.20}, uses=70, maxlevel=1},
choppy={times={[1]=0.80, [2]=0.40, [3]=0.20}, uses=70, maxlevel=1},
cracky={times={[1]=0.80, [2]=0.40, [3]=0.20}, uses=70, maxlevel=1},
fleshy={times={[1]=0.80, [2]=0.60, [3]=0.20}, uses=140, maxlevel=1}
},
damage_groups = {fleshy=20},
},
groups = {not_in_creative_inventory=1,}
})
end

View File

@ -1,15 +1,17 @@
# ABOUT SETTINGS # ABOUT SETTINGS
# Mapgen: write here (after "int") 6 (mgv6) or 7 (mgv7 or valleys or fractal or flat) # Mapgen: write here (after "int") 6 (mgv6) or 7 (mgv7 or valleys or fractal or flat)
mymapgenis (Mapgen) int 7 nssm.mymapgenis (Mapgen) int 7
# Mobs-Multiplier: multiplier defining the spawn abundance for the mobs: # Mobs-Multiplier: multiplier defining the spawn abundance for the mobs:
# 0 = spawn disabled # 0 = spawn disabled
# a number between 0 and 1000 = less then default # a number between 0 and 1000 = less then default
# 1000 = default # 1000 = default
# more than 1000 = suicide is not the fastest way of dying # more than 1000 = suicide is not the fastest way of dying
multimobs (Multimobs) int 1000 nssm.multimobs (Multimobs) int 1000
# Difficult-level: # Difficult-level:
# Multiplier to raise life and damage of the mobs # Multiplier to raise life and damage of the mobs
mob_difficulty (Mob_difficulty) int 1 nssm.mob_difficulty (Mob difficulty) int 1
nssm.classic_rainbow_staff (Use the classical rainbow staff) bool true