Page 1 of 1
Changing to god/ghost mode causes crash?
Posted: Fri Oct 18, 2013 8:45 pm
by ficolas
When I change from normal mode to god/ghost mode (inside the control.lua), the game crashes, if I do it in game, with the console, it works fine, also, inside the control.lua of the sandboxmode this is used.
The command im using is game.player.setcontroller{type=defines.controllers.ghost}.
Re: Changing to god/ghost mode causes crash?
Posted: Fri Oct 18, 2013 9:57 pm
by FreeER
I believe I saw that you can enter ghost mode by simply setting the player.character to nil (save character first) this may not lead to a crash.
Re: Changing to god/ghost mode causes crash?
Posted: Sat Oct 19, 2013 1:31 pm
by Math3vv
how do i getout of ghost mode ? (i used the "game.player.character = nil" command)
Re: Changing to god/ghost mode causes crash?
Posted: Sat Oct 19, 2013 1:35 pm
by ficolas
Math3vv wrote:how do i getout of ghost mode ? (i used the "game.player.character = nil" command)
did you save game.player.character in some variable?
If so you do game.player.setcontroller{type=defines.controllers.character, character=whatevernameofthevariable}
If you didnt I think you can put the cursor on the player and type game.player.setcontroller{type=defines.controllers.character, character=game.player.selected}
Re: Changing to god/ghost mode causes crash?
Posted: Sat Oct 19, 2013 1:53 pm
by Math3vv
ficolas wrote:Math3vv wrote:how do i getout of ghost mode ? (i used the "game.player.character = nil" command)
did you save game.player.character in some variable?
If so you do game.player.setcontroller{type=defines.controllers.character, character=whatevernameofthevariable}
If you didnt I think you can put the cursor on the player and type game.player.setcontroller{type=defines.controllers.character, character=game.player.selected}
in both cases he says it cant change (or read) the value because its nil
Re: Changing to god/ghost mode causes crash?
Posted: Sat Oct 19, 2013 2:22 pm
by ficolas
The crash seems to be only when done on the buildentity event, I can make it be at the tick event.
Maybe this should send a better crash message, or be fixed?
Re: Changing to god/ghost mode causes crash?
Posted: Sat Oct 19, 2013 2:40 pm
by ficolas
Code: Select all
glob.missile=true
glob.missilecount=0
glob.character=game.player.character
game.player.setcontroller{type=defines.controllers.ghost}
game.player.teleport(glob.character.position) --here is the error
cap=tostring(math.ceil(game.player.position.x))..", "..tostring(math.ceil(game.player.position.y)).." "..tostring(math.ceil(glob.character.position.x)).."±100, "..tostring(math.ceil(glob.character.position.y)).."±100"
game.player.gui.center.add({type="frame", name="menus", caption=cap,direction="vertical",style="missile_menu"})
game.player.gui.center.menus.add({type="button", name="missile", caption=" ",style="inv_button"})
Now that sends error at the marked line, it says attempt to index field character
Re: Changing to god/ghost mode causes crash?
Posted: Sun Oct 20, 2013 8:40 am
by kovarex
Right, when you do it as part of the onbuilt event or similar, it probably doesn't expect the character to be removed during processing that event, we can try to solve it somehow ...