Page 1 of 1

Controlling a character with lua

Posted: Wed Aug 17, 2016 12:21 pm
by SamSam
Is there a way to make a character actually walk or preferably a way to emulate a key press from a player? For example if I wanted to write a bot for factorio, are there any functions for emulating control? Unfortunately you can't do a lot of things realistically with the functions I have found, such as mining an entity. Hopefully there is a way to do this without using some kind of external method :)
EDIT:
LuaPlayer.walking_state is labelled as read-only on the wiki, but the example shows it being set, could anyone clarify which way it is used? (Can't access a PC right now) And also mining_state.

Re: Controlling a character with lua

Posted: Wed Aug 17, 2016 2:19 pm
by aubergine18
Not sure if you can control the player avatar much, but you can certainly control other entities, for example:

https://mods.factorio.com/mods/kyranzor/robotarmy

https://mods.factorio.com/mods/KatzSmile/trucks

Re: Controlling a character with lua

Posted: Sat Aug 20, 2016 6:51 pm
by Adil
In 0.12.35 the documentation listed walking state as read-write. You could make char move around or steer a vehicle by modifying the field.
In 0.13 the field is listed as read, who knows maybe its typo.
Other actions like mining and shooting are not achievable in this way.