If you want to think about it in a slightly different way, every action the synced Lua gadgets perform get translated into engine events that get passed to the AI through the AI's normal event handler.
Hm, not every Lua action gets passed to the AI.
ie in Spring Tanks (
http://springrts.com/wiki/Spring_Tanks) there is a score table that counts how often a players captured the enemy flag. For an AI that score table is atm not visible but at game end the winner is decided by that score table.
There simply is no engine event for "flag has been scored" and so it does not get passed to the AI. The AI could only do something like track location of the flags and depending on how near the flags are to the score bases it could make some guesses or something.
In other games there is a "king of the hill" where players try to hold an area for a certain amount of time to win. If controll of the area changes, no engine event is raised because it is a pure Lua thing.
There are lots more things like this.
The reason the AI needs to talk to Lua is so that the AI can control the Lua environment as if it were a human.
Imo it is more abstract and not just about allowing the AI to click dialogue boxes.
ie afaik AI interfaces have something like
isBuildSiteValid(x,z) and then the engine responds with "you can/can not build there."
But for some games, it would not work. For example evolutionRTS has this system were you can build certain things only around powerplants:
http://www.evolutionrts.info/game-manual/#Power
So the game would need to provide a new
isBuildSiteValid(x,z) that takes in account the power requirement.
---------------------
But that is details, what would be really nice to know is how 2) 3) 4) work.
Hopefully some engine/AI dev can shed some light on that
Here is an Lua side message recieving, that is now pretty clear:
unit_morph.lua of zeroK:
Code: Select all
http://www.google.com/codesearch/p?hl=de#_IaQsP4Z6YI/trunk/mods/zk/LuaRules/Gadgets/unit_morph.lua&q=AICallin%20package:http://zero-k\.googlecode\.com&sa=N&cd=2&ct=rc
unit_morph.lua of Conflict Terra: (appearently older version)
Code: Select all
http://www.google.com/codesearch/p?hl=de#5IW79w8JrCo/games/CT/LuaRules/Gadgets/unit_morph.lua&q=AICallin%20package:http://conflictterra\.googlecode\.com&sa=N&cd=1&ct=rc
it has this
Spring.SendMessage(data) maybe that is for responding?
(links get fucked, so I put them in code-tags to allow copy&paste)
Code: Select all
if message[1] == "Shard" or true then-- Because other AI shall be allowed to send such morph command without having to pretend to be Shard
lol. Such things should be avoided of course...
Also quickly looked through the source of some AIs
(
http://springrts.com/wiki/AI:Skirmish:List) ie BKPAI but I found nothing that seemed to send custom messages to Lua.