my first changes
This commit is contained in:
230
init.lua
230
init.lua
@@ -4,7 +4,6 @@ proportal_group_only = false
|
||||
|
||||
portalgun={new=0,checkpoints={}}
|
||||
dofile(minetest.get_modpath("portalgun") .. "/gravityuse.lua") -- the gravity part of portalgun
|
||||
dofile(minetest.get_modpath("portalgun") .. "/craft.lua")
|
||||
dofile(minetest.get_modpath("portalgun") .. "/stuff.lua") -- security cam
|
||||
if disable_portal_stuff==false and minetest.get_modpath("mesecons")~=nil then
|
||||
dofile(minetest.get_modpath("portalgun") .. "/weightedstoragecube.lua") -- weighted storage cube
|
||||
@@ -58,7 +57,6 @@ function portal_delete(name,n) -- using set_hp & :punch instand of :remove ... n
|
||||
end
|
||||
portalgun_portal[name].portal1_active=false
|
||||
portalgun_portal[name].portal1:set_hp(0)
|
||||
portalgun_portal[name].portal1:punch(portalgun_portal[name].portal1, {full_punch_interval=1.0,damage_groups={fleshy=9000}}, "default:bronze_pick", nil)
|
||||
end
|
||||
if (n==2 or n==0) and portalgun_portal[name].portal2~=nil then
|
||||
if n==0 then
|
||||
@@ -67,7 +65,6 @@ function portal_delete(name,n) -- using set_hp & :punch instand of :remove ... n
|
||||
end
|
||||
portalgun_portal[name].portal2_active=false
|
||||
portalgun_portal[name].portal2:set_hp(0)
|
||||
portalgun_portal[name].portal2:punch(portalgun_portal[name].portal2, {full_punch_interval=1.0,damage_groups={fleshy=9000}}, "default:bronze_pick", nil)
|
||||
end
|
||||
if n==0 then portalgun_portal[name]=nil end
|
||||
end
|
||||
@@ -340,157 +337,85 @@ on_activate= function(self, staticdata)
|
||||
end,
|
||||
on_step=portalgun_on_step,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_node("portalgun:gun1", {
|
||||
description = "Portalgun (blue)",
|
||||
range = 5,
|
||||
tiles={"portalgun_gun1.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.3, -0.5, -0.3, 0.3, -0.1,0.3},
|
||||
}
|
||||
},
|
||||
drawtype="mesh",
|
||||
mesh="portalgun_gun_wearing.obj",
|
||||
groups = {not_in_creative_inventory=1},
|
||||
sunlight_propagates = true,
|
||||
paramtype="light",
|
||||
paramtype2="facedir",
|
||||
on_place=function(itemstack, user, pointed_thing)
|
||||
portalgun_mode(itemstack, user, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
portalgun_onuse(itemstack, user, pointed_thing)
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
minetest.register_node("portalgun:gun2", {
|
||||
description = "Portalgun (orange)",
|
||||
range = 5,
|
||||
tiles={"portalgun_gun2.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.3, -0.5, -0.3, 0.3, -0.1,0.3},
|
||||
}
|
||||
},
|
||||
drawtype="mesh",
|
||||
mesh="portalgun_gun_wearing.obj",
|
||||
groups = {not_in_creative_inventory=1},
|
||||
sunlight_propagates = true,
|
||||
paramtype="light",
|
||||
paramtype2="facedir",
|
||||
on_place=function(itemstack, user, pointed_thing)
|
||||
portalgun_mode(itemstack, user, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
portalgun_onuse(itemstack, user, pointed_thing)
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("portalgun:gun", {
|
||||
minetest.register_craftitem("portalgun:gun", {
|
||||
description = "Portalgun",
|
||||
range = 5,
|
||||
tiles={"portalgun_gun0.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.3, -0.5, -0.3, 0.3, -0.1,0.3},
|
||||
}
|
||||
range = 100,
|
||||
inventory_image = "portalgun_gun0_rndr.png",
|
||||
wield_image = "portalgun_gun0_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},
|
||||
},
|
||||
drawtype="mesh",
|
||||
mesh="portalgun_gun_wearing.obj",
|
||||
sunlight_propagates = true,
|
||||
paramtype="light",
|
||||
paramtype2="facedir",
|
||||
on_place=function(itemstack, user, pointed_thing)
|
||||
portalgun_mode(itemstack, user, pointed_thing)
|
||||
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: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_node("portalgun:gun1_placed", {
|
||||
description = "Portalgun (blue)",
|
||||
range = 5,
|
||||
tiles={"portalgun_gun1.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.3, -0.5, -0.3, 0.3, -0.1,0.3},
|
||||
}
|
||||
},
|
||||
drawtype="mesh",
|
||||
mesh="portalgun_gun.obj",
|
||||
sunlight_propagates = true,
|
||||
paramtype="light",
|
||||
paramtype2="facedir",
|
||||
visual_scale=0.4,
|
||||
groups = {not_in_creative_inventory=1,dig_immediate = 3},
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
portalgun_onuse(itemstack, user, pointed_thing)
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
minetest.register_node("portalgun:gun2_placed", {
|
||||
minetest.register_craftitem("portalgun:gun2", {
|
||||
description = "Portalgun (orange)",
|
||||
range = 5,
|
||||
tiles={"portalgun_gun2.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.3, -0.5, -0.3, 0.3, -0.1,0.3},
|
||||
}
|
||||
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},
|
||||
},
|
||||
drawtype="mesh",
|
||||
mesh="portalgun_gun.obj",
|
||||
sunlight_propagates = true,
|
||||
paramtype="light",
|
||||
paramtype2="facedir",
|
||||
visual_scale=0.4,
|
||||
groups = {not_in_creative_inventory=1,dig_immediate = 3},
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
portalgun_onuse(itemstack, user, pointed_thing)
|
||||
return itemstack
|
||||
end
|
||||
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
|
||||
})
|
||||
|
||||
minetest.register_node("portalgun:gun_placed", {
|
||||
description = "Portalgun",
|
||||
range = 5,
|
||||
tiles={"portalgun_gun0.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.3, -0.5, -0.3, 0.3, -0.1,0.3},
|
||||
}
|
||||
},
|
||||
drawtype="mesh",
|
||||
mesh="portalgun_gun.obj",
|
||||
sunlight_propagates = true,
|
||||
paramtype="light",
|
||||
paramtype2="facedir",
|
||||
visual_scale=0.4,
|
||||
groups = {not_in_creative_inventory=1,dig_immediate = 3},
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
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"])
|
||||
@@ -516,6 +441,23 @@ function portalgun_mode(itemstack, user, pointed_thing) -- change modes
|
||||
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)
|
||||
@@ -558,12 +500,6 @@ function portalgun_onuse(itemstack, user, pointed_thing) -- using the gun
|
||||
portalgun_portal[name]={lifelime=portalgun_lifelime,project=1,timer=0,portal1_active=false,portal2_active=false,portal1_use=0,portal2_use=0}
|
||||
end
|
||||
|
||||
if key.RMB and mode==2 then -- hold rmbutton to use the other one (like diplazer)
|
||||
mode=1
|
||||
elseif key.RMB and mode==1 then
|
||||
mode=2
|
||||
end
|
||||
|
||||
if key.sneak then
|
||||
portal_delete(name,0)
|
||||
return itemstack
|
||||
|
Reference in New Issue
Block a user