LuaControl / LuaEntity should expose more player actions
Posted: Sun Mar 12, 2017 12:59 am
I want to create a player AI mod where the AI opponent make their own bases, defenses and do mining. However, while you can create 'zombie' character entities with no associated LuaPlayer, a lot of reasonable character actions are not exposed in the LuaControl interface.
Example:
The mining state is only modified for a single tick, hence I tested it in the on_tick callback. While this works for character entities with a connected player, this has no effect on 'zombie' character entities.
However, LuaControl.walking_state *does* work. With walking set to true, and with a direction defined, the 'zombie' character does walk in the specified direction.
So my request is:
Similar workarounds would work for firing weapons (spawn projectiles or use invisible turrets) and pick up / drop items, but with the same shortcomings.
Example:
Code: Select all
BOT = game.surfaces[1].create_entity{name = "player", position = {0, 0}, force=game.forces.enemy }
function bot_mine(x,y)
BOTt.teleport(x, y-1)
script.on_event(defines.events.on_tick, function(event) BOT.mining_state = {mining = true, position = {x, y}} end)
end
However, LuaControl.walking_state *does* work. With walking set to true, and with a direction defined, the 'zombie' character does walk in the specified direction.
So my request is:
- It would be nice if LuaControl.mining_state, and all the other xxx_states worked for the player prototype where the character entity is not associated with a connected client.
- Implement a firing_state: LuaControl.firing_state = {firing = true, position = {x,y}} where position would be where the conceptual cursor is. A direction wouldn't work, because the radius is important when using capsules and grenades.
- Implement functions in LuaControl which lets the entity pick up and drop items.
Similar workarounds would work for firing weapons (spawn projectiles or use invisible turrets) and pick up / drop items, but with the same shortcomings.