Split files, and working antigravity 8D (may lag on servers though)

master
Zeg9 2013-04-23 13:37:15 +02:00
parent a593266a94
commit 0fc5cc3521
4 changed files with 245 additions and 204 deletions

94
ruby/anticrystal.lua Normal file
View File

@ -0,0 +1,94 @@
minetest.register_craftitem("ruby:anticrystal", {
description = "Anticrystal",
inventory_image = "ruby_anticrystal.png",
})
minetest.register_node("ruby:anticrystalblock", {
description = "Anticrystal Block",
tiles = {"ruby_anticrystal_block.png"},
is_ground_content = true,
groups = {anti=1,level=2},
sounds = default.node_sound_stone_defaults(),
})
local APS = 0.25 -- Anticrystal Pickaxe Speed
local APU = 100 -- Anticrystal Pickaxe Uses
minetest.register_tool("ruby:pick_anticrystal", {
description = "Anticrystal Pickaxe",
inventory_image = "ruby_tool_anticrystalpick.png",
tool_capabilities = {
full_punch_interval = 0.7,
max_drop_level=3,
groupcaps={
cracky = {times={[1]=APS, [2]=APS, [3]=APS}, uses=APU, maxlevel=3},
choppy={times={[1]=APS, [2]=APS, [3]=APS}, uses=APU, maxlevel=3},
crumbly = {times={[1]=APS, [2]=APS, [3]=APS}, uses=APU, maxlevel=3},
snappy={times={[1]=APS, [2]=APS, [3]=APS}, uses=APU, maxlevel=3},
anti={times={[1]=APS*5, [2]=APS*5, [3]=APS*5}, uses=APU, maxlevel=3},
},
damage_groups = {fleshy=7},
},
})
minetest.register_craft({
output = 'ruby:pick_anticrystal',
recipe = {
{'ruby:anticrystal', 'ruby:anticrystal', 'ruby:anticrystal'},
{'', 'default:stick', ''},
{'', 'default:stick', ''},
}
})
minetest.register_craft({
output = 'ruby:anticrystalblock',
recipe = {
{'ruby:anticrystal', 'ruby:anticrystal', 'ruby:anticrystal'},
{'ruby:anticrystal', 'ruby:anticrystal', 'ruby:anticrystal'},
{'ruby:anticrystal', 'ruby:anticrystal', 'ruby:anticrystal'},
}
})
-- Ruby block + Mese block --> Anticrystal
minetest.register_abm({
nodenames={"default:mese"},
neighbors={"ruby:rubyblock"},
interval = 5.0,
chance = 5,
action = function(pos,node,active_object_count,active_object_count_wider)
minetest.add_particlespawner(10, 1,
pos, pos,
{x=-10,y=-10,z=-10}, {x=10,y=10,z=10},
{x=-100,y=-100,z=-100}, {x=100,y=100,z=10},
1, 1,
.1,10,
false, "ruby_particle_ruby.png")
minetest.add_particlespawner(100, 1,
pos, pos,
{x=-10,y=-10,z=-10}, {x=10,y=10,z=10},
{x=-100,y=-100,z=-100}, {x=100,y=100,z=100},
1, 1,
.1,10,
false, "ruby_particle_mese.png")
local r = 2 -- Radius for destroying
for x = pos.x-r, pos.x+r, 1 do
for y = pos.y-r, pos.y+r, 1 do
for z = pos.z-r, pos.z+r, 1 do
local cpos = {x=x,y=y,z=z}
if minetest.env:get_node(cpos).name == "ruby:rubyblock" then
local e = minetest.env:add_item(cpos,{name="ruby:anticrystal"})
e:setvelocity({x=0,y=10,z=0})
end
-- The commented part allows to randomly destroy nodes around
if --[[math.random(0,1) == 1
or]] minetest.env:get_node(cpos).name == "ruby:rubyblock"
or minetest.env:get_node(cpos).name == "default:mese" then
minetest.env:remove_node(cpos)
end
end
end
end
end,
})

80
ruby/antigravity.lua Normal file
View File

@ -0,0 +1,80 @@
local antigravities = {}
local same_pos = function(p1,p2)
return p1.x == p2.x and p1.y == p2.y and p1.z == p2.z
end
local is_antigravity = function(pos)
for _, i in ipairs(antigravities) do
if i.x == pos.x
and i.y < pos.y
and i.z == pos.z then
return true
end
end
return false
end
minetest.register_node("ruby:antigravity",{
description = "Antigravity",
tiles = {"ruby_antigravity.png"},
is_ground_content = true,
groups = {anti=1,level=2},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
end,
})
minetest.register_globalstep(function(dtime)
for _, p in ipairs(minetest.get_connected_players()) do
local pos = p:getpos()
local rpos = {
x = math.floor(pos.x+.5),
y = math.floor(pos.y+.5),
z = math.floor(pos.z+.5)
}
if is_antigravity(rpos) then
p:set_physics_override(nil,nil,-1)
else
p:set_physics_override(nil,nil,1)
end
end
end)
minetest.register_abm({
nodenames={"ruby:antigravity"},
interval = 5,
chance = 1,
action = function(pos, node)
minpos = {}
minpos.x = pos.x - .5
minpos.y = pos.y
minpos.z = pos.z - .5
maxpos = {}
maxpos.x = pos.x + .5
maxpos.y = pos.y
maxpos.z = pos.z + .5
minetest.add_particlespawner(100,5,
minpos, maxpos,
{x=0,y=20,z=0}, {x=0,y=20,z=0},
{x=0,y=0,z=0}, {x=0,y=0,z=0},
1, 1,
.1, 1,
false, "ruby_particle_mese.png")
if not is_antigravity(pos) then
table.insert(antigravities,pos)
end
end,
})
minetest.register_craft({
output = 'ruby:antigravity',
recipe = {
{'default:mese_crystal','default:mese_crystal','default:mese_crystal'},
{'default:mese_crystal','ruby:anticrystalblock','default:mese_crystal'},
{'default:mese_crystal','default:mese_crystal','default:mese_crystal'},
}
})

View File

@ -1,207 +1,15 @@
minetest.register_craftitem("ruby:ruby", {
description = "Ruby",
inventory_image = "ruby_ruby.png",
})
minetest.register_craftitem("ruby:anticrystal", {
description = "Anticrystal",
inventory_image = "ruby_anticrystal.png",
})
-- Configuration
-- Remove the modules you do not want to load
local MODULES = {
"ruby",
"anticrystal",
"antigravity",
}
minetest.register_node("ruby:stone_with_ruby", {
description = "Rubies in Stone",
tiles = {"default_stone.png^ruby_mineral_ruby.png"},
is_ground_content = true,
groups = {cracky=1},
drop = "ruby:ruby",
sounds = default.node_sound_stone_defaults(),
})
-- End of configuration
minetest.register_node("ruby:rubyblock", {
description = "Ruby Block",
tiles = {"ruby_ruby_block.png"},
-- light_source = LIGHT_MAX, --TODO make Ruby lamp
is_ground_content = true,
groups = {cracky=1,level=2},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("ruby:anticrystalblock", {
description = "Anticrystal Block",
tiles = {"ruby_anticrystal_block.png"},
is_ground_content = true,
groups = {anti=1,level=2},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("ruby:antigravity",{
description = "Antigravity",
tiles = {"ruby_antigravity.png"},
is_ground_content = true,
groups = {anti=1,level=2},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
end,
})
minetest.register_abm({
nodenames={"ruby:antigravity"},
interval = 1,
chance = 1,
action = function(pos, node)
pos.y = pos.y+.5
local objs = minetest.env:get_objects_inside_radius(pos, .5)
pos.y = pos.y -.5
for _, obj in pairs(objs) do
if obj:is_player() then
obj:set_physics_override(nil,nil,-1)
minetest.after(5.0,function()
obj:set_physics_override(nil,nil,1)
end)
end
end
end,
})
minetest.register_abm({
nodenames={"ruby:antigravity"},
interval = 5,
chance = 1,
action = function(pos, node)
minpos = {}
minpos.x = pos.x - .5
minpos.y = pos.y
minpos.z = pos.z - .5
maxpos = {}
maxpos.x = pos.x + .5
maxpos.y = pos.y
maxpos.z = pos.z + .5
minetest.add_particlespawner(100,5,
minpos, maxpos,
{x=0,y=20,z=0}, {x=0,y=20,z=0},
{x=0,y=0,z=0}, {x=0,y=0,z=0},
1, 1,
.1, 1,
false, "ruby_particle_mese.png")
end,
})
minetest.register_abm({
nodenames={"default:mese"},
neighbors={"ruby:rubyblock"},
interval = 5.0,
chance = 5,
action = function(pos,node,active_object_count,active_object_count_wider)
minetest.add_particlespawner(10, 1,
pos, pos,
{x=-10,y=-10,z=-10}, {x=10,y=10,z=10},
{x=-100,y=-100,z=-100}, {x=100,y=100,z=10},
1, 1,
.1,10,
false, "ruby_particle_ruby.png")
minetest.add_particlespawner(100, 1,
pos, pos,
{x=-10,y=-10,z=-10}, {x=10,y=10,z=10},
{x=-100,y=-100,z=-100}, {x=100,y=100,z=100},
1, 1,
.1,10,
false, "ruby_particle_mese.png")
local r = 2 -- Radius for destroying
for x = pos.x-r, pos.x+r, 1 do
for y = pos.y-r, pos.y+r, 1 do
for z = pos.z-r, pos.z+r, 1 do
local cpos = {x=x,y=y,z=z}
if minetest.env:get_node(cpos).name == "ruby:rubyblock" then
local e = minetest.env:add_item(cpos,{name="ruby:anticrystal"})
e:setvelocity({x=0,y=10,z=0})
end
-- The commented part allows to randomly destroy nodes around
if --[[math.random(0,1) == 1
or]] minetest.env:get_node(cpos).name == "ruby:rubyblock"
or minetest.env:get_node(cpos).name == "default:mese" then
minetest.env:remove_node(cpos)
end
end
end
end
end,
})
minetest.register_ore({
ore_type = "scatter",
ore = "ruby:stone_with_ruby",
wherein = "default:stone",
clust_scarcity = 18*18*18,
clust_num_ores = 4,
clust_size = 3,
height_min = -5119,
height_max = -1024,
})
minetest.register_ore({
ore_type = "scatter",
ore = "ruby:stone_with_ruby",
wherein = "default:stone",
clust_scarcity = 12*12*12,
clust_num_ores = 4,
clust_size = 3,
height_min = -31000,
height_max = -5120,
})
minetest.register_craft({
output = 'ruby:rubyblock',
recipe = {
{'ruby:ruby', 'ruby:ruby', 'ruby:ruby'},
{'ruby:ruby', 'ruby:ruby', 'ruby:ruby'},
{'ruby:ruby', 'ruby:ruby', 'ruby:ruby'},
}
})
minetest.register_craft({
output = 'ruby:anticrystalblock',
recipe = {
{'ruby:anticrystal', 'ruby:anticrystal', 'ruby:anticrystal'},
{'ruby:anticrystal', 'ruby:anticrystal', 'ruby:anticrystal'},
{'ruby:anticrystal', 'ruby:anticrystal', 'ruby:anticrystal'},
}
})
minetest.register_craft({
output = 'ruby:antigravity',
recipe = {
{'default:mese_crystal','default:mese_crystal','default:mese_crystal'},
{'default:mese_crystal','ruby:anticrystalblock','default:mese_crystal'},
{'default:mese_crystal','default:mese_crystal','default:mese_crystal'},
}
})
local APS = 0.25 -- Anticrystal Pickaxe Speed
local APU = 100 -- Anticrystal Pickaxe Uses
minetest.register_tool("ruby:pick_anticrystal", {
description = "Anticrystal Pickaxe",
inventory_image = "ruby_tool_anticrystalpick.png",
tool_capabilities = {
full_punch_interval = 0.7,
max_drop_level=3,
groupcaps={
cracky = {times={[1]=APS, [2]=APS, [3]=APS}, uses=APU, maxlevel=3},
choppy={times={[1]=APS, [2]=APS, [3]=APS}, uses=APU, maxlevel=3},
crumbly = {times={[1]=APS, [2]=APS, [3]=APS}, uses=APU, maxlevel=3},
snappy={times={[1]=APS, [2]=APS, [3]=APS}, uses=APU, maxlevel=3},
anti={times={[1]=APS*5, [2]=APS*5, [3]=APS*5}, uses=APU, maxlevel=3},
},
damage_groups = {fleshy=7},
},
})
minetest.register_craft({
output = 'ruby:pick_anticrystal',
recipe = {
{'ruby:anticrystal', 'ruby:anticrystal', 'ruby:anticrystal'},
{'', 'default:stick', ''},
{'', 'default:stick', ''},
}
})
minetest.register_alias("default:stone_with_ruby","ruby:stone_with_ruby")
minetest.register_alias("default:ruby","ruby:ruby")
local MODPATH = minetest.get_modpath("ruby")
for i, m in ipairs(MODULES) do
dofile(MODPATH.."/"..m..".lua")
end

59
ruby/ruby.lua Normal file
View File

@ -0,0 +1,59 @@
minetest.register_craftitem("ruby:ruby", {
description = "Ruby",
inventory_image = "ruby_ruby.png",
})
minetest.register_node("ruby:stone_with_ruby", {
description = "Rubies in Stone",
tiles = {"default_stone.png^ruby_mineral_ruby.png"},
is_ground_content = true,
groups = {cracky=1},
drop = "ruby:ruby",
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("ruby:rubyblock", {
description = "Ruby Block",
tiles = {"ruby_ruby_block.png"},
-- light_source = LIGHT_MAX, --TODO make Ruby lamp
is_ground_content = true,
groups = {cracky=1,level=2},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_ore({
ore_type = "scatter",
ore = "ruby:stone_with_ruby",
wherein = "default:stone",
clust_scarcity = 18*18*18,
clust_num_ores = 4,
clust_size = 3,
height_min = -5119,
height_max = -1024,
})
minetest.register_ore({
ore_type = "scatter",
ore = "ruby:stone_with_ruby",
wherein = "default:stone",
clust_scarcity = 12*12*12,
clust_num_ores = 4,
clust_size = 3,
height_min = -31000,
height_max = -5120,
})
minetest.register_craft({
output = 'ruby:rubyblock',
recipe = {
{'ruby:ruby', 'ruby:ruby', 'ruby:ruby'},
{'ruby:ruby', 'ruby:ruby', 'ruby:ruby'},
{'ruby:ruby', 'ruby:ruby', 'ruby:ruby'},
}
})
-- This is for compatibility with the original version of the mod, which was a patch to default game
minetest.register_alias("default:stone_with_ruby","ruby:stone_with_ruby")
minetest.register_alias("default:ruby","ruby:ruby")