forked from Mirrorlandia_minetest/mod-sneeker
Replace double-quoted strings with single-quoted
This commit is contained in:
parent
83c26a3a41
commit
e8a37511ea
72
init.lua
72
init.lua
@ -1,7 +1,7 @@
|
|||||||
sneaker = {}
|
sneaker = {}
|
||||||
|
|
||||||
dofile(minetest.get_modpath("sneaker").."/tnt_function.lua")
|
dofile(minetest.get_modpath('sneaker')..'/tnt_function.lua')
|
||||||
dofile(minetest.get_modpath("sneaker").."/spawn.lua")
|
dofile(minetest.get_modpath('sneaker')..'/spawn.lua')
|
||||||
|
|
||||||
local function jump(self,pos,direction)
|
local function jump(self,pos,direction)
|
||||||
local velocity = self.object:getvelocity()
|
local velocity = self.object:getvelocity()
|
||||||
@ -23,7 +23,7 @@ local function jump(self,pos,direction)
|
|||||||
end
|
end
|
||||||
if def and def.walkable
|
if def and def.walkable
|
||||||
and def2 and not def2.walkable
|
and def2 and not def2.walkable
|
||||||
and def.drawtype ~= "fencelike" then
|
and def.drawtype ~= 'fencelike' then
|
||||||
self.object:setvelocity({
|
self.object:setvelocity({
|
||||||
x=velocity.x*2.2,
|
x=velocity.x*2.2,
|
||||||
y=self.jump_height,
|
y=self.jump_height,
|
||||||
@ -36,11 +36,11 @@ local function random_turn(self)
|
|||||||
if self.turn_timer > math.random(2,5) then
|
if self.turn_timer > math.random(2,5) then
|
||||||
local select_turn = math.random(1,3)
|
local select_turn = math.random(1,3)
|
||||||
if select_turn == 1 then
|
if select_turn == 1 then
|
||||||
self.turn = "left"
|
self.turn = 'left'
|
||||||
elseif select_turn == 2 then
|
elseif select_turn == 2 then
|
||||||
self.turn = "right"
|
self.turn = 'right'
|
||||||
elseif select_turn == 3 then
|
elseif select_turn == 3 then
|
||||||
self.turn = "straight"
|
self.turn = 'straight'
|
||||||
end
|
end
|
||||||
self.turn_timer = 0
|
self.turn_timer = 0
|
||||||
self.turn_speed = 0.05*math.random()
|
self.turn_speed = 0.05*math.random()
|
||||||
@ -51,9 +51,9 @@ local def = {
|
|||||||
hp_max = 20,
|
hp_max = 20,
|
||||||
physical = true,
|
physical = true,
|
||||||
collisionbox = {-0.25,-0.7,-0.25, 0.25,0.8,0.25},
|
collisionbox = {-0.25,-0.7,-0.25, 0.25,0.8,0.25},
|
||||||
visual = "mesh",
|
visual = 'mesh',
|
||||||
mesh = "character.b3d",
|
mesh = 'character.b3d',
|
||||||
textures = {"sneaker.png"},
|
textures = {'sneaker.png'},
|
||||||
makes_footstep_sound = false,
|
makes_footstep_sound = false,
|
||||||
|
|
||||||
-- Original
|
-- Original
|
||||||
@ -83,15 +83,15 @@ def.on_activate = function(self,staticdata)
|
|||||||
self.old_y = self.object:getpos().y
|
self.old_y = self.object:getpos().y
|
||||||
|
|
||||||
local data = minetest.deserialize(staticdata)
|
local data = minetest.deserialize(staticdata)
|
||||||
if data and type(data) == "table" then
|
if data and type(data) == 'table' then
|
||||||
if data.powered == true then
|
if data.powered == true then
|
||||||
self.powered = true
|
self.powered = true
|
||||||
self.object:set_properties({textures = {"sneaker_powered.png"}})
|
self.object:set_properties({textures = {'sneaker_powered.png'}})
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if math.random(0,20) == 20 then
|
if math.random(0,20) == 20 then
|
||||||
self.powered = true
|
self.powered = true
|
||||||
self.object:set_properties({textures = {"sneaker_powered.png"}})
|
self.object:set_properties({textures = {'sneaker_powered.png'}})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -119,24 +119,24 @@ def.on_step = function(self, dtime)
|
|||||||
if not self.chase
|
if not self.chase
|
||||||
and self.timer > math.random(2,5) then
|
and self.timer > math.random(2,5) then
|
||||||
if math.random() > 0.8 then
|
if math.random() > 0.8 then
|
||||||
self.state = "stand"
|
self.state = 'stand'
|
||||||
else
|
else
|
||||||
self.state = "walk"
|
self.state = 'walk'
|
||||||
end
|
end
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.turn == "right" then
|
if self.turn == 'right' then
|
||||||
self.yaw = self.yaw+self.turn_speed
|
self.yaw = self.yaw+self.turn_speed
|
||||||
self.object:setyaw(self.yaw)
|
self.object:setyaw(self.yaw)
|
||||||
elseif self.turn == "left" then
|
elseif self.turn == 'left' then
|
||||||
self.yaw = self.yaw-self.turn_speed
|
self.yaw = self.yaw-self.turn_speed
|
||||||
self.object:setyaw(self.yaw)
|
self.object:setyaw(self.yaw)
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.chase and self.visualx < 2 then
|
if self.chase and self.visualx < 2 then
|
||||||
if self.hiss == false then
|
if self.hiss == false then
|
||||||
minetest.sound_play("sneaker_hiss",{pos=pos,gain=1.5,max_hear_distance=2*64})
|
minetest.sound_play('sneaker_hiss',{pos=pos,gain=1.5,max_hear_distance=2*64})
|
||||||
end
|
end
|
||||||
self.visualx = self.visualx+0.05
|
self.visualx = self.visualx+0.05
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
@ -155,11 +155,11 @@ def.on_step = function(self, dtime)
|
|||||||
|
|
||||||
for _,object in ipairs(inside) do
|
for _,object in ipairs(inside) do
|
||||||
if object:is_player() then
|
if object:is_player() then
|
||||||
self.state = "chase"
|
self.state = 'chase'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.state == "stand" then
|
if self.state == 'stand' then
|
||||||
if self.anim ~= ANIM_STAND then
|
if self.anim ~= ANIM_STAND then
|
||||||
self.object:set_animation({x=animation.stand_START,y=animation.stand_END},anim_speed,0)
|
self.object:set_animation({x=animation.stand_START,y=animation.stand_END},anim_speed,0)
|
||||||
self.anim = ANIM_STAND
|
self.anim = ANIM_STAND
|
||||||
@ -173,7 +173,7 @@ def.on_step = function(self, dtime)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.state == "walk" then
|
if self.state == 'walk' then
|
||||||
if self.anim ~= ANIM_WALK then
|
if self.anim ~= ANIM_WALK then
|
||||||
self.object:set_animation({x=animation.walk_START,y=animation.walk_END},anim_speed,0)
|
self.object:set_animation({x=animation.walk_START,y=animation.walk_END},anim_speed,0)
|
||||||
self.anim = ANIM_WALK
|
self.anim = ANIM_WALK
|
||||||
@ -195,9 +195,9 @@ def.on_step = function(self, dtime)
|
|||||||
or minetest.registered_nodes[minetest.get_node(npos).name].walkable then
|
or minetest.registered_nodes[minetest.get_node(npos).name].walkable then
|
||||||
local select_turn = math.random(1,2)
|
local select_turn = math.random(1,2)
|
||||||
if select_turn == 1 then
|
if select_turn == 1 then
|
||||||
self.turn = "left"
|
self.turn = 'left'
|
||||||
elseif select_turn == 2 then
|
elseif select_turn == 2 then
|
||||||
self.turn = "right"
|
self.turn = 'right'
|
||||||
end
|
end
|
||||||
self.turn_timer = 0
|
self.turn_timer = 0
|
||||||
self.turn_speed = 0.05*math.random()
|
self.turn_speed = 0.05*math.random()
|
||||||
@ -210,13 +210,13 @@ def.on_step = function(self, dtime)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.state == "chase" then
|
if self.state == 'chase' then
|
||||||
if self.anim ~= ANIM_WALK then
|
if self.anim ~= ANIM_WALK then
|
||||||
self.object:set_animation({x=animation.walk_START,y=animation.walk_END},anim_speed,0)
|
self.object:set_animation({x=animation.walk_START,y=animation.walk_END},anim_speed,0)
|
||||||
self.anim = ANIM_WALK
|
self.anim = ANIM_WALK
|
||||||
end
|
end
|
||||||
|
|
||||||
self.turn = "straight"
|
self.turn = 'straight'
|
||||||
|
|
||||||
local inside_2 = minetest.get_objects_inside_radius(pos,2)
|
local inside_2 = minetest.get_objects_inside_radius(pos,2)
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ def.on_step = function(self, dtime)
|
|||||||
if self.visualx >= 2 then
|
if self.visualx >= 2 then
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
sneaker.boom(pos,self.powered)
|
sneaker.boom(pos,self.powered)
|
||||||
minetest.sound_play("sneaker_explode",{pos=pos,gain=1.5,max_hear_distance=2*64})
|
minetest.sound_play('sneaker_explode',{pos=pos,gain=1.5,max_hear_distance=2*64})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -271,13 +271,13 @@ def.on_step = function(self, dtime)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self.state = "stand"
|
self.state = 'stand'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Swim
|
-- Swim
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if minetest.get_item_group(node.name,"water") ~= 0 then
|
if minetest.get_item_group(node.name,'water') ~= 0 then
|
||||||
self.object:setacceleration({x=0,y=1,z=0})
|
self.object:setacceleration({x=0,y=1,z=0})
|
||||||
local velocity = self.object:getvelocity()
|
local velocity = self.object:getvelocity()
|
||||||
if self.object:getvelocity().y > 5 then
|
if self.object:getvelocity().y > 5 then
|
||||||
@ -305,10 +305,10 @@ def.on_punch = function(self,puncher,time_from_last_punch,tool_capabilities,dir)
|
|||||||
local z = 1/math.random(1,5)*dir.z
|
local z = 1/math.random(1,5)*dir.z
|
||||||
local p = {x=pos.x+x,y=pos.y,z=pos.z+z}
|
local p = {x=pos.x+x,y=pos.y,z=pos.z+z}
|
||||||
local node = minetest.get_node_or_nil(p)
|
local node = minetest.get_node_or_nil(p)
|
||||||
if node == nil or not node.name or node.name ~= "air" then
|
if node == nil or not node.name or node.name ~= 'air' then
|
||||||
p = pos
|
p = pos
|
||||||
end
|
end
|
||||||
local obj = minetest.add_item(p, {name="tnt:gunpowder",count=math.random(0,2)})
|
local obj = minetest.add_item(p, {name='tnt:gunpowder',count=math.random(0,2)})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -318,19 +318,19 @@ def.get_staticdata = function(self)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_entity("sneaker:sneaker",def)
|
minetest.register_entity('sneaker:sneaker',def)
|
||||||
|
|
||||||
if minetest.get_modpath('spawneggs') and minetest.get_modpath('tnt') then
|
if minetest.get_modpath('spawneggs') and minetest.get_modpath('tnt') then
|
||||||
minetest.register_craftitem("sneaker:spawnegg",{
|
minetest.register_craftitem('sneaker:spawnegg',{
|
||||||
description = "Sneaker Spawn Egg",
|
description = 'Sneaker Spawn Egg',
|
||||||
inventory_image = "sneaker_spawnegg.png",
|
inventory_image = 'sneaker_spawnegg.png',
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
on_place = function(itemstack,placer,pointed_thing)
|
on_place = function(itemstack,placer,pointed_thing)
|
||||||
if pointed_thing.type == "node" then
|
if pointed_thing.type == 'node' then
|
||||||
local pos = pointed_thing.above
|
local pos = pointed_thing.above
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
minetest.add_entity(pos,"sneaker:sneaker")
|
minetest.add_entity(pos,'sneaker:sneaker')
|
||||||
if not minetest.settings:get_bool("creative_mode") then
|
if not minetest.settings:get_bool('creative_mode') then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
|
10
spawn.lua
10
spawn.lua
@ -5,8 +5,8 @@ local time_hr = time_min * 60
|
|||||||
local time_day = time_hr * 24
|
local time_day = time_hr * 24
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"default:dirt_with_grass","default:stone"},
|
nodenames = {'default:dirt_with_grass','default:stone'},
|
||||||
neighbors = {"air"},
|
neighbors = {'air'},
|
||||||
interval = time_min * 20, -- Run spawn function every 20 minutes
|
interval = time_min * 20, -- Run spawn function every 20 minutes
|
||||||
chance = 9000,
|
chance = 9000,
|
||||||
action = function(pos, node, _, active_object_count_wider)
|
action = function(pos, node, _, active_object_count_wider)
|
||||||
@ -26,13 +26,13 @@ minetest.register_abm({
|
|||||||
if pos.y > 31000 then
|
if pos.y > 31000 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if minetest.get_node(pos).name ~= "air" then
|
if minetest.get_node(pos).name ~= 'air' then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
if minetest.get_node(pos).name ~= "air" then
|
if minetest.get_node(pos).name ~= 'air' then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
minetest.add_entity(pos,"sneaker:sneaker")
|
minetest.add_entity(pos,'sneaker:sneaker')
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
-- From TNT
|
-- From TNT
|
||||||
local cid_data = {}
|
local cid_data = {}
|
||||||
local radius = tonumber(minetest.settings:get("tnt_radius") or 3)
|
local radius = tonumber(minetest.settings:get('tnt_radius') or 3)
|
||||||
local large_radius = 5
|
local large_radius = 5
|
||||||
local loss_prob = {
|
local loss_prob = {
|
||||||
["default:cobble"] = 3,
|
['default:cobble'] = 3,
|
||||||
["default:dirt"] = 4,
|
['default:dirt'] = 4,
|
||||||
}
|
}
|
||||||
minetest.after(0, function()
|
minetest.after(0, function()
|
||||||
for name, def in pairs(minetest.registered_nodes) do
|
for name, def in pairs(minetest.registered_nodes) do
|
||||||
@ -62,7 +62,7 @@ local function add_drop(drops, item)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function destroy(drops, pos, cid)
|
local function destroy(drops, pos, cid)
|
||||||
if minetest.is_protected(pos, "") then
|
if minetest.is_protected(pos, '') then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local def = cid_data[cid]
|
local def = cid_data[cid]
|
||||||
@ -72,7 +72,7 @@ local function destroy(drops, pos, cid)
|
|||||||
end
|
end
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
if def then
|
if def then
|
||||||
local node_drops = minetest.get_node_drops(def.name, "")
|
local node_drops = minetest.get_node_drops(def.name, '')
|
||||||
for _, item in ipairs(node_drops) do
|
for _, item in ipairs(node_drops) do
|
||||||
add_drop(drops, item)
|
add_drop(drops, item)
|
||||||
end
|
end
|
||||||
@ -128,7 +128,7 @@ local function add_effects(pos, radius)
|
|||||||
maxexptime = 3,
|
maxexptime = 3,
|
||||||
minsize = 8,
|
minsize = 8,
|
||||||
maxsize = 16,
|
maxsize = 16,
|
||||||
texture = "sneaker_smoke.png",
|
texture = 'sneaker_smoke.png',
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -146,12 +146,12 @@ local function explode(pos, radius)
|
|||||||
local drops = {}
|
local drops = {}
|
||||||
local p = {}
|
local p = {}
|
||||||
|
|
||||||
local c_air = minetest.get_content_id("air")
|
local c_air = minetest.get_content_id('air')
|
||||||
local c_tnt = minetest.get_content_id("tnt:tnt")
|
local c_tnt = minetest.get_content_id('tnt:tnt')
|
||||||
local c_tnt_burning = minetest.get_content_id("tnt:tnt_burning")
|
local c_tnt_burning = minetest.get_content_id('tnt:tnt_burning')
|
||||||
local c_gunpowder = minetest.get_content_id("tnt:gunpowder")
|
local c_gunpowder = minetest.get_content_id('tnt:gunpowder')
|
||||||
local c_gunpowder_burning = minetest.get_content_id("tnt:gunpowder_burning")
|
local c_gunpowder_burning = minetest.get_content_id('tnt:gunpowder_burning')
|
||||||
local c_boom = minetest.get_content_id("tnt:boom")
|
local c_boom = minetest.get_content_id('tnt:boom')
|
||||||
|
|
||||||
for z = -radius, radius do
|
for z = -radius, radius do
|
||||||
for y = -radius, radius do
|
for y = -radius, radius do
|
||||||
@ -185,8 +185,8 @@ function sneaker.boom(pos,large)
|
|||||||
if large then
|
if large then
|
||||||
radius = large_radius
|
radius = large_radius
|
||||||
end
|
end
|
||||||
minetest.sound_play("sneaker_explode", {pos=pos, gain=1.5, max_hear_distance=2*64})
|
minetest.sound_play('sneaker_explode', {pos=pos, gain=1.5, max_hear_distance=2*64})
|
||||||
minetest.set_node(pos, {name="tnt:boom"})
|
minetest.set_node(pos, {name='tnt:boom'})
|
||||||
minetest.get_node_timer(pos):start(0.5)
|
minetest.get_node_timer(pos):start(0.5)
|
||||||
local drops = explode(pos, radius)
|
local drops = explode(pos, radius)
|
||||||
entity_physics(pos, radius)
|
entity_physics(pos, radius)
|
||||||
|
Loading…
Reference in New Issue
Block a user