Controlling the player through API

Place to get help with not working mods / modding interface.
Post Reply
User avatar
marcotc
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu Jan 30, 2014 12:38 am
Contact:

Controlling the player through API

Post by marcotc »

Hello everyone,
I want to write an autopilot script. I wanted a way to send "clean", valid player actions to the game. A few examples of actions I need are: walk one block north; use slot1 item on tile X,Y (given tile is within range). I'm trying to avoid "cheat" actions like teleport or spawn items.
Is it possible to control what actions the player does through the Lua API?
I couldn't find any possible functions by inspecting the objects in console (specifically game.player).

Thank you very much!

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Controlling the player through API

Post by DaveMcW »

Code: Select all

/c game.local_player.walking_state = {walking = true, direction = defines.direction.north}
Look at LuaPlayer.html in the api folder for more details.

Post Reply

Return to “Modding help”