Page 1 of 1

Chart Question

Posted: Mon May 23, 2016 11:00 pm
by TheSAguy
How would I run the below from the Control.lua?

Code: Select all

/c game.local_player.force.chart(game.local_player.surface,{lefttop = {x = -1024, y = -1024}, rightbottom = {x = 1024, y = 1024}})
Since I can't use "game." in the control.lua?

Thanks.

Re: Chart Question

Posted: Mon May 23, 2016 11:18 pm
by prg
local_player would be the problem here, not game. You could use game.forces.player and game.surfaces.nauvis if you want to hardcode things. If you're doing this in an event handler, chances are there's something appropriate to use in the event object that gets passed to it. If you're trying to do this in on_load or in the global scope, you're doing it wrong.

Re: Chart Question

Posted: Mon May 23, 2016 11:21 pm
by ArderBlackard
You may subscribe to some event that will be called after the game start and execute your code in it's handler. For example

Code: Select all

require "defines"
script.on_event( 
  defines.events.on_player_created, 
  function ( event ) 
    -- game. is available here
  end 
)