[Cubescript] GUIRADIO help

[Cubescript] GUIRADIO help

Postby ZeroKnight » 23 Sep 2011, 22:52

Yes I know, yet another thread about Zero asking for CS help :P This time it's GUIRADIO. I've come to understand that the radio settings are remembered by it's second and third parameter, but, it only accepts floats as far as I know. What I'm trying to accomplish is an updated feature to the Color Chat script. I made it so you could pick the color presets from the letter color codes, and then quin revealed to me that you can use HEX codes as well, so then I integrated that. The problem lies with the letter codes. I'd like to keep them with GUIRADIO, but I can't use a letter for the third parameter in GUIRADIO to keep the setting remembered.
I can work around it in a rather ugly way by using a second variable, and setting it when that radio is selected, but it also means having to keep extra aliases in ecdata in order for the settings to be remembered.

{l Code}: {l Select All Code}
guiradio   "ssfsi"
Ex: guiradio "" foo 1 [alias bar 1]
    guiradio "" foo 2 [alias bar 2]
    guiradio "" foo 3 [alias foobar 100]


It uses the third param as a sort of index, to associate the radio selection with whatever it initializes or does. Now take my code for example (excuse the lengthy-ness, I've yet to trim it to use a function)

{l Code}: {l Select All Code}
//////////////////////////////////////////////////////////////////////////////
/// Color Chat Script
///
/// Author: HTN-Kitsune
///     Minor edits for Extended Compass by ZeroKnight
///
//////////////////////////////////////////////////////////////////////////////


newgui Chat_Colors [
    guiheader "Chat Color"
    guilist [
        guilist [
            guiradio "^fgGreen (default)" chatcolorindex 0 [alias chatcolor "g"; alias chatcolorindex 0]
            guiradio "^fGDark Green" chatcolorindex 1 [alias chatcolor "G"; alias chatcolorindex 1]
            guiradio "^fbBlue" chatcolorindex 2 [alias chatcolor "b"; alias chatcolorindex 2]
            guiradio "^fBDark Blue" chatcolorindex 3 [alias chatcolor "B"; alias chatcolorindex 3]
            guiradio "^fyYellow" chatcolorindex 4 [alias chatcolor "y"; alias chatcolorindex 4]
            guiradio "^fYDark Yellow" chatcolorindex 5 [alias chatcolor "Y"; alias chatcolorindex 5]
            guiradio "^frRed" chatcolorindex 6 [alias chatcolor "r"; alias chatcolorindex 6]
            guiradio "^fRDark Red" chatcolorindex 7 [alias chatcolor "R"; alias chatcolorindex 7]
            guiradio "^fePale Red" chatcolorindex 8 [alias chatcolor "e"; alias chatcolorindex 8]
            guiradio "^faGrey" chatcolorindex 9 [alias chatcolor "a"; alias chatcolorindex 9]
            guiradio "^fADark Grey" chatcolorindex 10 [alias chatcolor "A"; alias chatcolorindex 10]
        ]
        guistrut 2
        guilist [   
            guiradio "^fmPink" chatcolorindex 11 [alias chatcolor "m"; alias chatcolorindex 11]
            guiradio "^fvPurple" chatcolorindex 12 [alias chatcolor "v"; alias chatcolorindex 12]
            guiradio "^foOrage" chatcolorindex 13 [alias chatcolor "o"; alias chatcolorindex 13]
            guiradio "^fODark Orage" chatcolorindex 14 [alias chatcolor "O"; alias chatcolorindex 14]
            guiradio "^fwWhite" chatcolorindex 15 [alias chatcolor "w"; alias chatcolorindex 15]
            guiradio "^fkBlack" chatcolorindex 16 [alias chatcolor "k"; alias chatcolorindex 16]
            guiradio "^fcCyan" chatcolorindex 17 [alias chatcolor "c"; alias chatcolorindex 17]
            guiradio "^fCTeal" chatcolorindex 18 [alias chatcolor "C"; alias chatcolorindex 18]
            guiradio "^fnBrown" chatcolorindex 19 [alias chatcolor "n"; alias chatcolorindex 19]
        ]
    ]
    guistrut 2
    guifont radar [ guitext "Custom Color (Hexadecimal)"]
    guilist [
        guiradio "" chatcolorindex 20 [alias chatcolorindex 20]
        guifield customChatColor 6 [alias chatcolor $customChatColor]
    ]
    guistrut 2
    guifont radar [ guitext "Keys: T - Chat, Y - Team, U - /me, I - Team /me" ]
   

guitab "Team Chat Color"
    guilist [
        guilist [
            guiradio "^fgGreen (default)" tchatcolorindex 0 [alias tchatcolor "g"; alias tchatcolorindex 0]
            guiradio "^fGDark Green" tchatcolorindex 1 [alias tchatcolor "G"; alias tchatcolorindex 1]
            guiradio "^fbBlue" tchatcolorindex 2 [alias tchatcolor "b"; alias tchatcolorindex 2]
            guiradio "^fBDark Blue" tchatcolorindex 3 [alias tchatcolor "B"; alias tchatcolorindex 3]
            guiradio "^fyYellow" tchatcolorindex 4 [alias tchatcolor "y"; alias tchatcolorindex 4]
            guiradio "^fYDark Yellow" ttchatcolorindex 5 [alias tchatcolor "Y"; alias tchatcolorindex 5]
            guiradio "^frRed" tchatcolorindex 6 [alias tchatcolor "r"; alias tchatcolorindex 6]
            guiradio "^fRDark Red" tchatcolorindex 7 [alias tchatcolor "R"; alias tchatcolorindex 7]
            guiradio "^fePale Red" tchatcolorindex 8 [alias tchatcolor "e"; alias tchatcolorindex 8]
            guiradio "^faGrey" tchatcolorindex 9 [alias tchatcolor "a"; alias tchatcolorindex 9]
            guiradio "^fADark Grey" tchatcolorindex 10 [alias tchatcolor "A"; alias tchatcolorindex 10]
        ]
        guistrut 2
        guilist [   
            guiradio "^fmPink" tchatcolorindex 11 [alias tchatcolor "m"; alias tchatcolorindex 11]
            guiradio "^fvPurple" tchatcolorindex 12 [alias tchatcolor "v"; alias tchatcolorindex 12]
            guiradio "^foOrage" tchatcolorindex 13 [alias tchatcolor "o"; alias tchatcolorindex 13]
            guiradio "^fODark Orage" tchatcolorindex 14 [alias tchatcolor "O"; alias tchatcolorindex 14]
            guiradio "^fwWhite" tchatcolorindex 15 [alias tchatcolor "w"; alias tchatcolorindex 15]
            guiradio "^fkBlack" tchatcolorindex 16 [alias tchatcolor "k"; alias tchatcolorindex 16]
            guiradio "^fcCyan" tchatcolorindex 17 [alias tchatcolor "c"; alias tchatcolorindex 17]
            guiradio "^fCTeal" tchatcolorindex 18 [alias tchatcolor "C"; alias tchatcolorindex 18]
            guiradio "^fnBrown" tchatcolorindex 19 [alias tchatcolor "n"; alias tchatcolorindex 19]
        ]
    ]
    guistrut 2
    guifont radar [ guitext "Custom Color (Hexadecimal)"]
    guilist [
        guiradio "" tchatcolorindex 20 [alias tchatcolorindex 20]
        guifield customTChatColor 6 [alias tchatcolor $customTChatColor]
    ]
    guistrut 2
    guifont radar [ guitext "Keys: T - Chat, Y - Team, U - /me, I - Team /me" ]

   
guitab "/me Color"
    guilist [
        guilist [
            guiradio "^fgGreen (default)" mchatcolorindex 0 [alias mchatcolor "g"; alias mchatcolorindex 0]
            guiradio "^fGDark Green" mchatcolorindex 1 [alias mchatcolor "G"; alias mchatcolorindex 1]
            guiradio "^fbBlue" mchatcolorindex 2 [alias mchatcolor "b"; alias mchatcolorindex 2]
            guiradio "^fBDark Blue" mchatcolorindex 3 [alias mchatcolor "B"; alias mchatcolorindex 3]
            guiradio "^fyYellow" mchatcolorindex 4 [alias mchatcolor "y"; alias mchatcolorindex 4]
            guiradio "^fYDark Yellow" mchatcolorindex 5 [alias mchatcolor "Y"; alias mchatcolorindex 5]
            guiradio "^frRed" mchatcolorindex 6 [alias mchatcolor "r"; alias mchatcolorindex 6]
            guiradio "^fRDark Red" mchatcolorindex 7 [alias mchatcolor "R"; alias mchatcolorindex 7]
            guiradio "^fePale Red" mchatcolorindex 8 [alias mchatcolor "e"; alias mchatcolorindex 8]
            guiradio "^faGrey" mchatcolorindex 9 [alias mchatcolor "a"; alias mchatcolorindex 9]
            guiradio "^fADark Grey" mchatcolorindex 10 [alias mchatcolor "A"; alias mchatcolorindex 10]
        ]
        guistrut 2
        guilist [   
            guiradio "^fmPink" mchatcolorindex 11 [alias mchatcolor "m"; alias mchatcolorindex 11]
            guiradio "^fvPurple" mchatcolorindex 12 [alias mchatcolor "v"; alias mchatcolorindex 12]
            guiradio "^foOrage" mchatcolorindex 13 [alias mchatcolor "o"; alias mchatcolorindex 13]
            guiradio "^fODark Orage" mchatcolorindex 14 [alias mchatcolor "O"; alias mchatcolorindex 14]
            guiradio "^fwWhite" mchatcolorindex 15 [alias mchatcolor "w"; alias mchatcolorindex 15]
            guiradio "^fkBlack" mchatcolorindex 16 [alias mchatcolor "k"; alias mchatcolorindex 16]
            guiradio "^fcCyan" mchatcolorindex 17 [alias mchatcolor "c"; alias mchatcolorindex 17]
            guiradio "^fCTeal" mchatcolorindex 18 [alias mchatcolor "C"; alias mchatcolorindex 18]
            guiradio "^fnBrown" mchatcolorindex 19 [alias mchatcolor "n"; alias mchatcolorindex 19]
        ]
    ]
    guistrut 2
    guifont radar [ guitext "Custom Color (Hexadecimal)"]
    guilist [
        guiradio "" mchatcolorindex 20 [alias mchatcolorindex 20]
        guifield customMChatColor 6 [alias mchatcolor $customMChatColor]
    ]
    guistrut 2
    guifont radar [ guitext "Keys: T - Chat, Y - Team, U - /me, I - Team /me" ]

   
guitab "Team /me Color"
    guilist [
        guilist [
            guiradio "^fgGreen (default)" tmchatcolorindex 0 [alias tmchatcolor "g"; alias tmchatcolorindex 0]
            guiradio "^fGDark Green" tmchatcolorindex 1 [alias tmchatcolor "G"; alias tmchatcolorindex 1]
            guiradio "^fbBlue" tmchatcolorindex 2 [alias tmchatcolor "b"; alias tmchatcolorindex 2]
            guiradio "^fBDark Blue" tmchatcolorindex 3 [alias tmchatcolor "B"; alias tmchatcolorindex 3]
            guiradio "^fyYellow" tmchatcolorindex 4 [alias tmchatcolor "y"; alias tmchatcolorindex 4]
            guiradio "^fYDark Yellow" tmchatcolorindex 5 [alias tmchatcolor "Y"; alias tmchatcolorindex 5]
            guiradio "^frRed" tmchatcolorindex 6 [alias tmchatcolor "r"; alias tmchatcolorindex 6]
            guiradio "^fRDark Red" tmchatcolorindex 7 [alias tmchatcolor "R"; alias tmchatcolorindex 7]
            guiradio "^fePale Red" tmchatcolorindex 8 [alias tmchatcolor "e"; alias tmchatcolorindex 8]
            guiradio "^faGrey" tmchatcolorindex 9 [alias tmchatcolor "a"; alias tmchatcolorindex 9]
            guiradio "^fADark Grey" tmchatcolorindex 10 [alias tmchatcolor "A"; alias tmchatcolorindex 10]
        ]
        guistrut 2
        guilist [
            guiradio "^fmPink" tmchatcolorindex 11 [alias tmchatcolor "m"; alias tmchatcolorindex 11]
            guiradio "^fvPurple" tmchatcolorindex 12 [alias tmchatcolor "v"; alias tmchatcolorindex 12]
            guiradio "^foOrage" tmchatcolorindex 13 [alias tmchatcolor "o"; alias tmchatcolorindex 13]
            guiradio "^fODark Orage" tmchatcolorindex 14 [alias tmchatcolor "O"; alias tmchatcolorindex 14]
            guiradio "^fwWhite" tmchatcolorindex 15 [alias tmchatcolor "w"; alias tmchatcolorindex 15]
            guiradio "^fkBlack" tmchatcolorindex 16 [alias tmchatcolor "k"; alias tmchatcolorindex 16]
            guiradio "^fcCyan" tmchatcolorindex 17 [alias tmchatcolor "c"; alias tmchatcolorindex 17]
            guiradio "^fCTeal" tmchatcolorindex 18 [alias tmchatcolor "C"; alias tmchatcolorindex 18]
            guiradio "^fnBrown" tmchatcolorindex 19 [alias tmchatcolor "n"; alias tmchatcolorindex 19]
        ]
    ]
    guistrut 2
    guifont radar [ guitext "Custom Color (Hexadecimal)"]
    guilist [
        guiradio "" tmchatcolorindex 20 [alias tmchatcolorindex 20]
        guifield customTMChatColor 6 [alias tmchatcolor $customTMChatColor]
    ]
    guistrut 2
    guifont radar [ guitext "Keys: T - Chat, Y - Team, U - /me, I - Team /me" ]
]


//the bindings, these have both a + and a -
//they disable the ability to add a / to do commands
//so unlike Q3A and such those must be down old school.
chatcolorcheck = [ if (> (strlen $chatcolor) 1) [inputcommand (concatword "^f[0x" $chatcolor "]") [say $commandbuffer]] [inputcommand (concatword "^f" $chatcolor) [say $commandbuffer]] ]
bind T chatcolorcheck

tchatcolorcheck = [ if (> (strlen $tchatcolor) 1) [inputcommand (concatword "^f[0x" $tchatcolor "]") [say $commandbuffer]] [inputcommand (concatword "^f" $tchatcolor) [say $commandbuffer]] ]
bind Y tchatcolorcheck

mchatcolorcheck = [ if (> (strlen $mchatcolor) 1) [inputcommand (concatword "^f[0x" $mchatcolor "]") [say $commandbuffer]] [inputcommand (concatword "^f" $mchatcolor) [say $commandbuffer]] ]
bind U mchatcolorcheck

tmchatcolorcheck = [ if (> (strlen $tmchatcolor) 1) [inputcommand (concatword "^f[0x" $tmchatcolor "]") [say $commandbuffer]] [inputcommand (concatword "^f" $tmchatcolor) [say $commandbuffer]] ]
bind I tmchatcolorcheck


Notice how I'm relying on: "*index # [...] alias *index #" to make up for the fact that the color codes are letters. I'd like to keep the 20 "letter color" presets, as it will provide users a way to use "RE's colors", and not have to go and get a HEX code. Quick and easy. As far as how I'm doing it, I can think of a few ways to go about this. I'd like some input or better ideas and suggestions. I want to make Extended Compass as best as it can possibly be, so please. Offer your wisdom ^^

  • I could either just go with having to include these index vars in ecdata, as it's just a data file and wont really matter. However, is there a way I could "trick" it into accepting the letter values somehow? Or is there some other way it could be done?
  • If those letter codes have an actual HEX value associated with them, is there a way to get them? I could just replace the letters in the script with their associated HEX value. It would work with GUIRADIO's params, it would eliminate the need to check if it's using a letter or custom color in order to properly set up the console for the chat, and I'd still have the 20 presets. It would be streamlined.
  • Any other kind of idea, trick, hack, workaround?

I'm bad at explaining what I'm trying to get at, so if I wasn't clear, please feel free to request clarification.
[ Github ][ WazuClan -- irc.wazuclan.com #wazuclan ][ Zero's Archive of RE Extensions, Scripts, WeapMods & More! ]
User avatar
ZeroKnight
 
Posts: 524
Joined: 08 Jun 2011, 01:24
Location: Ohio, United States

Re: [Cubescript] GUIRADIO help

Postby Phy83r0pt1k » 24 Sep 2011, 03:01

Zeroknight, dont put [] after it, just the alais and value. thats how i always got guiradio to work.
Phy83r0pt1k
 
Posts: 39
Joined: 20 Aug 2011, 04:28

Re: [Cubescript] GUIRADIO help

Postby qreeves » 24 Sep 2011, 06:11

Okay, try this:
{l Code}: {l Select All Code}
chatcolours = [ r o y g b i v ] // colours sorted by index
chatcnames = [ red orange yellow green blue indigo violet ] // colour names in each index
chatcolour = 0 // the current index

Then you can:
{l Code}: {l Select All Code}
colours = (listlen $chatcolours) // dynamically get the number of colours in the chatcolour array
loop i $colours [
    guiradio (at $chatcnames $i) chatcolour $i [chatcolour = $i] // loop each colour and create a radio box for it
]

And when you want to create the colour code:
{l Code}: {l Select All Code}
sayincolour = [ say (format "^f%1%2" (at $chatcolours $chatcolour) $arg1) ]

Or thereabouts. I suck at cubescript, but that is the gist of it. Anyone with more/better/correct info feel free to chime in.
Quinton "quin" Reeves | Lead Developer, Red Eclipse | http://redeclipse.net/ | http://www.facebook.com/redeclipse.net
User avatar
qreeves
 
Posts: 1294
Joined: 17 Mar 2011, 03:46
Location: Queensland, Australia

Re: [Cubescript] GUIRADIO help

Postby ZeroKnight » 24 Sep 2011, 19:28

Woah, I don't think I would have ever thought of that. It also keeps things compact since it's looped. Thanks quin ^_^
I'll try this out later on, so I'll reply back on whether it works or not. Looking at it, I'm pretty sure it should.

Quick question, what exactly does "at" do in the code? I've seen it in menus.cfg, but couldn't figure out what it did. Does it just specify what "word" to jump to?
[ Github ][ WazuClan -- irc.wazuclan.com #wazuclan ][ Zero's Archive of RE Extensions, Scripts, WeapMods & More! ]
User avatar
ZeroKnight
 
Posts: 524
Joined: 08 Jun 2011, 01:24
Location: Ohio, United States

Re: [Cubescript] GUIRADIO help

Postby qreeves » 25 Sep 2011, 16:27

ZeroKnight {l Wrote}:Quick question, what exactly does "at" do in the code? I've seen it in menus.cfg, but couldn't figure out what it did. Does it just specify what "word" to jump to?

Yeah, but from a programmer point of view. 0 is the first word, 1 is the second, etc. It's basically a way to do arrays with cubescript.
Quinton "quin" Reeves | Lead Developer, Red Eclipse | http://redeclipse.net/ | http://www.facebook.com/redeclipse.net
User avatar
qreeves
 
Posts: 1294
Joined: 17 Mar 2011, 03:46
Location: Queensland, Australia

Re: [Cubescript] GUIRADIO help

Postby ZeroKnight » 26 Sep 2011, 17:53

Ah, I had a feeling it was selecting an entity in an array, but I just wanted to make sure ^^

Thank you, quin! That worked beautifully! You've given me quite a lot of pointers and help, and I've learned quite a bit from you. (both directly, and indirectly by referencing your code ;P)
For that reason, I added you to my credits in Extended Compass. ^^ (which I'll be updating today)

This thread can be considered closed. Got what I needed and more. Just wanted to say thanks~
[ Github ][ WazuClan -- irc.wazuclan.com #wazuclan ][ Zero's Archive of RE Extensions, Scripts, WeapMods & More! ]
User avatar
ZeroKnight
 
Posts: 524
Joined: 08 Jun 2011, 01:24
Location: Ohio, United States

Re: [Cubescript] GUIRADIO help

Postby srbs » 28 Sep 2011, 04:59

One thing to note: quoted strings are considered 1 word
so:
var = [this is a "cool string"]
echo (at $var 3)

output:
cool string

srbs
srbs
 
Posts: 94
Joined: 17 Mar 2011, 07:00

Who is online

Users browsing this forum: No registered users and 1 guest

cron