Controlling a character with lua

Place to get help with not working mods / modding interface.
Post Reply
SamSam
Inserter
Inserter
Posts: 32
Joined: Fri Jul 10, 2015 2:02 am
Contact:

Controlling a character with lua

Post 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.

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Controlling a character with lua

Post 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
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: Controlling a character with lua

Post 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.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

Post Reply

Return to “Modding help”