Chart Question

Place to get help with not working mods / modding interface.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1456
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Chart Question

Post 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.
User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Chart Question

Post 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.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
User avatar
ArderBlackard
Long Handed Inserter
Long Handed Inserter
Posts: 74
Joined: Thu May 05, 2016 12:41 pm
Contact:

Re: Chart Question

Post 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 
)
Gib dich hin bis du Glück bist
Post Reply

Return to “Modding help”