I need suggestions on making a script

I need suggestions on making a script

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
PhailQuail
Posts: 35
Joined: 17 Sep 2008, 15:54

I need suggestions on making a script

Post by PhailQuail »

Hello, I am interested in exporting data from replays from games I have played in Spring into an external program so that it can be parsed, analyzed and stored into a database.

I am a programmer, but I have no Lua experience, and I am wondering how I would go about coding something like this.

It is my intention on sending the data using sockets, as I would like it to be fairly fast, and the program that parses the data could potentially be run on another PC, is this possible with Spring's implementation of Lua?

What kind of information can I expect to extract? I would like to know things such as when/how/where a building/unit gets built, what players are playing, when they leave and the result of the game.

I additionally would like the ability to do this in real-time, so I could write programs that could guess certain things such as how long it takes for my opponent to upgrade to stronger AA, or if he doesn't build anti-nukes, how soon would he switch to T2, what units he gets owned by, what his favorite units are, etc.

I have a feeling that someone may of attempted to do something like this already, I would like to hear the experiences they had doing so.
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Re: I need suggestions on making a script

Post by BrainDamage »

PhailQuail wrote:What kind of information can I expect to extract? I would like to know things such as when/how/where a building/unit gets built, what players are playing, when they leave and the result of the game.

I additionally would like the ability to do this in real-time, so I could write programs that could guess certain things such as how long it takes for my opponent to upgrade to stronger AA, or if he doesn't build anti-nukes, how soon would he switch to T2, what units he gets owned by, what his favorite units are, etc.
replays are a list of orders by the players, you can already extract the infos you want directly from the replay file itself without running spring at all.
check demoanalyzer in the spring repository for a replay parser example.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: I need suggestions on making a script

Post by imbaczek »

ask Error323, he's been doing replay analysis IIRC.
PhailQuail
Posts: 35
Joined: 17 Sep 2008, 15:54

Re: I need suggestions on making a script

Post by PhailQuail »

I am interested in more than just the orders players give, call me lazy, but I just don't feel like re-implementing Spring's engine in it's entirety to find out what unit attacks which.

I intending on extracting this information while watching replays, since I would also be able to extract this information in real-time (although, understandably, less verbose than watching a replay).
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: I need suggestions on making a script

Post by lurker »

You may want to look at the statistics gadget in CA. As far as realtime, it's not too messy to build luasocket for spring and load it. More info or a dll for 78.2 if you want it.
PhailQuail
Posts: 35
Joined: 17 Sep 2008, 15:54

Re: I need suggestions on making a script

Post by PhailQuail »

Anything CA-dependent is fine, since that is all I play anyway.

Any further info would be greatly appreciated, as I have no experience with Lua or the inner workings of Spring.

I may consider releasing what I make to the community (open-source, ofc) if it gets to a point where I am happy with it.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: I need suggestions on making a script

Post by lurker »

Not dependent, as something for you to take code from.

http://evolutionrts.info/~lurker/stuff/ ... ketwoo.zip
PhailQuail
Posts: 35
Joined: 17 Sep 2008, 15:54

Re: I need suggestions on making a script

Post by PhailQuail »

I am having some trouble with the sockets library, the problems mainly involve me not knowing what I am doing.

The examples (if that's what they were) were only slightly helpful, at this stage, I have no idea on how to load the socket library.

I did manage to echo when units got damaged, etc, so I am making progress.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: I need suggestions on making a script

Post by lurker »

require("socket") or something, unzipped into your spring folder
PhailQuail
Posts: 35
Joined: 17 Sep 2008, 15:54

Re: I need suggestions on making a script

Post by PhailQuail »

OK, I have made significant progress, but now I have run into issues with the UnitDamaged callin.
UnitDamaged() --> "unitID, unitDefID, unitTeam, damage, paralyzer, weaponID, attackerID, attackerDefID, attackerTeam"
weaponID, attackerID, attackerDefID and attackerTeam are always nil, I am using a replay of a FFA CA game I played.
Post Reply

Return to “Lua Scripts”