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}.
Changing to god/ghost mode causes crash?
Re: Changing to god/ghost mode causes crash?
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.
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me
Or drop into #factorio on irc.esper.net
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me

Or drop into #factorio on irc.esper.net
Re: Changing to god/ghost mode causes crash?
how do i getout of ghost mode ? (i used the "game.player.character = nil" command)
Re: Changing to god/ghost mode causes crash?
did you save game.player.character in some variable?Math3vv wrote:how do i getout of ghost mode ? (i used the "game.player.character = nil" command)
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?
in both cases he says it cant change (or read) the value because its nilficolas wrote:did you save game.player.character in some variable?Math3vv wrote:how do i getout of ghost mode ? (i used the "game.player.character = nil" command)
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?
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?
Maybe this should send a better crash message, or be fixed?
Re: Changing to god/ghost mode causes crash?
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"})
Re: Changing to god/ghost mode causes crash?
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 ...