Fix buggy spawn algorithm

This commit is contained in:
Wuzzy 2016-02-13 21:30:06 +01:00
parent 8751727d70
commit 431614f096

View File

@ -41,8 +41,10 @@ end
if(read==false) then if(read==false) then
tutorial.state = {} tutorial.state = {}
-- Is this the first time the player joins this tutorial? -- Is this the first time the player joins this tutorial? (used for spawn position)
tutorial.state.first_join = true tutorial.state.first_join = true
-- Has the regular introduction text been shown yet?
tutorial.state.intro_text = false
-- These variables store wheather a message for those events has been shown yet. -- These variables store wheather a message for those events has been shown yet.
tutorial.state.first_gold = false tutorial.state.first_gold = false
tutorial.state.last_gold = false tutorial.state.last_gold = false
@ -1300,7 +1302,7 @@ minetest.register_on_joinplayer(function(player)
"button_exit[2.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue anyways")).."]".. "button_exit[2.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue anyways")).."]"..
"button_exit[6.5,5.5;3,1;leave;"..minetest.formspec_escape(S("Leave tutorial")).."]" "button_exit[6.5,5.5;3,1;leave;"..minetest.formspec_escape(S("Leave tutorial")).."]"
elseif(tutorial.state.first_join==true) then elseif(tutorial.state.intro_text == false) then
formspec = "size[12,6]".. formspec = "size[12,6]"..
"label[-0.15,-0.4;"..minetest.formspec_escape(S("Introduction")).."]".. "label[-0.15,-0.4;"..minetest.formspec_escape(S("Introduction")).."]"..
"tablecolumns[text]".. "tablecolumns[text]"..
@ -1309,13 +1311,14 @@ minetest.register_on_joinplayer(function(player)
tutorial.convert_newlines(minetest.formspec_escape(S(tutorial.texts.intro))).. tutorial.convert_newlines(minetest.formspec_escape(S(tutorial.texts.intro)))..
"]".. "]"..
"button_exit[4.5,5.5;3,1;close;"..minetest.formspec_escape(S("Close")).."]" "button_exit[4.5,5.5;3,1;close;"..minetest.formspec_escape(S("Close")).."]"
tutorial.state.first_join = false tutorial.state.intro_text = true
tutorial.save_state()
end end
if tutorial.first_spawn then if tutorial.state.first_join==true and tutorial.first_spawn then
player:setpos(tutorial.first_spawn.pos) player:setpos(tutorial.first_spawn.pos)
player:set_look_yaw(tutorial.first_spawn.yaw) player:set_look_yaw(tutorial.first_spawn.yaw)
tutorial.state.first_join = false
end end
tutorial.save_state()
if(formspec~=nil) then if(formspec~=nil) then
minetest.show_formspec(player:get_player_name(), "intro", formspec) minetest.show_formspec(player:get_player_name(), "intro", formspec)
end end