ID:273171
 
I'm working on a 16-bit team-based game, where each player is a big icon (native) that is 64x64

To swap the 6 colors of each player takes roughly 6-12 seconds on meh slowish computer

Is there any way to improve these times?
If one SwapColor() call is taking 6-12 seconds there's really nothing you can do besides not use it.

If you are making five hundred SwapColor() calls, then the solution is to not make five hundred SwapColor() calls.

Strangely enough, specific advice is not possible without seeing any code.
In response to Garthor (#1)
mob/verb
Change_Color(var/T in list("Default","Chaos","Assault","Guard"))
usr.ColorProc(T)

mob
proc
ColorProc(var/T="")
if(src)
var/change1=src.defaultcolor1
var/change2=src.defaultcolor2
var/change3=src.defaultcolor3
var/change4=src.defaultcolor4
var/change5=src.defaultcolor5
var/change6=src.defaultcolor6
switch(T)
if("Assault")
change1=rgb(0,128,248) //Darker Shade (Main)
change2=rgb(32,48,128) //Darker Shade (Shadow)
change3=rgb(0,64,240) //Darker Shade (Shadow's Border)
change4=rgb(240,20,20) //Lighter Shade (Main)
change5=rgb(200,0,0) //Lighter Shade (Shadow)
change6=rgb(220,40,40) //Lighter Shade (Border)
if("Guard")
change1=rgb(242,242,242) //Darker Shade (Main)
change2=rgb(140,140,140) //Darker Shade (Shadow)
change3=rgb(200,200,200) //Darker Shade (Shadow's Border)
change4=rgb(10,168,255) //Lighter Shade (Main)
change5=rgb(0,138,250) //Lighter Shade (Shadow)
change6=rgb(0,128,248) //Lighter Shade (Border)
if("Chaos")
change1=rgb(60,60,60) //Darker Shade (Main)
change2=rgb(30,30,30) //Darker Shade (Shadow)
change3=rgb(40,40,40) //Darker Shade (Shadow's Border)
change4=rgb(255,153,0) //Lighter Shade (Main)
change5=rgb(200,110,0) //Lighter Shade (Shadow)
change6=rgb(144,143,0) //Lighter Shade (Border)
spawn(0)
src.ColorSwap(src.icon,change1,change2,change3,change4,change5,change6,src.currentcolor1,src.currentcolor2,src.currentcolor3,src.currentcolor4,src.currentcolor5,src.currentcolor6)


ColorSwap(var/icon/iconinput=src.icon,change1=src.defaultcolor1,change2=src.defaultcolor2,change3=src.defaultcolor3,change4=src.defaultcolor4,change5=src.defaultcolor5,change6=src.defaultcolor6,text=src.currentcolor1,text2=src.currentcolor2,text3=src.currentcolor3,text4=src.currentcolor4,text5=src.currentcolor5,text6=src.currentcolor6)
var/icon/Q = new(iconinput)
Q.SwapColor(text,change1)
Q.SwapColor(text2,change2)
Q.SwapColor(text3,change3)
Q.SwapColor(text4,change4)
Q.SwapColor(text5,change5)
Q.SwapColor(text6,change6)
src.currentcolor1=change1
src.currentcolor2=change2
src.currentcolor3=change3
src.currentcolor4=change4
src.currentcolor5=change5
src.currentcolor6=change6
src.icon=Q
In response to Mista-mage123 (#2)
rgb() isn't all that fast either.
In response to Haywire (#3)
Should have given more info, but yeah, try entering the hex of the colours directly instead of getting rgb() to convert the 3 numbers, and then check out the speed. It should speed the procedure up a bit.

Here's a converter: http://www.javascripter.net/faq/rgbtohex.htm

( Just incase you don't know how to do it by yourself, and even then I would rather get the computer to do it for me rather than doing it mentally :P )

You can represent Hex in DM by placing the "0x" prefix before the hex (e.g FFF).

I haven't worked with hex much in DM so I'm not sure how many digits DM limits hex to, but from what Popisfizzy has told me it's about 3-4.

Good luck!
In response to Haywire (#4)
I've isolated the problem using ''tick tests'. The ticks arent actually lost during the SwapColor() calls, ONE ENTIRE SECOND was used just switching the icon

Should icon changes take an ENTIRE SECOND? Maybe native icons arent so good when it comes to switching them...
In response to Mista-mage123 (#5)
The problem is that, while all the datum changes are simple, it takes more CPU to take that datum and make it into an actual icon.