forked from Mirrorlandia_minetest/portalgun
_
This commit is contained in:
parent
bad55d19a0
commit
f580dcd720
@ -14,12 +14,15 @@ function portalgun_gravity(itemstack, user, pointed_thing)
|
||||
return itemstack
|
||||
end
|
||||
if not ob:get_attach() and (ob:is_player() or (ob:get_luaentity() and ob:get_luaentity().powerball~=1)) then
|
||||
portalgun_power.user=user
|
||||
portalgun_power.target=ob
|
||||
if ob:is_player() then portalgun_power.player=1 end
|
||||
local m=minetest.add_entity(ob:get_pos(), "portalgun:power")
|
||||
ob:set_attach(m, "", {x=0,y=0,z=0}, {x=0,y=0,z=0})
|
||||
return itemstack
|
||||
--if 4 blocks or closer to player
|
||||
if vector.distance(ob:get_pos(),user:get_pos())<4 then
|
||||
portalgun_power.user=user
|
||||
portalgun_power.target=ob
|
||||
if ob:is_player() then portalgun_power.player=1 end
|
||||
local m=minetest.add_entity(ob:get_pos(), "portalgun:power")
|
||||
ob:set_attach(m, "", {x=0,y=0,z=0}, {x=0,y=0,z=0})
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
127
init.lua
127
init.lua
@ -337,7 +337,7 @@ on_activate= function(self, staticdata)
|
||||
end,
|
||||
on_step=portalgun_on_step,
|
||||
})
|
||||
minetest.register_craftitem("portalgun:gun", {
|
||||
minetest.register_craftitem(":", {
|
||||
description = "Portalgun",
|
||||
range = 100,
|
||||
inventory_image = "portalgun_gun0_rndr.png",
|
||||
@ -352,118 +352,33 @@ minetest.register_craftitem("portalgun:gun", {
|
||||
damage_groups = {fleshy=1},
|
||||
},
|
||||
on_place=function(itemstack, user, pointed_thing)
|
||||
portalgun_setmode(itemstack, user, pointed_thing, 2)
|
||||
portalgun_onuse(itemstack, user, pointed_thing)
|
||||
local node = minetest.get_node(pointed_thing.under)
|
||||
if node.name=="portalgun:button"then
|
||||
--use the item normally
|
||||
minetest.item_place(itemstack, user, pointed_thing)
|
||||
else
|
||||
portalgun_onuse(itemstack, user, pointed_thing, 2)
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
portalgun_setmode(itemstack, user, pointed_thing, 1)
|
||||
portalgun_onuse(itemstack, user, pointed_thing)
|
||||
--if pointing at turret then start breaking it
|
||||
if pointed_thing.type=="node" then
|
||||
local node=minetest.get_node(pointed_thing.under)
|
||||
if node.name=="portalgun:turretgun" or node.name=="portalgun:turretgun2" then
|
||||
minetest.remove_node(pointed_thing.under)
|
||||
end
|
||||
end
|
||||
portalgun_onuse(itemstack, user, pointed_thing, 1)
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craftitem("portalgun:gun1", {
|
||||
description = "Portalgun (blue)",
|
||||
range = 100,
|
||||
groups = {not_in_creative_inventory=1},
|
||||
inventory_image = "portalgun_gun1_rndr.png",
|
||||
wield_image = "portalgun_gun1_rndr.png",
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.5,
|
||||
max_drop_level = 3,
|
||||
groupcaps = {
|
||||
fleshy = {times={[2]=0.80, [3]=0.40}, uses=100, maxlevel=3},
|
||||
oddly_breakable_by_hand = {times={[1]=1}, uses=100, maxlevel=1},
|
||||
},
|
||||
damage_groups = {fleshy=1},
|
||||
},
|
||||
on_place=function(itemstack, user, pointed_thing)
|
||||
portalgun_setmode(itemstack, user, pointed_thing, 2)
|
||||
portalgun_onuse(itemstack, user, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
portalgun_setmode(itemstack, user, pointed_thing, 1)
|
||||
portalgun_onuse(itemstack, user, pointed_thing)
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
minetest.register_craftitem("portalgun:gun2", {
|
||||
description = "Portalgun (orange)",
|
||||
range = 100,
|
||||
inventory_image = "portalgun_gun2_rndr.png",
|
||||
wield_image = "portalgun_gun2_rndr.png",
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.5,
|
||||
max_drop_level = 3,
|
||||
groupcaps = {
|
||||
fleshy = {times={[2]=0.80, [3]=0.40}, uses=100, maxlevel=3},
|
||||
oddly_breakable_by_hand = {times={[1]=1}, uses=100, maxlevel=1},
|
||||
},
|
||||
damage_groups = {fleshy=1},
|
||||
},
|
||||
groups = {not_in_creative_inventory=1},
|
||||
on_place=function(itemstack, user, pointed_thing)
|
||||
portalgun_setmode(itemstack, user, pointed_thing, 2)
|
||||
portalgun_onuse(itemstack, user, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
portalgun_setmode(itemstack, user, pointed_thing, 1)
|
||||
portalgun_onuse(itemstack, user, pointed_thing)
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
function portalgun_mode(itemstack, user, pointed_thing) -- change modes
|
||||
local item=itemstack:to_table()
|
||||
local meta=minetest.deserialize(item["metadata"])
|
||||
local mode=0
|
||||
if meta==nil then
|
||||
meta={}
|
||||
mode=1
|
||||
minetest.chat_send_player(user:get_player_name(), "<Portalgun> PLACE to change portal mode (or LEFT+RIGHTCLICK to use the other)")
|
||||
minetest.chat_send_player(user:get_player_name(), "<Portalgun> LEFTCLICK on an object to carry it, CLICK AGAIN to release")
|
||||
minetest.chat_send_player(user:get_player_name(), "<Portalgun> SHIFT+LEFTCLICK to close both portals (or wait 40sec until it removes it self)")
|
||||
end
|
||||
if meta.mode==nil then meta.mode=2 end
|
||||
mode=(meta.mode)
|
||||
if mode==1 then
|
||||
mode=2
|
||||
else
|
||||
mode=1
|
||||
end
|
||||
meta.mode=mode
|
||||
item.name="portalgun:gun"..mode
|
||||
item.metadata=minetest.serialize(meta)
|
||||
itemstack:replace(item)
|
||||
minetest.sound_play("portalgun_mode", {pos=user:get_pos(),max_hear_distance = 5, gain = 1})
|
||||
end
|
||||
|
||||
function portalgun_setmode(itemstack, user, pointed_thing, mode) -- change modes
|
||||
local item=itemstack:to_table()
|
||||
local meta=minetest.deserialize(item["metadata"])
|
||||
if meta==nil then
|
||||
meta={}
|
||||
mode=1
|
||||
minetest.chat_send_player(user:get_player_name(), "<Portalgun> PLACE to change portal mode (or LEFT+RIGHTCLICK to use the other)")
|
||||
minetest.chat_send_player(user:get_player_name(), "<Portalgun> LEFTCLICK on an object to carry it, CLICK AGAIN to release")
|
||||
minetest.chat_send_player(user:get_player_name(), "<Portalgun> SHIFT+LEFTCLICK to close both portals (or wait 40sec until it removes it self)")
|
||||
end
|
||||
if meta.mode==nil then meta.mode=2 end
|
||||
meta.mode=mode
|
||||
item.name="portalgun:gun"..mode
|
||||
item.metadata=minetest.serialize(meta)
|
||||
itemstack:replace(item)
|
||||
minetest.sound_play("portalgun_mode", {pos=user:get_pos(),max_hear_distance = 5, gain = 1})
|
||||
end
|
||||
|
||||
local function rnd(r)
|
||||
return math.floor(r+ 0.5)
|
||||
end
|
||||
|
||||
function portalgun_onuse(itemstack, user, pointed_thing) -- using the gun
|
||||
function portalgun_onuse(itemstack, user, pointed_thing, mode) -- using the gun
|
||||
|
||||
if pointed_thing.type=="object" then
|
||||
portalgun_gravity(itemstack, user, pointed_thing)
|
||||
@ -477,14 +392,6 @@ function portalgun_onuse(itemstack, user, pointed_thing) -- using the gun
|
||||
local exist=0
|
||||
|
||||
local item=itemstack:to_table()
|
||||
local mode=minetest.deserialize(item["metadata"])
|
||||
if mode==nil then
|
||||
portalgun_mode(itemstack, user, pointed_thing)
|
||||
return itemstack
|
||||
else
|
||||
mode=mode.mode
|
||||
end
|
||||
|
||||
local ob={}
|
||||
ob.project=1
|
||||
ob.lifelime=portalgun_lifelime
|
||||
|
29
other.lua
29
other.lua
@ -36,7 +36,34 @@ minetest.register_node("portalgun:cplps1", {
|
||||
}}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_node("portalgun:cplps3", {
|
||||
description = "Close player portal when player is near",
|
||||
tiles = {"portalgun_gray.png"},
|
||||
groups = {snappy = 3, not_in_creative_inventory=0},
|
||||
sounds = stone_sounds,
|
||||
is_ground_content = false,
|
||||
--every 2 seconds, check if player is near and close portal if so
|
||||
on_timer = function (pos, elapsed)
|
||||
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 4)) do
|
||||
if ob and ob:is_player() then
|
||||
minetest.sound_play("portalgun_close", {pos=pos, gain=1.0, max_hear_distance = 10,})
|
||||
portal_delete(ob:get_player_name(),0)
|
||||
end
|
||||
--destroy Weighted storage cubes
|
||||
--if name starts with '''portalgun:wsc'''
|
||||
if ob and ob:get_luaentity() and ob:get_luaentity().name and string.sub(ob:get_luaentity().name,1,13) == "portalgun:wsc" then
|
||||
ob:remove()
|
||||
end
|
||||
end
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
timer:start(2)
|
||||
return true
|
||||
end,
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
timer:start(2)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("portalgun:cplps2", {
|
||||
description = "Close player portal",
|
||||
|
@ -17,7 +17,6 @@ minetest.register_node("portalgun:powerballspawner", {
|
||||
sounds = glass_sounds,
|
||||
is_ground_content = false,
|
||||
paramtype2 = "facedir",
|
||||
on_place = minetest.rotate_node,
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(10)
|
||||
end,
|
||||
@ -28,8 +27,9 @@ minetest.register_node("portalgun:powerballspawner", {
|
||||
elseif dir==1 then v.x=-1
|
||||
elseif dir==2 then v.z=1
|
||||
elseif dir==3 then v.x=1
|
||||
elseif dir==8 then v.y=-1
|
||||
elseif dir==5 then v.y=-1
|
||||
elseif dir==4 then v.y=1
|
||||
else v.y = -1
|
||||
end
|
||||
local pv={x=pos.x+v.x, y=pos.y+v.y, z=pos.z+v.z}
|
||||
portalgun.new=1
|
||||
@ -121,6 +121,7 @@ on_step= function(self, dtime)
|
||||
if nname=="portalgun:powerballtarget" and mesecon then
|
||||
mesecon.receptor_on(nextn)
|
||||
minetest.get_node_timer(nextn):start(5)
|
||||
self.object:remove()
|
||||
end
|
||||
self.object:set_velocity({x=v.x*-1, y=v.y*-1, z=v.z*-1})
|
||||
minetest.sound_play("portalgun_powerballbonce", {pos=pos,max_hear_distance = 10, gain = 1})
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
37
stuff.lua
37
stuff.lua
@ -94,7 +94,7 @@ end
|
||||
|
||||
minetest.register_node("portalgun:turretgun2", {
|
||||
description = "Sentry turret",
|
||||
groups = {cracky=3,not_in_creative_inventory=1},
|
||||
groups = {oddly_breakable_by_hand=1,not_in_creative_inventory=1},
|
||||
drop="portalgun:turretgun",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
@ -160,7 +160,7 @@ minetest.register_node("portalgun:turretgun2", {
|
||||
|
||||
minetest.register_node("portalgun:turretgun", {
|
||||
description = "Sentry turret",
|
||||
groups = {cracky=3},
|
||||
groups = {oddly_breakable_by_hand=1},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
@ -226,12 +226,12 @@ minetest.register_chatcommand("giveitems", {
|
||||
func = function(name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player then
|
||||
--give all items that dont have not_in_creative_inventory=1
|
||||
for i,v in pairs(minetest.registered_items) do
|
||||
if v.not_in_creative_inventory==nil or v.not_in_creative_inventory==0 then
|
||||
player:get_inventory():add_item("main",i.." 1")
|
||||
end
|
||||
end
|
||||
--clear inventory
|
||||
player:get_inventory():set_list("main", {})
|
||||
--GIVE turret
|
||||
player:get_inventory():add_item("main", "portalgun:turretgun")
|
||||
--give testblock
|
||||
player:get_inventory():add_item("main", "portalgun:testblock")
|
||||
end
|
||||
end,
|
||||
})
|
||||
@ -304,7 +304,25 @@ minetest.register_node("portalgun:toxwater_2", {
|
||||
post_effect_color = {a = 200, r = 119, g = 70, b = 16},
|
||||
groups = {water = 3, liquid = 3, not_in_creative_inventory = 1}
|
||||
})
|
||||
|
||||
minetest.register_tool("portalgun:pick", {
|
||||
--a pickaxe that can mine all blocks
|
||||
description = "Portalgun Pickaxe",
|
||||
inventory_image = "portalgun_pick.png",
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 1.0,
|
||||
max_drop_level = 3,
|
||||
groupcaps = {
|
||||
unbreakable = {times={[1]=1, [2]=1, [3]=1}, uses=0, maxlevel=3},
|
||||
fleshy = {times={[1]=1, [2]=1, [3]=1}, uses=0, maxlevel=3},
|
||||
choppy = {times={[1]=1, [2]=1, [3]=1}, uses=0, maxlevel=3},
|
||||
bendy = {times={[1]=1, [2]=1, [3]=1}, uses=0, maxlevel=3},
|
||||
cracky = {times={[1]=1, [2]=1, [3]=1}, uses=0, maxlevel=3},
|
||||
crumbly = {times={[1]=1, [2]=1, [3]=1}, uses=0, maxlevel=3},
|
||||
snappy = {times={[1]=1, [2]=1, [3]=1}, uses=0, maxlevel=3},
|
||||
},
|
||||
damage_groups = {fleshy = 1000},
|
||||
},
|
||||
})
|
||||
minetest.register_tool("portalgun:ed", {
|
||||
description = "Entity Destroyer",
|
||||
inventory_image = "portalgun_edestroyer.png",
|
||||
@ -529,7 +547,6 @@ minetest.register_entity("portalgun:bullet1",{
|
||||
mesh = "bullet.obj",
|
||||
--yellow color as tiles
|
||||
tiles = {"#color[yellow]"},
|
||||
visual_size = {x=0.1, y=0.1},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
portalgun=2,
|
||||
bullet=1,
|
||||
|
BIN
textures/portalgun_pick.png
Normal file
BIN
textures/portalgun_pick.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 293 B |
Loading…
Reference in New Issue
Block a user