Page 1 of 1

lua sockets and dynamic content

Posted: 29 Oct 2019, 17:44
by raaar
https://springrts.com/wiki/Lua_Socket

I'm wondering if lua sockets could be used to have dynamic content in games through gadgets, namely:

1 - allowing players to build custom units through an external website, then, when the game starts, luasocket communication being used to get info about each player's custom unit set and generating the corresponding unit defs and updating the build menus.

2 - allowing lua AIs to tweak their behavior, to learn, by uploading info to an external server when the game ends and getting info from it when the game starts.


Are these possible? Any ideas on how to implement them? How would that work on replays?

Re: lua sockets and dynamic content

Posted: 29 Oct 2019, 18:11
by sprunk
raaar wrote: 29 Oct 2019, 17:441 - allowing players to build custom units through an external website, then, when the game starts, luasocket communication being used to get info about each player's custom unit set and generating the corresponding unit defs and updating the build menus.
Sockets are unsynced so at best you could download presets describing what a widget should say to a gadget.

This might as well be done offline (Chobby has some unit-building UI, saves to file, ingame widget reads that file). If you still want the persistence offered by the external website there's also the option to have the host server read the data and embed it in startscript (that's how it's done in ZK).

Re: lua sockets and dynamic content

Posted: 29 Oct 2019, 21:47
by AF
Lua AIs could always do this kind of thing, but most Lua AIs run in synced land, which stops this from happening.

If a Lua AI ran unsynced however, it could run faster, store data on the filesystem, make network requests, and generally be far better.

For example, I wrote an async building placement algorithm for DAI with timing controls so it always had predictable load, but because it had to run synced, I had to fix all the timing values rather than letting it adapt to the current workload budgets :(

Re: lua sockets and dynamic content

Posted: 30 Oct 2019, 10:09
by Anarchid
If a Lua AI ran unsynced however, it could run faster, store data on the filesystem, make network requests, and generally be far better.
It can't do that atm though as LuaUI is limited to information accessible to the current player. It would need LuaAI as a separate unsynced LuaState.

If you really want to improve your AI performance though or do more complex things it probably just makes sense to use the SkirmishAI interface though.

Re: lua sockets and dynamic content

Posted: 30 Oct 2019, 12:15
by PicassoCT
Spring besieged? I can already see peniszilla..

Re: lua sockets and dynamic content

Posted: 06 Nov 2019, 17:22
by abma
raaar wrote: 29 Oct 2019, 17:44 Are these possible? Any ideas on how to implement them? How would that work on replays?
IMHO yes: https://springrts.com/wiki/Lua_Unsynced ... LuaMessage

the messages are stored in replays, so replays would work "offline".