initial stargate code
authorRealBadAngel <mk@realbadangel.pl>
Sun, 10 Mar 2013 17:36:40 +0000 (18:36 +0100)
committerRealBadAngel <mk@realbadangel.pl>
Sun, 10 Mar 2013 17:37:29 +0000 (18:37 +0100)
41 files changed:
stargate/depends.txt [new file with mode: 0644]
stargate/gate_defs.lua [new file with mode: 0644]
stargate/init.lua [new file with mode: 0644]
stargate/io.lua [new file with mode: 0644]
stargate/sounds/click.ogg [new file with mode: 0644]
stargate/sounds/gate_activate.ogg [new file with mode: 0644]
stargate/sounds/stargatetheme.ogg [new file with mode: 0644]
stargate/stargate_gui.lua [new file with mode: 0644]
stargate/textures/dot_icon.png [new file with mode: 0644]
stargate/textures/down1.png [new file with mode: 0644]
stargate/textures/down1_off.png [new file with mode: 0644]
stargate/textures/down2.png [new file with mode: 0644]
stargate/textures/down2_off.png [new file with mode: 0644]
stargate/textures/down3.png [new file with mode: 0644]
stargate/textures/down3_off.png [new file with mode: 0644]
stargate/textures/mid1.png [new file with mode: 0644]
stargate/textures/mid1_off.png [new file with mode: 0644]
stargate/textures/mid2.png [new file with mode: 0644]
stargate/textures/mid2_off.png [new file with mode: 0644]
stargate/textures/mid3.png [new file with mode: 0644]
stargate/textures/mid3_off.png [new file with mode: 0644]
stargate/textures/ok_icon.png [new file with mode: 0644]
stargate/textures/ok_ikon.png [new file with mode: 0644]
stargate/textures/pencil_icon.png [new file with mode: 0644]
stargate/textures/st1.png [new file with mode: 0644]
stargate/textures/st2.png [new file with mode: 0644]
stargate/textures/st3.png [new file with mode: 0644]
stargate/textures/st_all.xcf [new file with mode: 0644]
stargate/textures/stargate.png [new file with mode: 0644]
stargate/textures/static.xcf [new file with mode: 0644]
stargate/textures/tick_ok_sign_4190.jpg [new file with mode: 0644]
stargate/textures/toggle_icon.png [new file with mode: 0644]
stargate/textures/up1.png [new file with mode: 0644]
stargate/textures/up1_off.png [new file with mode: 0644]
stargate/textures/up1r.png [new file with mode: 0644]
stargate/textures/up2.png [new file with mode: 0644]
stargate/textures/up2_off.png [new file with mode: 0644]
stargate/textures/up3.png [new file with mode: 0644]
stargate/textures/up3_off.png [new file with mode: 0644]
technic/concrete.lua
technic/ores.lua

diff --git a/stargate/depends.txt b/stargate/depends.txt
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/stargate/gate_defs.lua b/stargate/gate_defs.lua
new file mode 100644 (file)
index 0000000..57189d5
--- /dev/null
@@ -0,0 +1,470 @@
+function swap_gate_node(pos,name,dir)
+       local node = minetest.env:get_node(pos)
+       local meta = minetest.env:get_meta(pos)
+       local meta0 = meta:to_table()
+       node.name = name
+       node.param1=0
+       node.param2=dir
+       minetest.env:set_node(pos,node)
+       meta=minetest.env:get_meta(pos)
+       meta:from_table(meta0)
+end
+
+function getDir (player)
+       local dir=player:get_look_dir()
+       if math.abs(dir.x)>math.abs(dir.z) then 
+               if dir.x>0 then return 0 end
+               return 1
+       end
+       if dir.z>0 then return 2 end
+       return 3
+end
+
+function checkNode (pos)
+       local node=minetest.env:get_node(pos)
+       if node.name == "air" then return 0 end
+       return 1
+end
+
+function addGateNode (gateNodes,i,pos)
+gateNodes[i].pos.x=pos.x
+gateNodes[i].pos.y=pos.y
+gateNodes[i].pos.z=pos.z
+end
+
+function placeGate (player,pos)
+       local player_name=player:get_player_name()
+       local dir=minetest.dir_to_facedir(player:get_look_dir())
+       local pos1=pos
+       local gateNodes={}
+       for i=1,9,1 do
+               gateNodes[i]={}
+               gateNodes[i].pos={}
+       end
+       if dir==1 then 
+                       addGateNode(gateNodes,1,pos1)
+                       pos1.z=pos1.z+1
+                       addGateNode(gateNodes,2,pos1)
+                       pos1.z=pos1.z-2
+                       addGateNode(gateNodes,3,pos1)
+                       pos1.z=pos1.z+1
+                       pos1.y=pos1.y+1
+                       addGateNode(gateNodes,4,pos1)
+                       pos1.z=pos1.z+1
+                       addGateNode(gateNodes,5,pos1)
+                       pos1.z=pos1.z-2
+                       addGateNode(gateNodes,6,pos1)
+                       pos1.z=pos1.z+1
+                       pos1.y=pos1.y+1
+                       addGateNode(gateNodes,7,pos1)
+                       pos1.z=pos1.z+1
+                       addGateNode(gateNodes,8,pos1)
+                       pos1.z=pos1.z-2
+                       addGateNode(gateNodes,9,pos1)
+       end
+       if dir==3 then 
+                       addGateNode(gateNodes,1,pos1)
+                       pos1.z=pos1.z+1
+                       addGateNode(gateNodes,3,pos1)
+                       pos1.z=pos1.z-2
+                       addGateNode(gateNodes,2,pos1)
+                       pos1.z=pos1.z+1
+                       pos1.y=pos1.y+1
+                       addGateNode(gateNodes,4,pos1)
+                       pos1.z=pos1.z+1
+                       addGateNode(gateNodes,6,pos1)
+                       pos1.z=pos1.z-2
+                       addGateNode(gateNodes,5,pos1)
+                       pos1.z=pos1.z+1
+                       pos1.y=pos1.y+1
+                       addGateNode(gateNodes,7,pos1)
+                       pos1.z=pos1.z+1
+                       addGateNode(gateNodes,9,pos1)
+                       pos1.z=pos1.z-2
+                       addGateNode(gateNodes,8,pos1)
+       end
+       if dir==2 then  
+                       addGateNode(gateNodes,1,pos1)
+                       pos1.x=pos1.x+1
+                       addGateNode(gateNodes,2,pos1)
+                       pos1.x=pos1.x-2
+                       addGateNode(gateNodes,3,pos1)
+                       pos1.x=pos1.x+1
+                       pos1.y=pos1.y+1
+                       addGateNode(gateNodes,4,pos1)
+                       pos1.x=pos1.x+1
+                       addGateNode(gateNodes,5,pos1)
+                       pos1.x=pos1.x-2
+                       addGateNode(gateNodes,6,pos1)
+                       pos1.x=pos1.x+1
+                       pos1.y=pos1.y+1
+                       addGateNode(gateNodes,7,pos1)
+                       pos1.x=pos1.x+1
+                       addGateNode(gateNodes,8,pos1)
+                       pos1.x=pos1.x-2
+                       addGateNode(gateNodes,9,pos1)
+                       end
+       if dir==0 then  
+                       addGateNode(gateNodes,1,pos1)
+                       pos1.x=pos1.x+1
+                       addGateNode(gateNodes,3,pos1)
+                       pos1.x=pos1.x-2
+                       addGateNode(gateNodes,2,pos1)
+                       pos1.x=pos1.x+1
+                       pos1.y=pos1.y+1
+                       addGateNode(gateNodes,4,pos1)
+                       pos1.x=pos1.x+1
+                       addGateNode(gateNodes,6,pos1)
+                       pos1.x=pos1.x-2
+                       addGateNode(gateNodes,5,pos1)
+                       pos1.x=pos1.x+1
+                       pos1.y=pos1.y+1
+                       addGateNode(gateNodes,7,pos1)
+                       pos1.x=pos1.x+1
+                       addGateNode(gateNodes,9,pos1)
+                       pos1.x=pos1.x-2
+                       addGateNode(gateNodes,8,pos1)
+                       end
+       for i=1,9,1 do
+               local node=minetest.env:get_node(gateNodes[i].pos)
+               if node.name ~= "air" then return false end
+       end
+       minetest.env:set_node(gateNodes[1].pos,{name="stargate:gatenode8_off", param1=0, param2=dir})
+       minetest.env:set_node(gateNodes[2].pos,{name="stargate:gatenode7_off", param1=0, param2=dir})
+       minetest.env:set_node(gateNodes[3].pos,{name="stargate:gatenode9_off", param1=0, param2=dir})
+       minetest.env:set_node(gateNodes[4].pos,{name="stargate:gatenode5_off", param1=0, param2=dir})
+       minetest.env:set_node(gateNodes[5].pos,{name="stargate:gatenode4_off", param1=0, param2=dir})
+       minetest.env:set_node(gateNodes[6].pos,{name="stargate:gatenode6_off", param1=0, param2=dir})
+       minetest.env:set_node(gateNodes[7].pos,{name="stargate:gatenode2_off", param1=0, param2=dir})
+       minetest.env:set_node(gateNodes[8].pos,{name="stargate:gatenode1_off", param1=0, param2=dir})
+       minetest.env:set_node(gateNodes[9].pos,{name="stargate:gatenode3_off", param1=0, param2=dir})
+       local meta = minetest.env:get_meta(gateNodes[1].pos)
+       meta:set_string("infotext", "Stargate inactive\nOwned by: "..player_name)
+       meta:set_string("gateNodes",minetest.serialize(gateNodes))
+       meta:set_int("gateActive",0)
+       meta:set_string("owner",player_name)
+       stargate.registerGate(player_name,gateNodes[1].pos)
+       return true
+end
+
+function removeGate (pos)
+       local meta = minetest.env:get_meta(pos)
+       local player_name=meta:get_string("owner")
+       local gateNodes=minetest.deserialize(meta:get_string("gateNodes"))
+       for i=2,9,1 do
+               minetest.env:remove_node(gateNodes[i].pos)
+       end
+       stargate.unregisterGate(player_name,gateNodes[1].pos)
+end
+
+function activateGate (player,pos)
+       local node = minetest.env:get_node(pos)
+       local dir=node.param2
+       local meta = minetest.env:get_meta(pos)
+       local gateNodes=minetest.deserialize(meta:get_string("gateNodes"))
+       meta:set_int("gateActive",1)
+       meta:set_string("infotext", "Stargate active")
+       minetest.sound_play("gate_activate", {pos = pos, gain = 1.0,loop = false, max_hear_distance = 72,})
+       swap_gate_node(gateNodes[1].pos,"stargate:gatenode8",dir)
+       swap_gate_node(gateNodes[2].pos,"stargate:gatenode7",dir)
+       swap_gate_node(gateNodes[3].pos,"stargate:gatenode9",dir)
+       swap_gate_node(gateNodes[4].pos,"stargate:gatenode5",dir)
+       swap_gate_node(gateNodes[5].pos,"stargate:gatenode4",dir)
+       swap_gate_node(gateNodes[6].pos,"stargate:gatenode6",dir)
+       swap_gate_node(gateNodes[7].pos,"stargate:gatenode2",dir)
+       swap_gate_node(gateNodes[8].pos,"stargate:gatenode1",dir)
+       swap_gate_node(gateNodes[9].pos,"stargate:gatenode3",dir)
+end
+
+function deactivateGate (player,pos)
+       local node = minetest.env:get_node(pos)
+       local dir=node.param2
+       local meta = minetest.env:get_meta(pos)
+       local gateNodes=minetest.deserialize(meta:get_string("gateNodes"))
+       meta:set_int("gateActive",0)
+       meta:set_string("infotext", "Stargate inactive")
+       swap_gate_node(gateNodes[1].pos,"stargate:gatenode8_off",dir)
+       swap_gate_node(gateNodes[2].pos,"stargate:gatenode7_off",dir)
+       swap_gate_node(gateNodes[3].pos,"stargate:gatenode9_off",dir)
+       swap_gate_node(gateNodes[4].pos,"stargate:gatenode5_off",dir)
+       swap_gate_node(gateNodes[5].pos,"stargate:gatenode4_off",dir)
+       swap_gate_node(gateNodes[6].pos,"stargate:gatenode6_off",dir)
+       swap_gate_node(gateNodes[7].pos,"stargate:gatenode2_off",dir)
+       swap_gate_node(gateNodes[8].pos,"stargate:gatenode1_off",dir)
+       swap_gate_node(gateNodes[9].pos,"stargate:gatenode3_off",dir)
+end
+
+gateCanDig = function(pos,player)
+       local player_name = player:get_player_name()
+       local meta = minetest.env:get_meta(pos)
+       local owner=meta:get_string("owner")
+       if player_name==owner then return true
+       else return false end
+end
+
+sg_selection_box = {
+       type = "fixed",
+       fixed={{-1.5,-0.5,-1/20,1.5,2.5,1/20},},
+               }
+sg_selection_box_empty = {
+       type = "fixed",
+       fixed={},
+               }
+sg_node_box = {
+       type = "fixed",
+       fixed={{-.5,-.5,0,.5,.5,0},},
+               }
+sg_groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1}
+sg_groups1 = {snappy=2,choppy=2,oddly_breakable_by_hand=2}
+
+minetest.register_node("stargate:gatenode1",{
+       description = "up1",
+       tiles = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png",
+               {name="up3.png",animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},},
+               {name="up1.png",animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},}},
+       groups = sg_groups,
+       paramtype2 = "facedir",
+       paramtype = "light",
+       light_source = 10,
+       drawtype = "nodebox",
+       selection_box = sg_selection_box_empty,
+       node_box=sg_node_box,
+})
+minetest.register_node("stargate:gatenode2",{
+       description = "up2",
+       tiles = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png",
+               {name="up2.png",animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},},
+               {name="up2.png",animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},}},
+       groups = sg_groups,
+       paramtype2 = "facedir",
+       paramtype = "light",
+       light_source = 10,
+       drawtype = "nodebox",
+       selection_box = sg_selection_box_empty,
+       node_box=sg_node_box,
+})
+
+minetest.register_node("stargate:gatenode3",{
+       description = "up3",
+       tiles = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png",
+               {name="up1.png",animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},},
+               {name="up3.png",animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},}},
+       groups = sg_groups,
+       paramtype2 = "facedir",
+       paramtype = "light",
+       light_source = 10,
+       drawtype = "nodebox",
+       selection_box = sg_selection_box_empty,
+       node_box=sg_node_box,
+})
+
+minetest.register_node("stargate:gatenode4",{
+       description = "mid1",
+       tiles = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png",
+               {name="mid3.png",animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},},
+               {name="mid1.png",animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},}},
+       groups = sg_groups,
+       paramtype2 = "facedir",
+       paramtype = "light",
+       light_source = 10,
+       drawtype = "nodebox",
+       selection_box = sg_selection_box_empty,
+       node_box=sg_node_box,
+})
+minetest.register_node("stargate:gatenode5",{
+       description = "mid2",
+       tiles = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png",
+               {name="mid2.png",animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},},
+               {name="mid2.png",animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},}},
+       groups = sg_groups,
+       paramtype2 = "facedir",
+       paramtype = "light",
+       light_source = 10,
+       drawtype = "nodebox",
+       selection_box = sg_selection_box_empty,
+       node_box=sg_node_box,
+})
+
+minetest.register_node("stargate:gatenode6",{
+       description = "mid3",
+       tiles = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png",
+               {name="mid1.png",animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},},
+               {name="mid3.png",animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},}},
+       groups = sg_groups,
+       paramtype2 = "facedir",
+       paramtype = "light",
+       light_source = 10,
+       drawtype = "nodebox",
+       selection_box = sg_selection_box_empty,
+       node_box=sg_node_box,
+})
+
+minetest.register_node("stargate:gatenode7",{
+       description = "down1",
+       tiles = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png",
+               {name="down3.png",animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},},
+               {name="down1.png",animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},}},
+       groups = sg_groups,
+       paramtype2 = "facedir",
+       paramtype = "light",
+       light_source = 10,
+       drawtype = "nodebox",
+       selection_box = sg_selection_box_empty,
+       node_box=sg_node_box,
+})
+
+minetest.register_node("stargate:gatenode8",{
+       description = "down2",
+       tiles = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png",
+               {name="down2.png",animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},},
+               {name="down2.png",animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},}},
+       groups = sg_groups,
+       drop="stargate:gatenode8_off",
+       paramtype2 = "facedir",
+       paramtype = "light",
+       light_source = 10,
+       drawtype = "nodebox",
+       selection_box = sg_selection_box,
+       node_box=sg_node_box,
+       can_dig = gateCanDig,
+       on_destruct = function (pos)
+       removeGate(pos)
+       end,
+})
+
+minetest.register_node("stargate:gatenode9",{
+       description = "down3",
+       tiles = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png",
+               {name="down1.png",animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},},
+               {name="down3.png",animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},}},
+       groups = sg_groups,
+       paramtype2 = "facedir",
+       paramtype = "light",
+       light_source = 10,
+       drawtype = "nodebox",
+       selection_box = sg_selection_box_empty,
+       node_box=sg_node_box,
+})
+
+minetest.register_node("stargate:gatenode1_off",{
+       description = "up1_off",
+       tiles = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png",
+               "up3_off.png","up1_off.png"},
+       groups = sg_groups,
+       paramtype2 = "facedir",
+       paramtype = "light",
+       drawtype = "nodebox",
+       selection_box = sg_selection_box_empty,
+       node_box=sg_node_box,
+})
+minetest.register_node("stargate:gatenode2_off",{
+       description = "up2_off",
+       tiles = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png",
+               "up2_off.png","up2_off.png"},
+       groups = sg_groups,
+       paramtype2 = "facedir",
+       paramtype = "light",
+       drawtype = "nodebox",
+       selection_box = sg_selection_box_empty,
+       node_box=sg_node_box,
+})
+
+minetest.register_node("stargate:gatenode3_off",{
+       description = "up3_off",
+       tiles = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png",
+               "up1_off.png","up3_off.png"},
+       groups = sg_groups,
+       paramtype2 = "facedir",
+       paramtype = "light",
+       drawtype = "nodebox",
+       selection_box = sg_selection_box_empty,
+       node_box=sg_node_box,
+})
+
+minetest.register_node("stargate:gatenode4_off",{
+       description = "mid1_off",
+       tiles = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png",
+               "mid3_off.png","mid1_off.png"},
+       groups = sg_groups,
+       paramtype2 = "facedir",
+       paramtype = "light",
+       drawtype = "nodebox",
+       selection_box = sg_selection_box_empty,
+       node_box=sg_node_box,
+})
+minetest.register_node("stargate:gatenode5_off",{
+       description = "mid2_off",
+       tiles = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png",
+               "mid2_off.png","mid2_off.png"},
+       groups = sg_groups,
+       paramtype2 = "facedir",
+       paramtype = "light",
+       drawtype = "nodebox",
+       selection_box = sg_selection_box_empty,
+       node_box=sg_node_box,
+})
+
+minetest.register_node("stargate:gatenode6_off",{
+       description = "mid3_off",
+       tiles = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png",
+               "mid1_off.png","mid3_off.png"},
+       groups = sg_groups,
+       paramtype2 = "facedir",
+       paramtype = "light",
+       drawtype = "nodebox",
+       selection_box = sg_selection_box_empty,
+       node_box=sg_node_box,
+})
+
+minetest.register_node("stargate:gatenode7_off",{
+       description = "down1_off",
+       tiles = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png",
+               "down3_off.png","down1_off.png"},
+       groups = sg_groups,
+       paramtype2 = "facedir",
+       paramtype = "light",
+       drawtype = "nodebox",
+       selection_box = sg_selection_box_empty,
+       node_box=sg_node_box,
+})
+
+--main gate node
+minetest.register_node("stargate:gatenode8_off",{
+       description = "Stargate",
+       inventory_image = "stargate.png",
+       wield_image = "stargate.png",
+       tiles = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png",
+               "down2_off.png","down2_off.png"},
+       groups = sg_groups1,
+       paramtype2 = "facedir",
+       paramtype = "light",
+       drawtype = "nodebox",
+       selection_box = sg_selection_box,
+       node_box=sg_node_box,
+       can_dig = gateCanDig,
+       on_destruct = function (pos)
+               removeGate(pos)
+       end,
+       on_place = function(itemstack, placer, pointed_thing)
+               local pos = pointed_thing.above
+               if placeGate(placer,pos)==true then 
+                       itemstack:take_item(1)
+                       return itemstack
+               else
+                       return
+               end
+       end,
+       on_rightclick=stargate.gateFormspecHandler,
+})
+
+minetest.register_node("stargate:gatenode9_off",{
+       description = "down3_off",
+       tiles = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png",
+               "down1_off.png","down3_off.png"},
+       groups = sg_groups,
+       paramtype2 = "facedir",
+       paramtype = "light",
+       drawtype = "nodebox",
+       selection_box = sg_selection_box_empty,
+       node_box=sg_node_box,
+})
diff --git a/stargate/init.lua b/stargate/init.lua
new file mode 100644 (file)
index 0000000..3f09cc2
--- /dev/null
@@ -0,0 +1,9 @@
+-- Minetest 0.4.5 : stargate
+
+--data tables definitions
+stargate={}
+stargate_network = {}
+
+modpath=minetest.get_modpath("stargate")
+dofile(modpath.."/stargate_gui.lua")
+dofile(modpath.."/gate_defs.lua")
diff --git a/stargate/io.lua b/stargate/io.lua
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/stargate/sounds/click.ogg b/stargate/sounds/click.ogg
new file mode 100644 (file)
index 0000000..3db63a0
Binary files /dev/null and b/stargate/sounds/click.ogg differ
diff --git a/stargate/sounds/gate_activate.ogg b/stargate/sounds/gate_activate.ogg
new file mode 100644 (file)
index 0000000..4725f23
Binary files /dev/null and b/stargate/sounds/gate_activate.ogg differ
diff --git a/stargate/sounds/stargatetheme.ogg b/stargate/sounds/stargatetheme.ogg
new file mode 100644 (file)
index 0000000..52dd016
Binary files /dev/null and b/stargate/sounds/stargatetheme.ogg differ
diff --git a/stargate/stargate_gui.lua b/stargate/stargate_gui.lua
new file mode 100644 (file)
index 0000000..93357d1
--- /dev/null
@@ -0,0 +1,198 @@
+-- default GUI page
+stargate.default_page = "main"
+stargate.players={}
+stargate.current_page={}
+
+stargate.save_data = function()
+       local data = minetest.serialize( stargate_network )
+       local path = minetest.get_worldpath().."/mod_stargate.data"
+       local file = io.open( path, "w" )
+       if( file ) then
+               file:write( data )
+               file:close()
+               return true
+       else return nil
+       end
+end
+
+stargate.restore_data = function()
+       local path = minetest.get_worldpath().."/mod_stargate.data"
+       local file = io.open( path, "r" )
+       if( file ) then
+               local data = file:read("*all")
+               stargate_network = minetest.deserialize( data )
+               file:close()
+       return true
+       else return nil
+       end
+end
+
+-- load Stargates network data
+if stargate.restore_data()==nil then
+       print ("[stargate] network data not found. Creating new file.")
+       if stargate.save_data()==nil then
+               print ("[stargate] Cannot load nor create new file!")
+               --crash or something here?
+       else
+               print ("[stargate] New data file created.")
+       end
+end
+
+-- register_on_joinplayer
+minetest.register_on_joinplayer(function(player)
+       local player_name = player:get_player_name()
+       stargate.players[player_name]={}
+       stargate.players[player_name]["formspec"]=""
+       stargate.players[player_name]["current_page"]=stargate.default_page
+       stargate.players[player_name]["own_gates"]={}
+       stargate.players[player_name]["own_gates_count"]=0
+       stargate.players[player_name]["public_gates"]={}
+       stargate.players[player_name]["public_gates_count"]=0
+end)
+
+stargate.registerGate = function(player_name,pos)
+       if stargate_network[player_name]==nil then
+               stargate_network[player_name]={}
+       end
+       local new_gate ={}
+       new_gate["pos"]=pos
+       new_gate["type"]="private"
+       new_gate["description"]=""
+       table.insert(stargate_network[player_name],new_gate)
+       if stargate.save_data()==nil then
+               print ("[stargate] Couldnt update network file!")
+       end
+end
+
+stargate.unregisterGate = function(player_name,pos)
+       for __,gates in ipairs(stargate_network[player_name]) do
+               if gates["pos"].x==pos.x and gates["pos"].y==pos.y and gates["pos"].z==pos.z then
+                       table.remove(stargate_network[player_name], __)
+                       break
+               end
+       end
+       if stargate.save_data()==nil then
+               print ("[stargate] Couldnt update network file!")
+       end
+end
+
+--show formspec to player
+stargate.gateFormspecHandler = function(pos, node, clicker, itemstack)
+       local player_name = clicker:get_player_name()
+       local meta = minetest.env:get_meta(pos)
+       local owner=meta:get_string("owner")
+       if player_name~=owner then return end
+       local current_gate=nil
+       stargate.players[player_name]["own_gates"]={}
+       stargate.players[player_name]["public_gates"]={}
+       local own_gates_count=0
+       for __,gates in ipairs(stargate_network[player_name]) do
+               if gates["pos"].x==pos.x and gates["pos"].y==pos.y and gates["pos"].z==pos.z then
+                       current_gate=gates
+               else
+               own_gates_count=own_gates_count+1
+               table.insert(stargate.players[player_name]["own_gates"],gates)
+               end
+       end
+       stargate.players[player_name]["own_gates_count"]=own_gates_count
+       if current_gate==nil then 
+               print ("Gate not registered in network! Please remove it and place once again.")
+               return nil
+       end
+       stargate.players[player_name]["current_index"]=0
+       stargate.players[player_name]["current_gate"]=current_gate
+       stargate.players[player_name]["dest_type"]="own"
+       local formspec=stargate.get_formspec(player_name,"main")
+       stargate.players[player_name]["formspec"]=formspec
+       minetest.show_formspec(player_name, "stargate:main", formspec)
+end
+
+-- get_formspec
+stargate.get_formspec = function(player_name,page)
+       if player_name==nil then return "" end
+       stargate.players[player_name]["current_page"]=page
+       local current_gate=stargate.players[player_name]["current_gate"]
+       local formspec = "size[14,10]"
+       --background
+       formspec = formspec .."background[-0.19,-0.2,;14.38,10.55;ui_form_bg.png]"
+       formspec = formspec.."label[0,0.0;Stargate]"
+       formspec = formspec.."label[0,.5;Position: ("..current_gate["pos"].x..","..current_gate["pos"].y..","..current_gate["pos"].z..")]"
+       formspec = formspec.."image_button[3.5,.6;.6,.6;toggle_icon.png;toggle_type;]"
+       formspec = formspec.."label[4,.5;Type: "..current_gate["type"].."]"
+       formspec = formspec.."image_button[6.5,.6;.6,.6;pencil_icon.png;edit_desc;]"
+       formspec = formspec.."label[0,1.1;Destination: ]"
+       formspec = formspec.."label[0,1.7;Aviable destinations:]"
+       formspec = formspec.."image_button[3.5,1.8;.6,.6;toggle_icon.png;toggle_dest_type;]"
+       formspec = formspec.."label[4,1.7;Type: "..stargate.players[player_name]["dest_type"].."]"
+
+       if page=="main" then
+       formspec = formspec.."image_button[6.5,.6;.6,.6;pencil_icon.png;edit_desc;]"
+       formspec = formspec.."label[7,.5;Description: "..current_gate["description"].."]"
+       end
+       if page=="edit_desc" then
+       formspec = formspec.."image_button[6.5,.6;.6,.6;ok_icon.png;save_desc;]"
+       formspec = formspec.."field[7.3,.7;5,1;desc_box;Edit gate description:;"..current_gate["description"].."]"
+       end
+       
+       local list_index=stargate.players[player_name]["current_index"]
+       print(dump(stargate.players[player_name]["own_gates_count"]))
+       local page=math.floor(list_index / (30) + 1)
+       local pagemax = math.floor((stargate.players[player_name]["own_gates_count"]+1) / (30) + 1)
+       for y=0,9,1 do
+       for x=0,2,1 do
+               print(dump(list_index))
+               print(dump(stargate.players[player_name]["own_gates"][list_index+1]))
+               local gate_temp=stargate.players[player_name]["own_gates"][list_index+1]
+               if gate_temp then
+                       formspec = formspec.."image_button["..(x*5)..","..(4+y*.8)..";.6,.6;dot_icon.png;list_button"..list_index..";]"
+                       formspec = formspec.."label["..(x*5+.8)..","..(4+y*.8)..";("..gate_temp["pos"].x..","..gate_temp["pos"].y..","..gate_temp["pos"].z..")]"
+               end
+               list_index=list_index+1
+       end
+       end     
+       return formspec
+end
+
+-- register_on_player_receive_fields
+minetest.register_on_player_receive_fields(function(player, formname, fields)
+       local player_name = player:get_player_name()
+       local current_gate=stargate.players[player_name]["current_gate"]
+       local formspec
+
+       if fields.toggle_type then
+               if current_gate["type"] == "private" then 
+                       current_gate["type"]="public"
+               else current_gate["type"]="private" end
+               formspec= stargate.get_formspec(player_name,"main")
+               stargate.players[player_name]["formspec"]=formspec
+               minetest.show_formspec(player_name, "stargate:main", formspec)
+               minetest.sound_play("click", {to_player=player_name, gain = 0.5})
+               return
+       end
+       if fields.toggle_dest_type then
+               if stargate.players[player_name]["dest_type"] == "all own" then 
+                       stargate.players[player_name]["dest_type"]="all public"
+               else stargate.players[player_name]["dest_type"]="all own" end
+               formspec= stargate.get_formspec(player_name,"main")
+               stargate.players[player_name]["formspec"]=formspec
+               minetest.show_formspec(player_name, "stargate:main", formspec)
+               minetest.sound_play("click", {to_player=player_name, gain = 0.5})
+               return
+       end
+       if fields.edit_desc then
+               formspec= stargate.get_formspec(player_name,"edit_desc")
+               stargate.players[player_name]["formspec"]=formspec
+               minetest.show_formspec(player_name, "stargate:main", formspec)
+               minetest.sound_play("click", {to_player=player_name, gain = 0.5})
+               return
+       end
+
+       if fields.save_desc then
+               current_gate["description"]=fields.desc_box
+               formspec= stargate.get_formspec(player_name,"main")
+               stargate.players[player_name]["formspec"]=formspec
+               minetest.show_formspec(player_name, "stargate:main", formspec)
+               minetest.sound_play("click", {to_player=player_name, gain = 0.5})
+               return
+       end
+end)
diff --git a/stargate/textures/dot_icon.png b/stargate/textures/dot_icon.png
new file mode 100644 (file)
index 0000000..e73af1a
Binary files /dev/null and b/stargate/textures/dot_icon.png differ
diff --git a/stargate/textures/down1.png b/stargate/textures/down1.png
new file mode 100644 (file)
index 0000000..a87134d
Binary files /dev/null and b/stargate/textures/down1.png differ
diff --git a/stargate/textures/down1_off.png b/stargate/textures/down1_off.png
new file mode 100644 (file)
index 0000000..9783f22
Binary files /dev/null and b/stargate/textures/down1_off.png differ
diff --git a/stargate/textures/down2.png b/stargate/textures/down2.png
new file mode 100644 (file)
index 0000000..e2b8f83
Binary files /dev/null and b/stargate/textures/down2.png differ
diff --git a/stargate/textures/down2_off.png b/stargate/textures/down2_off.png
new file mode 100644 (file)
index 0000000..7910ff6
Binary files /dev/null and b/stargate/textures/down2_off.png differ
diff --git a/stargate/textures/down3.png b/stargate/textures/down3.png
new file mode 100644 (file)
index 0000000..b6adc8c
Binary files /dev/null and b/stargate/textures/down3.png differ
diff --git a/stargate/textures/down3_off.png b/stargate/textures/down3_off.png
new file mode 100644 (file)
index 0000000..5fd8feb
Binary files /dev/null and b/stargate/textures/down3_off.png differ
diff --git a/stargate/textures/mid1.png b/stargate/textures/mid1.png
new file mode 100644 (file)
index 0000000..6cdb9ff
Binary files /dev/null and b/stargate/textures/mid1.png differ
diff --git a/stargate/textures/mid1_off.png b/stargate/textures/mid1_off.png
new file mode 100644 (file)
index 0000000..ceae50f
Binary files /dev/null and b/stargate/textures/mid1_off.png differ
diff --git a/stargate/textures/mid2.png b/stargate/textures/mid2.png
new file mode 100644 (file)
index 0000000..9167989
Binary files /dev/null and b/stargate/textures/mid2.png differ
diff --git a/stargate/textures/mid2_off.png b/stargate/textures/mid2_off.png
new file mode 100644 (file)
index 0000000..b29c3d6
Binary files /dev/null and b/stargate/textures/mid2_off.png differ
diff --git a/stargate/textures/mid3.png b/stargate/textures/mid3.png
new file mode 100644 (file)
index 0000000..1420e27
Binary files /dev/null and b/stargate/textures/mid3.png differ
diff --git a/stargate/textures/mid3_off.png b/stargate/textures/mid3_off.png
new file mode 100644 (file)
index 0000000..ae4f932
Binary files /dev/null and b/stargate/textures/mid3_off.png differ
diff --git a/stargate/textures/ok_icon.png b/stargate/textures/ok_icon.png
new file mode 100644 (file)
index 0000000..779fc3b
Binary files /dev/null and b/stargate/textures/ok_icon.png differ
diff --git a/stargate/textures/ok_ikon.png b/stargate/textures/ok_ikon.png
new file mode 100644 (file)
index 0000000..5bdff96
Binary files /dev/null and b/stargate/textures/ok_ikon.png differ
diff --git a/stargate/textures/pencil_icon.png b/stargate/textures/pencil_icon.png
new file mode 100644 (file)
index 0000000..af77c2f
Binary files /dev/null and b/stargate/textures/pencil_icon.png differ
diff --git a/stargate/textures/st1.png b/stargate/textures/st1.png
new file mode 100644 (file)
index 0000000..c7c4248
Binary files /dev/null and b/stargate/textures/st1.png differ
diff --git a/stargate/textures/st2.png b/stargate/textures/st2.png
new file mode 100644 (file)
index 0000000..c30f9ae
Binary files /dev/null and b/stargate/textures/st2.png differ
diff --git a/stargate/textures/st3.png b/stargate/textures/st3.png
new file mode 100644 (file)
index 0000000..e5464d9
Binary files /dev/null and b/stargate/textures/st3.png differ
diff --git a/stargate/textures/st_all.xcf b/stargate/textures/st_all.xcf
new file mode 100644 (file)
index 0000000..a2e4441
Binary files /dev/null and b/stargate/textures/st_all.xcf differ
diff --git a/stargate/textures/stargate.png b/stargate/textures/stargate.png
new file mode 100644 (file)
index 0000000..339c389
Binary files /dev/null and b/stargate/textures/stargate.png differ
diff --git a/stargate/textures/static.xcf b/stargate/textures/static.xcf
new file mode 100644 (file)
index 0000000..c106ab1
Binary files /dev/null and b/stargate/textures/static.xcf differ
diff --git a/stargate/textures/tick_ok_sign_4190.jpg b/stargate/textures/tick_ok_sign_4190.jpg
new file mode 100644 (file)
index 0000000..5f6c6aa
Binary files /dev/null and b/stargate/textures/tick_ok_sign_4190.jpg differ
diff --git a/stargate/textures/toggle_icon.png b/stargate/textures/toggle_icon.png
new file mode 100644 (file)
index 0000000..4792158
Binary files /dev/null and b/stargate/textures/toggle_icon.png differ
diff --git a/stargate/textures/up1.png b/stargate/textures/up1.png
new file mode 100644 (file)
index 0000000..89f47d2
Binary files /dev/null and b/stargate/textures/up1.png differ
diff --git a/stargate/textures/up1_off.png b/stargate/textures/up1_off.png
new file mode 100644 (file)
index 0000000..c4e6361
Binary files /dev/null and b/stargate/textures/up1_off.png differ
diff --git a/stargate/textures/up1r.png b/stargate/textures/up1r.png
new file mode 100644 (file)
index 0000000..6dc6a1d
Binary files /dev/null and b/stargate/textures/up1r.png differ
diff --git a/stargate/textures/up2.png b/stargate/textures/up2.png
new file mode 100644 (file)
index 0000000..9527d79
Binary files /dev/null and b/stargate/textures/up2.png differ
diff --git a/stargate/textures/up2_off.png b/stargate/textures/up2_off.png
new file mode 100644 (file)
index 0000000..88de6f8
Binary files /dev/null and b/stargate/textures/up2_off.png differ
diff --git a/stargate/textures/up3.png b/stargate/textures/up3.png
new file mode 100644 (file)
index 0000000..6767c2d
Binary files /dev/null and b/stargate/textures/up3.png differ
diff --git a/stargate/textures/up3_off.png b/stargate/textures/up3_off.png
new file mode 100644 (file)
index 0000000..efa5cc9
Binary files /dev/null and b/stargate/textures/up3_off.png differ
index 001913e121086d69b2f019313b0e56fcebab0a44..929f1558bafbe04c6b66a48b0715010e46603b5d 100644 (file)
@@ -72,7 +72,17 @@ minetest.register_node("technic:concrete_post", {
        groups = {cracky=1},
        sounds = default.node_sound_stone_defaults(),
 })
-
+if type(register_stair_and_slab_and_panel_and_micro) == "function" then
+register_stair_and_slab_and_panel_and_micro(":stairsplus", "concrete", "technic:concrete",
+               {cracky=3},
+               {"technic_concrete_block.png"},
+               "Concrete Stairs",
+               "Concrete Slab",
+               "Concrete Panel",
+               "Concrete Microblock",
+               "concrete")
+end
+if type(register_stair_slab_panel_micro) == "function" then
 register_stair_slab_panel_micro(":stairsplus", "concrete", "technic:concrete",
                {cracky=3},
                {"technic_concrete_block.png"},
@@ -81,3 +91,4 @@ register_stair_slab_panel_micro(":stairsplus", "concrete", "technic:concrete",
                "Concrete Panel",
                "Concrete Microblock",
                "concrete")
+end
index b4d67ece31e30a798b5140de71d6561696c04808..92cf50f1cabc0f5685ea7720b541cab7c5935282 100644 (file)
@@ -38,6 +38,42 @@ minetest.register_node( "technic:obsidian", {
        sounds = default.node_sound_stone_defaults(),
 }) 
 
+if type(register_stair_and_slab_and_panel_and_micro) == "function" then
+register_stair_and_slab_and_panel_and_micro(":stairsplus", "marble", "technic:marble",
+               {cracky=3},
+               {"technic_marble.png"},
+               "Marble Stairs",
+               "Marble Slab",
+               "Marble Panel",
+               "Marble Microblock",
+               "marble")
+register_stair_and_slab_and_panel_and_micro(":stairsplus", "marble_bricks", "technic:marble_bricks",
+               {cracky=3},
+               {"technic_marble_bricks.png"},
+               "Marble Bricks Stairs",
+               "Marble Bricks Slab",
+               "Marble Bricks Panel",
+               "Marble Bricks Microblock",
+               "marble_bricks")
+register_stair_and_slab_and_panel_and_micro(":stairsplus", "granite", "technic:granite",
+               {cracky=3},
+               {"technic_granite.png"},
+               "Granite Stairs",
+               "Granite Slab",
+               "Granite Panel",
+               "Granite Microblock",
+               "granite")
+register_stair_and_slab_and_panel_and_micro(":stairsplus", "obsidian", "technic:obsidian",
+               {cracky=3},
+               {"technic_obsidian.png"},
+               "Obsidian Stairs",
+               "Obsidian Slab",
+               "Obsidian Panel",
+               "Obsidian Microblock",
+               "obsidian")
+end
+
+if type(register_stair_slab_panel_micro) == "function" then
 register_stair_slab_panel_micro(":stairsplus", "marble", "technic:marble",
                {cracky=3},
                {"technic_marble.png"},
@@ -70,6 +106,7 @@ register_stair_slab_panel_micro(":stairsplus", "obsidian", "technic:obsidian",
                "Obsidian Panel",
                "Obsidian Microblock",
                "obsidian")
+end
 
 minetest.register_node( "technic:mineral_diamond", {
        description = "Diamond Ore",