[plugin] StandardColors

[plugin] StandardColors

SpringRTS Perl Autohost for Dedicated Server

Moderators: Moderators, Lobby Developers, SPADS AutoHost

Post Reply
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

[plugin] StandardColors

Post by Jools »

Here's a plugin I made:

It allows you to save your color (one main and one away color) for automatic applying when the !balance or !fixcolors commands are issued. (Would be ideal to do it when you arrive to the battle room but I couldn't make it work with onJoinBattleRequest. I only tested with tasclient: maybe it works with other lobbies...).

Many people in xta at least so often use the same color that it has become associated with those people. Like Wayne Gretzky and 99. But at least Tasclient does not apply the same color when you leave battle room and rejoin. So with this you can make your color permanent.

It provides the following commands:
[savecolor]
!savecolor [<user>] [away]
!savecolor Jools - saves the current color of user 'Jools' to the database.
!savecolor - saves the current color of the user who gave the command to the database.
!savecolor Jools away - saves the current color as away color of user 'Jools' to the database.


[loadcolor]
!loadcolor [<user>]
!loadcolor Jools - loads the current color of user 'Jools' from the database.
!loadcolor - loads the current color of the user who gave the command from the database.


[removecolor]
!removecolor [<user>]
!removecolor Jools - removes the current color of user 'Jools' from the database.
!removecolor - removes the current color of the user who gave the command from the database.


[printcolor]
!printcolor [<user>]
!printcolor Jools - prints the currently used spring color of user 'Jools' to output.
!printcolor - prints the currently used spring color of the user who gave the command to output.


[listcolors]
!listcolors [<user>]
!listcolors - lists the currently saved colors of all users in list to output.
!listcolors Jools - lists the currently saved colors for user Jools to output.


TODO: make it save database to a file.

Edit: Thanks for the instructions. Made the necessary corrections and I put a newer version here instead. It saves the data and uses the joinedbattle event instead.
Attachments
StandardColors1.1.zip
Version 1.1
(4.11 KiB) Downloaded 7 times
Last edited by Jools on 25 Jan 2015, 17:14, edited 2 times in total.
User avatar
bibim
Lobby Developer
Posts: 952
Joined: 06 Dec 2007, 11:12

Re: SPADS AutoHost

Post by bibim »

Jools wrote:Here's a plugin I made:
Nice, thanks for sharing!
Jools wrote:It allows you to save your color (one main and one away color) for automatic applying when the !balance or !fixcolors commands are issued. (Would be ideal to do it when you arrive to the battle room but I couldn't make it work with onJoinBattleRequest. I only tested with tasclient: maybe it works with other lobbies...).
The onJoinBattleRequest() callback is called when the user hasn't joined the battle yet. This callback is supposed to be used to allow or deny users to join the battle, it's not the ideal place to implement what you want.
I recommend adding a lobby command handler on the JOINEDBATTLE command instead, so you can trigger processing once the user actually joined the battle. You can find an example of this in the FirstWelcomeMsg plugin (function hLobbyJoinedBattle() ).
Jools wrote:TODO: make it save database to a file.
I recommend honoring the dataDumpDelay SPADS settings to regularly store your persistent data into files, so that even if SPADS crashes, your data aren't lost. The persistent data should also be stored when the plugin is unloaded of course.
The easiest way to do this is to use the "store" and "retrieve" functions from the standard "Storable" Perl module. You can find an example of this in the FirstWelcomeMsg plugin (persistent data are retrieved in the plugin constructor, and stored in the "storeAlreadySentDataIfNeeded" function which is called from the "eventLoop" and "onUnload" callbacks).
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: SPADS AutoHost

Post by Jools »

Thanks. I edited the previous post to reflect changes.

The dataDumpDelay is an autohost setting right? I have it enabled and set to 60 minutes, I see it dumps userdata.dat and maybe also savedboxes.dat and maybe something else, but preferences.dat is always the empty file (but with the standard comments).

Also one more note: I think spring lobby protocol page could begin with an index of all commands, to make it easier to find what you're looking for.
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: SPADS AutoHost

Post by gajop »

Jools wrote: Also one more note: I think spring lobby protocol page could begin with an index of all commands, to make it easier to find what you're looking for.
http://springrts.com/dl/LobbyProtocol/ ?
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: SPADS AutoHost

Post by Jools »

Nice, Thank you. I hadn't found that page.
User avatar
bibim
Lobby Developer
Posts: 952
Joined: 06 Dec 2007, 11:12

Re: SPADS AutoHost

Post by bibim »

Jools wrote:The dataDumpDelay is an autohost setting right? I have it enabled and set to 60 minutes, I see it dumps userdata.dat and maybe also savedboxes.dat and maybe something else, but preferences.dat is always the empty file (but with the standard comments).
Yes it is a global SPADS setting, you can safely use it from any plugin to use same delay to dump plugin data.
preferences.dat contains the user preferences, but if none of your users defined any preference (using !pSet command) then it's normal that it is empty.
Post Reply

Return to “SPADS AutoHost”