Page 1 of 1

Controlling the player through API

Posted: Wed Jan 27, 2016 8:59 pm
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!

Re: Controlling the player through API

Posted: Wed Jan 27, 2016 9:59 pm
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.