From: RealBadAngel Date: Wed, 13 Mar 2013 23:27:32 +0000 (+0100) Subject: update X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=e7b7eb45784658176aa199e794109bed449fe34f;p=zefram%2Fminetest%2Ftechnic.git update --- diff --git a/stargate/gate_defs.lua b/stargate/gate_defs.lua index 57189d5..355ac2b 100644 --- a/stargate/gate_defs.lua +++ b/stargate/gate_defs.lua @@ -6,7 +6,6 @@ function swap_gate_node(pos,name,dir) node.param1=0 node.param2=dir minetest.env:set_node(pos,node) - meta=minetest.env:get_meta(pos) meta:from_table(meta0) end @@ -143,12 +142,14 @@ function placeGate (player,pos) meta:set_string("gateNodes",minetest.serialize(gateNodes)) meta:set_int("gateActive",0) meta:set_string("owner",player_name) + meta:set_string("dont_destroy","false") stargate.registerGate(player_name,gateNodes[1].pos) return true end function removeGate (pos) local meta = minetest.env:get_meta(pos) + if meta:get_string("dont_destroy") == "true" then return end local player_name=meta:get_string("owner") local gateNodes=minetest.deserialize(meta:get_string("gateNodes")) for i=2,9,1 do @@ -164,7 +165,8 @@ function activateGate (player,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,}) + meta:set_string("dont_destroy","true") + minetest.sound_play("gateOpen", {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) @@ -174,6 +176,7 @@ function activateGate (player,pos) 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) + meta:set_string("dont_destroy","false") end function deactivateGate (player,pos) @@ -182,7 +185,9 @@ function deactivateGate (player,pos) local meta = minetest.env:get_meta(pos) local gateNodes=minetest.deserialize(meta:get_string("gateNodes")) meta:set_int("gateActive",0) + meta:set_string("dont_destroy","true") meta:set_string("infotext", "Stargate inactive") + minetest.sound_play("gateClose", {pos = pos, gain = 1.0,loop = false, max_hear_distance = 72,}) 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) @@ -192,11 +197,13 @@ function deactivateGate (player,pos) 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) + meta:set_string("dont_destroy","false") end gateCanDig = function(pos,player) local player_name = player:get_player_name() local meta = minetest.env:get_meta(pos) + if meta:get_string("dont_destroy") == "true" then return end local owner=meta:get_string("owner") if player_name==owner then return true else return false end @@ -330,6 +337,7 @@ minetest.register_node("stargate:gatenode8",{ on_destruct = function (pos) removeGate(pos) end, + on_rightclick=stargate.gateFormspecHandler, }) minetest.register_node("stargate:gatenode9",{ diff --git a/stargate/io.lua b/stargate/io.lua deleted file mode 100644 index 8b13789..0000000 --- a/stargate/io.lua +++ /dev/null @@ -1 +0,0 @@ - diff --git a/stargate/sounds/enterEventHorizon.ogg b/stargate/sounds/enterEventHorizon.ogg new file mode 100644 index 0000000..7543bdd Binary files /dev/null and b/stargate/sounds/enterEventHorizon.ogg differ diff --git a/stargate/sounds/gateClose.ogg b/stargate/sounds/gateClose.ogg new file mode 100644 index 0000000..3bdfcb7 Binary files /dev/null and b/stargate/sounds/gateClose.ogg differ diff --git a/stargate/sounds/gateOpen.ogg b/stargate/sounds/gateOpen.ogg new file mode 100644 index 0000000..cd2130c Binary files /dev/null and b/stargate/sounds/gateOpen.ogg differ diff --git a/stargate/sounds/gateSpin.ogg b/stargate/sounds/gateSpin.ogg new file mode 100644 index 0000000..6e96d47 Binary files /dev/null and b/stargate/sounds/gateSpin.ogg differ diff --git a/stargate/sounds/irisClose.ogg b/stargate/sounds/irisClose.ogg new file mode 100644 index 0000000..33044b1 Binary files /dev/null and b/stargate/sounds/irisClose.ogg differ diff --git a/stargate/sounds/irisOpen.ogg b/stargate/sounds/irisOpen.ogg new file mode 100644 index 0000000..161e1fe Binary files /dev/null and b/stargate/sounds/irisOpen.ogg differ diff --git a/stargate/sounds/stargatetheme.ogg b/stargate/sounds/stargatetheme.ogg deleted file mode 100644 index 52dd016..0000000 Binary files a/stargate/sounds/stargatetheme.ogg and /dev/null differ diff --git a/stargate/stargate_gui.lua b/stargate/stargate_gui.lua index 88894ac..829130f 100644 --- a/stargate/stargate_gui.lua +++ b/stargate/stargate_gui.lua @@ -62,6 +62,7 @@ minetest.register_on_joinplayer(function(player) stargate_network["players"][player_name]["public_gates"]={} stargate_network["players"][player_name]["public_gates_count"]=0 stargate_network["players"][player_name]["current_index"]=0 + stargate_network["players"][player_name]["temp_gate"]={} end) stargate.registerGate = function(player_name,pos) @@ -100,6 +101,7 @@ stargate.gateFormspecHandler = function(pos, node, clicker, itemstack) stargate_network["players"][player_name]["own_gates"]={} stargate_network["players"][player_name]["public_gates"]={} local own_gates_count=0 + print(dump(stargate_network[player_name])) 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 @@ -114,6 +116,21 @@ stargate.gateFormspecHandler = function(pos, node, clicker, itemstack) return nil end stargate_network["players"][player_name]["current_index"]=0 + stargate_network["players"][player_name]["temp_gate"]["type"]=current_gate["type"] + stargate_network["players"][player_name]["temp_gate"]["description"]=current_gate["description"] + stargate_network["players"][player_name]["temp_gate"]["pos"]={} + stargate_network["players"][player_name]["temp_gate"]["pos"].x=current_gate["pos"].x + stargate_network["players"][player_name]["temp_gate"]["pos"].y=current_gate["pos"].y + stargate_network["players"][player_name]["temp_gate"]["pos"].z=current_gate["pos"].z + if current_gate["destination"] then + stargate_network["players"][player_name]["temp_gate"]["destination_description"]=current_gate["destination_description"] + stargate_network["players"][player_name]["temp_gate"]["destination"]={} + stargate_network["players"][player_name]["temp_gate"]["destination"].x=current_gate["destination"].x + stargate_network["players"][player_name]["temp_gate"]["destination"].y=current_gate["destination"].y + stargate_network["players"][player_name]["temp_gate"]["destination"].z=current_gate["destination"].z + else + stargate_network["players"][player_name]["temp_gate"]["destination"]=nil + end stargate_network["players"][player_name]["current_gate"]=current_gate stargate_network["players"][player_name]["dest_type"]="own" local formspec=stargate.get_formspec(player_name,"main") @@ -125,27 +142,36 @@ end stargate.get_formspec = function(player_name,page) if player_name==nil then return nil end stargate_network["players"][player_name]["current_page"]=page - local current_gate=stargate_network["players"][player_name]["current_gate"] + local temp_gate=stargate_network["players"][player_name]["temp_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.."label[0,0.0;Stargate DHD]" + formspec = formspec.."label[0,.5;Position: ("..temp_gate["pos"].x..","..temp_gate["pos"].y..","..temp_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.."label[4,.5;Type: "..temp_gate["type"].."]" formspec = formspec.."image_button[6.5,.6;.6,.6;pencil_icon.png;edit_desc;]" formspec = formspec.."label[0,1.1;Destination: ]" + if temp_gate["destination"] then + formspec = formspec.."label[2.5,1.1;("..temp_gate["destination"].x.."," + ..temp_gate["destination"].y.."," + ..temp_gate["destination"].z..") " + ..temp_gate["destination_description"].."]" + formspec = formspec.."image_button[2,1.2;.6,.6;cancel_icon.png;remove_dest;]" + else + formspec = formspec.."label[2,1.1;Not connected]" + end 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;Filter: "..stargate_network["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"].."]" + formspec = formspec.."label[7,.5;Description: "..temp_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"].."]" + formspec = formspec.."field[7.3,.7;5,1;desc_box;Edit gate description:;"..temp_gate["description"].."]" end local list_index=stargate_network["players"][player_name]["current_index"] @@ -156,9 +182,9 @@ stargate.get_formspec = function(player_name,page) for x=0,2,1 do local gate_temp=stargate_network["players"][player_name]["own_gates"][list_index+1] if gate_temp then - formspec = formspec.."image_button["..(x*4.5)..","..(2.5+y*.9)..";.6,.6;stargate_icon.png;list_button"..list_index..";]" - formspec = formspec.."label["..(x*4.5+.5)..","..(2.3+y*.9)..";("..gate_temp["pos"].x..","..gate_temp["pos"].y..","..gate_temp["pos"].z..") "..gate_temp["type"].."]" - formspec = formspec.."label["..(x*4.5+.5)..","..(2.7+y*.9)..";"..gate_temp["description"].."]" + formspec = formspec.."image_button["..(x*4.5)..","..(2.5+y*.87)..";.6,.6;stargate_icon.png;list_button"..list_index..";]" + formspec = formspec.."label["..(x*4.5+.5)..","..(2.3+y*.87)..";("..gate_temp["pos"].x..","..gate_temp["pos"].y..","..gate_temp["pos"].z..") "..gate_temp["type"].."]" + formspec = formspec.."label["..(x*4.5+.5)..","..(2.7+y*.87)..";"..gate_temp["description"].."]" end print(dump(list_index)) list_index=list_index+1 @@ -167,6 +193,8 @@ stargate.get_formspec = function(player_name,page) formspec = formspec.."image_button[6.5,1.8;.6,.6;left_icon.png;page_left;]" formspec = formspec.."image_button[6.9,1.8;.6,.6;right_icon.png;page_right;]" formspec=formspec.."label[7.5,1.7;Page: "..page.." of "..pagemax.."]" + formspec = formspec.."image_button_exit[6.1,9.3;.8,.8;ok_icon.png;save_changes;]" + formspec = formspec.."image_button_exit[7.1,9.3;.8,.8;cancel_icon.png;discard_changes;]" return formspec end @@ -174,13 +202,14 @@ end minetest.register_on_player_receive_fields(function(player, formname, fields) if not formname == "stargate_main" then return "" end local player_name = player:get_player_name() + local temp_gate=stargate_network["players"][player_name]["temp_gate"] local current_gate=stargate_network["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 + if temp_gate["type"] == "private" then + temp_gate["type"] = "public" + else temp_gate["type"] = "private" end formspec= stargate.get_formspec(player_name,"main") stargate_network["players"][player_name]["formspec"] = formspec minetest.show_formspec(player_name, "stargate_main", formspec) @@ -207,7 +236,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end if fields.save_desc then - current_gate["description"]=fields.desc_box + temp_gate["description"]=fields.desc_box formspec= stargate.get_formspec(player_name,"main") stargate_network["players"][player_name]["formspec"]=formspec minetest.show_formspec(player_name, "stargate_main", formspec) @@ -242,18 +271,63 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) minetest.show_formspec(player_name, "stargate_main", formspec) end end + + if fields.remove_dest then + minetest.sound_play("click", {to_player=player_name, gain = 0.5}) + temp_gate["destination"]=nil + temp_gate["destination_description"]=nil + formspec = stargate.get_formspec(player_name,"main") + stargate_network["players"][player_name]["formspec"] = formspec + minetest.show_formspec(player_name, "stargate_main", formspec) + end + + if fields.save_changes then + minetest.sound_play("click", {to_player=player_name, gain = 0.5}) + current_gate["type"]=temp_gate["type"] + current_gate["description"]=temp_gate["description"] + current_gate["pos"]={} + current_gate["pos"].x=temp_gate["pos"].x + current_gate["pos"].y=temp_gate["pos"].y + current_gate["pos"].z=temp_gate["pos"].z + if temp_gate["destination"] then + current_gate["destination_description"]=temp_gate["destination_description"] + current_gate["destination"]={} + current_gate["destination"].x=temp_gate["destination"].x + current_gate["destination"].y=temp_gate["destination"].y + current_gate["destination"].z=temp_gate["destination"].z + else + current_gate["destination"]=nil + end + if current_gate["destination"] then + activateGate (player,current_gate["pos"]) + else + deactivateGate (player,current_gate["pos"]) + end + if stargate.save_data(player_name)==nil then + print ("[stargate] Couldnt update network file!") + end + end + + if fields.discard_changes then + minetest.sound_play("click", {to_player=player_name, gain = 0.5}) + end + local list_index=stargate_network["players"][player_name]["current_index"] local i for i=0,23,1 do local button="list_button"..i+list_index if fields[button] then - local gate=stargate_network["players"][player_name]["current_gate"] + minetest.sound_play("gateSpin", {to_player=player_name, gain = 1.0}) + local gate=stargate_network["players"][player_name]["temp_gate"] local dest_gate=stargate_network["players"][player_name]["own_gates"][list_index+i+1] gate["destination"]={} gate["destination"].x=dest_gate["pos"].x gate["destination"].y=dest_gate["pos"].y gate["destination"].z=dest_gate["pos"].z - activateGate (player,gate["pos"]) + gate["destination_description"]=dest_gate["description"] + formspec = stargate.get_formspec(player_name,"main") + stargate_network["players"][player_name]["formspec"] = formspec + minetest.show_formspec(player_name, "stargate_main", formspec) end end end) diff --git a/stargate/textures/cancel_icon.png b/stargate/textures/cancel_icon.png new file mode 100644 index 0000000..6c36fae Binary files /dev/null and b/stargate/textures/cancel_icon.png differ diff --git a/stargate/textures/dialog-ok.png b/stargate/textures/dialog-ok.png new file mode 100644 index 0000000..0371a9f Binary files /dev/null and b/stargate/textures/dialog-ok.png differ diff --git a/stargate/textures/save_icon.png b/stargate/textures/save_icon.png new file mode 100644 index 0000000..bc6d4d7 Binary files /dev/null and b/stargate/textures/save_icon.png differ diff --git a/stargate/textures/tick_ok_sign_4190.jpg b/stargate/textures/tick_ok_sign_4190.jpg deleted file mode 100644 index 5f6c6aa..0000000 Binary files a/stargate/textures/tick_ok_sign_4190.jpg and /dev/null differ