make antigrav mesecons compliant
parent
7d9c3d62cb
commit
d886dc64e0
437
antigrav.lua
437
antigrav.lua
|
@ -1,5 +1,43 @@
|
|||
minetest.register_node("ufowreck:alien_antigrav_off", {
|
||||
description = "Alien Antigrav OFF",
|
||||
------------------- anti grav beam initiator broken --------------------
|
||||
------------------------------------------------------------------------
|
||||
------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
-- minetest.register_node("ufowreck:alien_antigrav_broken", {
|
||||
-- description = minetest.colorize("#0E0", "Alien ").."Antigrav Beam (Broken)",
|
||||
-- tiles = {
|
||||
-- {name="alien_ag_top.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.00},},
|
||||
-- "alien_ag_bottom.png",
|
||||
-- {name="alien_ag_side.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.00},},
|
||||
-- {name="alien_ag_side.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.00},},
|
||||
-- {name="alien_ag_side.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.00},},
|
||||
-- {name="alien_ag_side.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.00},},
|
||||
-- },
|
||||
-- light_source = 5,
|
||||
-- groups = {cracky=2,},
|
||||
-- connect_sides = {"bottom"},
|
||||
-- sounds = default.node_sound_metal_defaults(),
|
||||
-- on_construct = function(pos,placer,itemstack)
|
||||
-- local meta = minetest.get_meta(pos)
|
||||
-- meta:set_string("infotext", minetest.colorize("#0E0", "Alien ").."Antigrav Beam (Broken)")
|
||||
-- end,
|
||||
-- on_rightclick = function(pos, node, clicker)
|
||||
-- local meta = minetest.get_meta(pos)
|
||||
-- meta:set_string("infotext", minetest.colorize("#0E0", "Alien ").."Antigrav Beam (Broken)")
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
|
||||
------------------- anti grav beam initiator off --------------------
|
||||
------------------------------------------------------------------------
|
||||
------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
minetest.register_node("ufowreck:alien_antigrav", {
|
||||
description = minetest.colorize("#0E0", "Alien ").."Antigrav Beam (Off)",
|
||||
tiles = {
|
||||
"alien_ag_top_off.png",
|
||||
"alien_ag_bottom.png",
|
||||
|
@ -8,33 +46,87 @@ minetest.register_node("ufowreck:alien_antigrav_off", {
|
|||
"alien_ag_side_off.png",
|
||||
"alien_ag_side_off.png",
|
||||
},
|
||||
groups = {cracky=2, technic_machine = 1, technic_hv = 1},
|
||||
groups = {cracky=2, mesecon_effector_off = 1 },
|
||||
connect_sides = {"bottom"},
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
drop = "ufowreck:alien_antigrav",
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
local meta = minetest.get_meta(pos)
|
||||
minetest.swap_node(pos,{name = "ufowreck:alien_antigrav"})
|
||||
meta:set_int("HV_EU_demand", 2000)
|
||||
meta:set_string("infotext", "Alien Antigrav")
|
||||
pos.y = pos.y + 1
|
||||
local yi
|
||||
if meta:get_int("HV_EU_input") < 2000 then
|
||||
-- on_construct = function(pos)
|
||||
-- local meta = minetest.get_meta(pos)
|
||||
-- meta:set_string("infotext", minetest.colorize("#0E0", "Alien ").."Antigrav Beam (Off)")
|
||||
-- pos.y = pos.y + 1
|
||||
-- local yi
|
||||
|
||||
-- for yi = 0, 100 do
|
||||
-- if (minetest.get_node(pos)).name == "air" then
|
||||
-- minetest.set_node(pos,{name = "ufowreck:ag_beam_off"})
|
||||
-- else
|
||||
-- break
|
||||
-- end
|
||||
-- pos.y = pos.y + 1
|
||||
-- end
|
||||
|
||||
-- end,
|
||||
mesecons = {effector = {
|
||||
rules = {
|
||||
{x=0, y=0, z=-1},
|
||||
{x=1, y=0, z=0},
|
||||
{x=-1, y=0, z=0},
|
||||
{x=0, y=0, z=1},
|
||||
{x=1, y=1, z=0},
|
||||
{x=1, y=-1, z=0},
|
||||
{x=-1, y=1, z=0},
|
||||
{x=-1, y=-1, z=0},
|
||||
{x=0, y=1, z=1},
|
||||
{x=0, y=-1, z=1},
|
||||
{x=0, y=1, z=-1},
|
||||
{x=0, y=-1, z=-1},
|
||||
{x=0, y=-1, z=0},
|
||||
},
|
||||
action_on = function (pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
minetest.swap_node(pos, {name = "ufowreck:alien_antigrav_on"})
|
||||
meta:set_string("infotext", minetest.colorize("#0E0", "Alien ").."Antigrav Beam (On)")
|
||||
pos.y = pos.y + 1
|
||||
local yi
|
||||
|
||||
minetest.sound_play("ag_on",{max_hear_distance = 16,pos = pos,gain = 1.0})
|
||||
for yi = 0, 100 do
|
||||
if (minetest.get_node(pos)).name == "air" then
|
||||
minetest.set_node(pos,{name = "ufowreck:ag_beam"})
|
||||
if (minetest.get_node(pos)).name == "air" or (minetest.get_node(pos)).name == "ufowreck:ag_beam_off" then
|
||||
minetest.set_node(pos,{name = "ufowreck:ag_beam_on"})
|
||||
else
|
||||
break
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
|
||||
end,
|
||||
|
||||
}},
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger) --gets rid of the beam when it is dug
|
||||
pos.y = pos.y + 1
|
||||
local yi
|
||||
|
||||
for yi = 0, 100 do
|
||||
if (minetest.get_node(pos)).name == "ufowreck:ag_beam_on" or (minetest.get_node(pos)).name == "ufowreck:ag_beam_off" then
|
||||
minetest.set_node(pos,{name = "air"})
|
||||
else
|
||||
break
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("ufowreck:alien_antigrav", {
|
||||
description = "Alien Antigrav",
|
||||
|
||||
|
||||
------------------- anti grav beam initiator on --------------------
|
||||
------------------------------------------------------------------------
|
||||
------------------------------------------------------------------------
|
||||
|
||||
|
||||
minetest.register_node("ufowreck:alien_antigrav_on", {
|
||||
description = minetest.colorize("#0E0", "Alien ").."Antigrav Beam (On)",
|
||||
tiles = {
|
||||
{name="alien_ag_top.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.00},},
|
||||
"alien_ag_bottom.png",
|
||||
|
@ -44,113 +136,250 @@ minetest.register_node("ufowreck:alien_antigrav", {
|
|||
{name="alien_ag_side.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.00},},
|
||||
},
|
||||
light_source = 5,
|
||||
groups = {cracky=2, technic_machine = 1, technic_hv = 1},
|
||||
groups = {cracky=2, not_in_creative_inventory = 1, mesecon_effector_on = 1,fall_damage_add_percent = -90,},
|
||||
connect_sides = {"bottom"},
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
drop = "ufowreck:alien_antigrav",
|
||||
after_place_node = function(pos,placer,itemstack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", "Alien Antigrav")
|
||||
meta:set_int("HV_EU_demand", 2000)
|
||||
pos.y = pos.y + 1
|
||||
local yi
|
||||
if meta:get_int("HV_EU_input") < 2000 then
|
||||
for yi = 0, 100 do
|
||||
if (minetest.get_node(pos)).name == "air" then
|
||||
minetest.set_node(pos,{name = "ufowreck:ag_beam"})
|
||||
else
|
||||
break
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
end
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
pos.y = pos.y + 1
|
||||
local yi
|
||||
for yi = 0, 100 do
|
||||
if (minetest.get_node(pos)).name == "ufowreck:ag_beam" then
|
||||
minetest.set_node(pos,{name = "air"})
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
local meta = minetest.get_meta(pos)
|
||||
minetest.swap_node(pos,{name = "ufowreck:alien_antigrav_off"})
|
||||
meta:set_int("HV_EU_demand", 0)
|
||||
meta:set_string("infotext", "Alien Antigrav Off")
|
||||
pos.y = pos.y + 1
|
||||
local yi
|
||||
for yi = 0, 100 do
|
||||
if (minetest.get_node(pos)).name == "ufowreck:ag_beam" then
|
||||
minetest.set_node(pos,{name = "air"})
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
--technic.register_machine("HV", "ufowreck:alien_antigrav", technic.receiver)
|
||||
--technic.register_machine("HV", "ufowreck:alien_antigrav_off", technic.receiver)
|
||||
|
||||
minetest.register_node("ufowreck:ag_beam", {
|
||||
description = "antigrav beam",
|
||||
paramtype = "light",
|
||||
tiles = {
|
||||
"alien_ag_beam.png",
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
use_texture_alpha = true,
|
||||
light_source = 14,
|
||||
sunlight_propagates = true,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
walkable = false,
|
||||
climbable = true,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("life", 12)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"ufowreck:alien_antigrav"},
|
||||
interval = 10,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", minetest.colorize("#0E0", "Alien ").."Antigrav Beam (On)")
|
||||
pos.y = pos.y + 1
|
||||
if meta:get_int("HV_EU_input") < 2000 then
|
||||
local yi
|
||||
for yi = 0, 100 do
|
||||
if (minetest.get_node(pos)).name == "ufowreck:ag_beam" then
|
||||
minetest.set_node(pos,{name = "air"})
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
for yi = 0, 100 do
|
||||
if (minetest.get_node(pos)).name == "air" then
|
||||
minetest.set_node(pos,{name = "ufowreck:ag_beam"})
|
||||
minetest.set_node(pos,{name = "ufowreck:ag_beam_on"})
|
||||
else
|
||||
break
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
|
||||
end,
|
||||
|
||||
on_destruct = function(pos) --gets rid of the beam when it is dug
|
||||
pos.y = pos.y + 1
|
||||
local yi
|
||||
|
||||
for yi = 0, 100 do
|
||||
if (minetest.get_node(pos)).name == "ufowreck:ag_beam_on" or (minetest.get_node(pos)).name == "ufowreck:ag_beam_off" then
|
||||
minetest.set_node(pos,{name = "air"})
|
||||
else
|
||||
break
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
end
|
||||
|
||||
end,
|
||||
|
||||
|
||||
mesecons = {effector = {
|
||||
rules = lightstone_rules,
|
||||
action_off = function (pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
minetest.swap_node(pos,{name = "ufowreck:alien_antigrav"})
|
||||
meta:set_string("infotext", minetest.colorize("#0E0", "Alien ").."Antigrav Beam (Off)")
|
||||
pos.y = pos.y + 1
|
||||
local yi
|
||||
for yi = 0, 100 do
|
||||
if (minetest.get_node(pos)).name == "ufowreck:ag_beam_on" then
|
||||
minetest.set_node(pos,{name = "air"})
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
end,
|
||||
}},
|
||||
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger) --gets rid of the beam when it is dug
|
||||
pos.y = pos.y + 1
|
||||
local yi
|
||||
|
||||
for yi = 0, 100 do
|
||||
if (minetest.get_node(pos)).name == "ufowreck:ag_beam_on" or (minetest.get_node(pos)).name == "ufowreck:ag_beam_off" then
|
||||
minetest.set_node(pos,{name = "air"})
|
||||
else
|
||||
break
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
|
||||
------------------- anti grav beam nodes -----------------------------
|
||||
------------------------------------------------------------------------
|
||||
------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
-------zero_grav effect ------------
|
||||
local gravity = player_monoids.gravity
|
||||
|
||||
local timer = 0
|
||||
ufowreck.antigrav_players = {}
|
||||
minetest.register_globalstep(function(dtime)
|
||||
timer = timer + dtime;
|
||||
if timer >= 1 then
|
||||
for _,player in pairs(minetest.get_connected_players()) do
|
||||
if minetest.get_node(player:get_pos()).name == "ufowreck:ag_beam_on" and ufowreck.antigrav_players[player:get_player_name()] == nil then
|
||||
-- player is standing in the ag_beam_on node, and is not on the list
|
||||
ufowreck.antigrav_players[player:get_player_name()] = player
|
||||
gravity:add_change(player, 0, "ufowreck_0_grav")
|
||||
player:add_velocity(vector.new(0,2,0))
|
||||
else
|
||||
if ufowreck.antigrav_players[player:get_player_name()] ~= nil then
|
||||
--player is on the list
|
||||
if minetest.get_node(player:get_pos()).name ~= "ufowreck:ag_beam_on" then
|
||||
--the player is not in an ag_beam_on node
|
||||
gravity:del_change(player, "ufowreck_0_grav")
|
||||
ufowreck.antigrav_players[player:get_player_name()] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
if ufowreck.antigrav_players[player:get_player_name()] == nil then
|
||||
return
|
||||
else
|
||||
ufowreck.antigrav_players[player:get_player_name()] = nil
|
||||
gravity:del_change(player, "ufowreck_0_grav")
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- minetest.register_node("ufowreck:ag_beam_off", {
|
||||
-- description = "Alien Antigrav Beam node (off)",
|
||||
-- paramtype = "light",
|
||||
-- tiles = {
|
||||
-- "alien_ag_beam.png",
|
||||
-- },
|
||||
-- drawtype = "nodebox",
|
||||
-- paramtype = "light",
|
||||
-- use_texture_alpha = true,
|
||||
-- light_source = 14,
|
||||
-- sunlight_propagates = true,
|
||||
-- pointable = false,
|
||||
-- diggable = false,
|
||||
-- buildable_to = false,
|
||||
-- walkable = false,
|
||||
-- climbable = true,
|
||||
-- drop = "",
|
||||
-- on_construct = function(pos)
|
||||
-- local timer = minetest.get_node_timer(pos)
|
||||
-- timer:start(1) -- in seconds
|
||||
-- end,
|
||||
-- on_destruct = function(pos)
|
||||
-- local timer = minetest.get_node_timer(pos)
|
||||
-- timer:stop()
|
||||
-- end,
|
||||
-- on_timer = function(pos)
|
||||
-- local obj_list = minetest.get_objects_inside_radius(pos, .5)
|
||||
-- for _,obj in ipairs(obj_list) do
|
||||
-- local is_p = false
|
||||
-- if obj:is_player() then
|
||||
-- is_p = true
|
||||
-- end
|
||||
-- if not(is_p) then
|
||||
-- --local vel = obj:get_velocity()
|
||||
-- local ent = obj:get_luaentity()
|
||||
-- if ent ~= nil then
|
||||
-- obj:set_velocity({x = 0, y = 0, z= 0})
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
-- if minetest.get_node(pos).name == "ufowreck:ag_beam_off" then
|
||||
-- return true
|
||||
-- else
|
||||
-- return false
|
||||
-- end
|
||||
-- end,
|
||||
|
||||
-- groups = {not_in_creative_inventory = 1},
|
||||
-- })
|
||||
|
||||
|
||||
|
||||
minetest.register_node("ufowreck:ag_beam_on", {
|
||||
description = "Alien Antigrav Beam node (on)",
|
||||
paramtype = "light",
|
||||
tiles = {
|
||||
"alien_ag_beam.png",
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
use_texture_alpha = true,
|
||||
light_source = 14,
|
||||
sunlight_propagates = true,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = false,
|
||||
walkable = false,
|
||||
climbable = false,
|
||||
drop = "",
|
||||
on_construct = function(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
timer:start(.3) -- in seconds
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
timer:stop()
|
||||
end,
|
||||
on_timer = function(pos)
|
||||
local obj_list = minetest.get_objects_inside_radius(pos, .6)
|
||||
for _,obj in ipairs(obj_list) do
|
||||
local is_p = false
|
||||
if obj:is_player() then
|
||||
-- local player = obj
|
||||
-- local vel = player:get_player_velocity().y
|
||||
-- vel = 3 - vel
|
||||
-- player:add_player_velocity({x = 0, y = vel, z = 0})
|
||||
|
||||
is_p = true
|
||||
end
|
||||
|
||||
if not(is_p) then
|
||||
local ent = obj:get_luaentity()
|
||||
if ent ~= nil then
|
||||
vel = obj:get_velocity()
|
||||
-- local yvel = vel.y
|
||||
-- yvel = 10- yvel
|
||||
obj:set_velocity({x=vel.x, y=10, z=vel.z})
|
||||
end
|
||||
end
|
||||
end
|
||||
if minetest.get_node(pos).name == "ufowreck:ag_beam_on" then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end,
|
||||
|
||||
groups = {not_in_creative_inventory = 1},
|
||||
})
|
||||
|
||||
|
||||
------------------- CRAFTS -----------------------------
|
||||
------------------------------------------------------------------------
|
||||
------------------------------------------------------------------------
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "ufowreck:alien_antigrav",
|
||||
recipe = {
|
||||
{"technic:copper_coil", "basic_materials:silver_wire", "technic:copper_coil"},
|
||||
{"ufowreck:alien_control", "technic:hv_transformer", "ufowreck:alien_control"},
|
||||
{"ufowreck:alien_metal", "technic:hv_cable", "ufowreck:alien_metal"}
|
||||
}
|
||||
})
|
||||
type = "shapeless",
|
||||
output = "ufowreck:alien_antigrav",
|
||||
recipe = {
|
||||
"ufowreck:alien_antigrav_broken",
|
||||
"mesecons_fpga:fpga0000",
|
||||
"default:mese_crystal_fragment",
|
||||
},
|
||||
})
|
Loading…
Reference in New Issue