SRB2 Message Board  

Go Back   SRB2 Message Board > Sonic Robo Blast 2 > Releases > Lua

Reply
 
Thread Tools
Team Colors (For Some Variation) Details »»
Team Colors (For Some Variation)
Version: 2.0, by Yoshirocks90 (Eh, maybe later.) Yoshirocks90 is offline
Developer Last Online: Nov 2017

Category: Version: SRB2 Rating:
Released: 09-09-2017 Last Update: 09-23-2017 Installs: 0
Scripts Re-Useable Content

This here is a script so you can change your colors in Team Match/CTF. Colors are restricted based on team, and some are not available at all.

Commands:

playercolor <color/help>: sets the color to use in Team Match and CTF.

player2color <color/help>: sets the color for player 2 to use in CTF and team match in splitscreen.

listcolor <red/blue/none/help>: lists the available colors for Red Team and Blue Team, as well as unavailable colors.

Spoiler: Changelog

V1.0 - Initial Release

V2.0 - Shortened lines, added splitscreen support

Download Now

File Type: lua TeamColors.lua (7.7 KB, 80 views)

Screenshots

Click image for larger version

Name:	srb20563.jpg
Views:	165
Size:	157.4 KB
ID:	11445   Click image for larger version

Name:	srb20564.jpg
Views:	160
Size:	157.1 KB
ID:	11446  

Show Your Support

  • The author of this addon has given explicit permission for its content to be re-used and/or reproduced.

Comments
Old 09-15-2017   #2
Sryder13
'That brit'
Judge
 
Sryder13's Avatar
Default

This seems to work from what I could see by myself. I haven't tested it in a netgame but I can't see anything breaking with other players due to how it works.
Only minor issue I saw was colour not being kept between maps, but that's an issue that isn't really solvable due to how the code works in the game IIRC.
For advice on the code you have, I recommend using string.lower on your strings where you have checks for what they are, for example, this:
Code:
elseif SetColor == "red" or SetColor == "Red" or SetColor == "RED" or SetColor == "18"
could be turned into this:
Code:
elseif string.lower(SetColor) == "red" or SetColor == "18"
meaning that you don't need to repeat checks for different capitalisation, and any capitalisation can work. You can also just set SetColor be the string.lower output earlier as well. Also if you want to print multiple lines you can add \n to your print instead of doing multiple prints.

For a more personal note the idea behind it I can't really get behind because you need to be really easily able to see who is on the enemy team in those gamemodes. But the colours seem to be setup alright so that there isn't too much of an issue determining who is on what team.
__________________
Quote:
<MonsterIestyn> try ctrl+f masturbation and get to the point
Sryder13 is offline   Reply With Quote
Old 09-20-2017   #3
Yoshirocks90
Eh, maybe later.
 
Yoshirocks90's Avatar
Default

Ok, quick question, although it's probably simpler than I think, but how would I make a command for changing player 2's color, and out of curiosity, how many people actually use this?
Yoshirocks90 is offline   Reply With Quote
Old 09-20-2017   #4
Lach
Latch? Lock?? Lack???
 
Lach's Avatar
Default

Quote:
Originally Posted by Yoshirocks90 View Post
Ok, quick question, although it's probably simpler than I think, but how would I make a command for changing player 2's color, and out of curiosity, how many people actually use this?
When not playing online, you can guarantee that the client player is always players[0], and in the case of splitscreen, the second player is always players[1]. Thus you can set up a console command for changing Player 2's color by first checking for the global variable splitscreen (true when a 2-player game is active, false if 1P or a netgame), and then modifying the color of players[1]. I believe players[1] is also the bot player when playing as Sonic and Tails, so if you want to add support for that guy as well, check for not netgame instead.
Lach is offline   Reply With Quote
Old 09-21-2017   #5
Yoshirocks90
Eh, maybe later.
 
Yoshirocks90's Avatar
Default

Sorry, I'm not sure how to check player numbers. What would be the line of code for checking player 2?
Yoshirocks90 is offline   Reply With Quote
Old 09-21-2017   #6
Lach
Latch? Lock?? Lack???
 
Lach's Avatar
Default

You know how you use "for player in players.iterate" to access every player in the current game? That works by telling the game to iterate through every entry in the global table "players" and perform an action for each of them—each entry in "players" stores one set of player_t data. But you can also access individual entries of a table by specifying the index value of the entry that you want to access and/or modify, and the way that you do that is using index numbers such as players[0] to access the first player, players[1] to access the second, players[2] to access the third, and so on. So to change the second player's color in splitscreen mode, you would do it like this instead of with an iteration:

Code:
if splitscreen and players[1].mo
    players[1].mo.color = SKINCOLOR_BLUE
end
Lach is offline   Reply With Quote
Old 09-21-2017   #7
Yoshirocks90
Eh, maybe later.
 
Yoshirocks90's Avatar
Default

Ah, thanks. I'll add support for player 2 when I get the chance later.
Yoshirocks90 is offline   Reply With Quote
Old 09-21-2017   #8
Zwip-Zwap Zapony
Please just call me Zappy.
 
Zwip-Zwap Zapony's Avatar
Default

Alternatively, to add splitscreen player 2 support, you can use the exact same function (though you then might want to add a check for if the player exists, not sure), and just set the "flags" value of the command addition line to 2. Something like this:
Spoiler:
Code:
local function teamcolor(player, SetColor)
    if string.lower(SetColor) == "help" or SetColor == none then
        -SNIP TO KEEP THIS POST SHORT-
    elseif string.lower(SetColor) == "zim" or SetColor == "22" then
        if player.ctfteam == 2 then
            player.mo.color = SKINCOLOR_ZIM
        end
    end
end

COM_AddCommand("playercolor", teamcolor)
COM_AddCommand("playercolor2", teamcolor, 2)

COM_AddCommand("listcolors", function(player, TeamRequest)
    if string.lower(TeamRequest) == "help" or TeamRequest == none then
        -SNIP TO KEEP THIS POST SHORT, AGAIN-
    end
end)

Mini-edit: See https://wiki.srb2.org/wiki/Lua/Funct...onsole_library for slightly more information.

Last edited by Zwip-Zwap Zapony; 09-21-2017 at 08:00 PM.
Zwip-Zwap Zapony is online now   Reply With Quote
Old 09-23-2017   #9
Yoshirocks90
Eh, maybe later.
 
Yoshirocks90's Avatar
Default

Alright, the script has been updated for splitscreen support. Use the command 'player2color <color/help>' to change player 2's color. It works the same as 'playercolor'.
Yoshirocks90 is offline   Reply With Quote
Old 4 Weeks Ago   #10
Yoshirocks90
Eh, maybe later.
 
Yoshirocks90's Avatar
Default

Out of curiosity, how many people actually use this?
Yoshirocks90 is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:36 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.