ID:2427440
 
(See the best response by Lummox JR.)
Code: https://www.dropbox.com/s/a26vt292tpzxlij/ Bar%20Demo_src.zip?dl=0
obj/bar

red_bar
icon = 'icons/bar.dmi'
icon_state = "red"
screen_loc = "5,7"

New()
..()

spawn()

filters += filter(type="drop_shadow",x=0,y=0,size=5,offset=2,color = rgb(255,0,0,0))
var/G = filters[filters.len]

do

animate(G,color=rgb(255,0,0,255),time = 10,flags = ANIMATION_END_NOW)
sleep(10)
animate(G,color=rgb(255,0,0,150),time = 10,flags = ANIMATION_END_NOW)
sleep(10)

while(1)

green_bar
icon = 'icons/bar.dmi'
icon_state = "green"
screen_loc = "5,6"

New()
..()

spawn()

filters += filter(type="drop_shadow",x=0,y=0,size=5,offset=2,color = rgb(0,255,0,0))
var/G = filters[filters.len]

do

animate(G,color=rgb(0,255,0,255),time = 10,flags = ANIMATION_PARALLEL)
sleep(10)
animate(G,color=rgb(0,255,0,150),time = 10,flags = ANIMATION_PARALLEL)
sleep(10)

while(1)

blue_bar
icon = 'icons/bar.dmi'
icon_state = "blue"
screen_loc = "5,5"

New()
..()

spawn()

filters += filter(type="drop_shadow",x=0,y=0,size=5,offset=2,color = rgb(0,0,255,0))
var/G = filters[filters.len]

do

animate(G,color=rgb(0,0,255,255),time = 10,flags = ANIMATION_PARALLEL)
sleep(10)
animate(G,color=rgb(0,0,255,150),time = 10,flags = ANIMATION_PARALLEL)
sleep(10)

while(1)

mob/var

obj
red_bar = new /obj/bar/red_bar
green_bar = new /obj/bar/green_bar
blue_bar = new /obj/bar/blue_bar

bar_started = 0

mob/verb

update_bar()

if(bar_started) {bar_started = 0;return}
else bar_started = 1

var
GX = 0
BX = 64

while(bar_started)

if(GX) GX = 0
else GX = 64

var
matrix/M1 = new
matrix/M2 = new

M1.Translate(32,0)
M1.Scale(max(min(ceil(GX * 64 / 64),64),0) / 64,1)
M1.Translate(-32,0)

animate(green_bar,transform = M1,time = 10,flags = ANIMATION_PARALLEL)

if(BX) BX = 0
else BX = 64

M2.Translate(32,0)
M2.Scale(max(min(ceil(BX * 64 / 64),64),0) / 64,1)
M2.Translate(-32,0)

animate(blue_bar,transform = M2,time = 10,flags = ANIMATION_PARALLEL)

sleep(10)

flash_bar()

animate(red_bar,color = list(1,1,1, 1,1,1, 1,1,1, 0,0,0),time = 2,loop = 2,flags = ANIMATION_PARALLEL)
animate(green_bar,color = list(1,1,1, 1,1,1, 1,1,1, 0,0,0),time = 2,loop = 2,flags = ANIMATION_PARALLEL)
animate(blue_bar,color = list(1,1,1, 1,1,1, 1,1,1, 0,0,0),time = 2,loop = 2,flags = ANIMATION_PARALLEL)

sleep(4)

red_bar.color = null
green_bar.color = null
blue_bar.color = null

Problem description:

So I created a demo that sorta demonstrates my issue and hope that someone can clarify things for me or help me figure out what I'm doing wrong. The demo kinda showcases some ideas I wanted to do specifically the bars will have a glowing effect at certain points and will flash to indicate they are ready. Unfortunately I can't seem to get this right as when the flashing comes into play it messes with the filters. Basically I want the bar to flash white not the glow effect if it was enabled. For the purpose of the demo I made it to where as many things could be active at once to test if they are all capable and so far it's mainly the colors that are driving me crazy.

EDIT: For whatever reason when I uploaded the demo it didn't put in all the files you'd need to run it. Should be fixed now.
It'd be easier if you post snippets of the code here as well. Otherwise only people at their main computer who also feel like compiling and playing with your project can help.
I agree but it's a lot I mean if you want I can post I can't remember if there are limits.
Can't you just do animate(bar,color="#ffffff",time=10)
it still messes with the filters color
Check out appearance flags
Appearance Flags don't appear to have an impact. I'm thinking you wanted me to use KEEP_APART right? If so this has been tried. What happens is that the the bars flash white taking the filter with it more so it seems to cause some lag as well as colors will sometimes take a moment to restore themselves.

Overall what I want is that each animation should be considered independent of one another. Pulsing Color, Flashing, and Resizing could happen depending on circumstances if they can't all happen at the same time then this will appear laggy.

    flash_bar()

animate(red_bar,color = list(1,1,1, 1,1,1, 1,1,1, 0,0,0),time = 1,flags = ANIMATION_PARALLEL)
animate(green_bar,color = list(1,1,1, 1,1,1, 1,1,1, 0,0,0),time = 1,flags = ANIMATION_PARALLEL)
animate(blue_bar,color = list(1,1,1, 1,1,1, 1,1,1, 0,0,0),time = 1,flags = ANIMATION_PARALLEL)

sleep(1)

animate(red_bar,color = null,time = 1,flags = ANIMATION_PARALLEL)
animate(green_bar,color = null,time = 1,flags = ANIMATION_PARALLEL)
animate(blue_bar,color = null,time = 1,flags = ANIMATION_PARALLEL)


I tried the above coding as well and it doesn't work but more importantly the colors will briefly stick to black for awhile. I have no idea why its doing this. Also to see more about what's happening with the filter and the bar I changed it to a grey background since black is too much and white blends in if you change it to grey you can see how the filter is reacting to the color change as well.

        red_bar.color = list(1,1,1, 1,1,1, 1,1,1, 0,0,0)
green_bar.color = list(1,1,1, 1,1,1, 1,1,1, 0,0,0)
blue_bar.color = list(1,1,1, 1,1,1, 1,1,1, 0,0,0)

sleep(1)

red_bar.color = null
green_bar.color = null
blue_bar.color = null

sleep(1)

red_bar.color = list(1,1,1, 1,1,1, 1,1,1, 0,0,0)
green_bar.color = list(1,1,1, 1,1,1, 1,1,1, 0,0,0)
blue_bar.color = list(1,1,1, 1,1,1, 1,1,1, 0,0,0)

sleep(1)

red_bar.color = null
green_bar.color = null
blue_bar.color = null


So after a few attempts of working on this I found it was better to not use animate to flash the bar. It still turns the filter white but at least it appears less laggy so it's not as bad. I'm thinking running too many animates on an obj appears to cause problems.
Best response
First, an important observation: you could save yourself a lot of repeated code and icons by using just one icon for all the bars, and having a default color for each bar.

Animations should not cause any more lag than changing the appearance directly; that's not how they work. The problem you had was, you were using animate() all wrong.

If you want to temporarily change a value in animate(), you'd do it this way:

animate(src, pixel_x = 32, time=10)
animate(pixel_x = 0, time = 10

You should not sleep between animate() calls, but instead string the animation commands together into one sequence.

I would suggest redoing the code like this, using a white bar icon:

obj/bar
icon = 'icons/bar.dmi'

New()
..()
filters += filter(type="drop_shadow",x=0,y=0,size=5,offset=2,color=src.color)
animate(filters[filters.len], alpha=150, time=10, easing=SINE_EASING)
animate(alpha=255, time=10, easing=SINE_EASING)

proc/Flash(flashcolor = "#fff", count=3)
animate(src, color = list("#000", "#000", "#000", flashcolor), time=1, loop=count)
animate(color = initial(src.color), time=1)

red_bar
color = "#f00"
screen_loc = "5,7"
green_bar
color = "#0f0"
screen_loc = "5,6"
blue_bar
color = "#00f"
screen_loc = "5,5"
Apologies I didn't see your response. That being said you bring up a good point about the bars. I'm so used to the old method of doing icons but I really should be using color like this more often lol.

I'm going to give this another test and see how it turns out.

EDIT:

Alright so I gave this a shot to see if I could get it working. I fixed it so bar.dmi is just a white line with no icon state. I then adjusted it obj/bar as follows.

obj/bar

icon = 'icons/bar.dmi'

red_bar
color = "#F00"
screen_loc = "5,7"

green_bar
color = "#0F0"
icon = 'icons/bar.dmi'
screen_loc = "5,6"

blue_bar
color = "#00F"
icon = 'icons/bar.dmi'
screen_loc = "5,5"

New()
..()
filters += filter(type="drop_shadow",x=0,y=0,size=5,offset=2,color=src.color)
animate(filters[filters.len], alpha=150, time = 1, easing=SINE_EASING)
animate(alpha = 255, time=1, easing = SINE_EASING)

proc

Flash(flashcolor = "#FFF", count=3)
animate(src, color = list("#000", "#000", "#000", flashcolor), time = 1, loop=count)
animate(color = initial(src.color), time=1)


the flash_bar() was defined to use red_bar.Flash() and so forth so that it calls correctly. The issue is that the pulse is no longer present from the filter it's just one solid color and the flash keeps the icon white below is a screenshot and the icon just keeps it here as it is.

Just to sorta shed light on what it is I was hoping to do. I wanted the bars to pulse when a condition was present indicating it was being boosted. I wanted it to flash white to indicate the bar is ready. I could just change color to white etc if I wanted to but I'd rather try to figure out how I can incorporate animate() into it as it would have a smoother feel.

Here it is before:


Here it is after:
Any chance you can shoot me a test project for this so I can make some comparisons? Since this is a still image I can't see why it's not animating.
Sorry I took so long to get back to you on this, but I do have an answer.

It looks like most of this chalks up to my mistakes in the animate() calls.

First, there is no alpha value for filters; I don't know what I was thinking. This is what obj/bar/New() should look like:
    New()
..()
filters += filter(type="drop_shadow", x = 0,y = 0,size = 5,offset = 2,color = src.color)
var c = filters[filters.len].color
animate(filters[filters.len], color=copytext(c,1,8)+"99", time = 10, loop=-1, easing = SINE_EASING)
animate(color=c, time = 10, loop=-1, easing = SINE_EASING)

Instead of setting alpha, I just set the whole color including an alpha value. Since the filter uses a non-matrix color, it'll read back as either an RGB or RGBA string, so the copytext() just chops off the last 2 hex digits if there are any, and "99" is added for an alpha of 153 (60% opacity).

For the flash, I screwed up the matrix. There might be a bug in short-form matrix interpretation, or I wrote it that way on purpose and forgot, but there should be five arguments instead of four: a null gets inserted into the fourth place.
    proc
Flash(flashcolor = "#FFF", count=3)
animate(src, color = list("#000", "#000", "#000", null, flashcolor), time = world.tick_lag, loop = count)
animate(color = initial(src.color), time = world.tick_lag)

Those changes fix the pulsing and flashing behavior.

Login to reply.