ID:2178134
 
Hi all, i'm currently experimenting with a technique i learned partly from here, and partly from SS13's blood overlay code.

I'm trying to make a teleporter effect which covers someone in swirly energy and conforms to the boundaries of their sprite. It's almost working, i'm 90% of the way there!


The result so far, as can be seen the swirly energy conforms perfectly. This is a ~10 second long .gif, you'll see the animation looping several times over
i.imgur.com/GeA8eYZ.gif

The problem however, is that the sprite used to create this energy is this:

i.imgur.com/SUChI31.png



There are two problems here.
First is that long delay i've set between frames - it should take 20 seconds to complete the animation, not two. This delay is just for debugging to confirm my suspicion that it's not working, my desired delay is 2.5 But it's evidence enough - this animation is playing at a preset delay of 1 decisecond between frames, and ignoring what i've set it to

Secondly, as can be seen there, ive set it to loop once (which basically means don't loop at all. Play from start to finish and then stop.) but as seen in the animation, its looping endlessly

So i need help figuring out these issues

My code is probably relevant
http://pastebin.com/dDXbQ5St

The effect is created by instantiating this object and passing in an atom (like a mob) into new to use as the target to copy the outline from

I copied and modified this from our bloodoverlay code. not looked too closely into how it works yet:
    shape = new /icon(subject.icon, subject.icon_state)
shape.Blend(new /icon('icons/effects/teleport.dmi', rgb(255,255,255)),ICON_ADD) //fills the icon_state with white (except where it's transparent)
shape.Blend(new /icon('icons/effects/teleport.dmi', "fader"),ICON_MULTIPLY) //adds blood and the remaining white areas become transparant


That first blend line doesnt specify an iconstate. The blood overlays use a plain white image as the first icon in the dmi, and it seems to point to that. So i'm thinking i can probably point that at a blank white image elsewhere, but for now i just copied it over

http://i.imgur.com/iUv5ByK.png


It might be relevant that i'm using this swirly effect as an overlay on the teleport object, and using its main icon_state as a different effect - i'm trying to combine two different effects in one object. i'm not exactly sure how to set the icon_state to a programmatically generated icon though
Bump, still need help with this.

I'm having a similar problem with a completely different project too - an animated overlay playing too quickly, this one doesnt even use any masking or blending at all, its just an animated image used as an overlay

Is there a bug at work here? I need some helpp
here, the other issue, i'm not certain if this is related or the same problem, but i'm guessing theres some common root cause

We have this overlay, which is material sliding into a slot on a machine: http://i.imgur.com/mxsWgyT.gifv

its an animation of it sliding in, five frames, total of 1 second. it should be simple enough. It is non looping

We have a couple versions of it where colour is the only real difference. Here's a random test of one of them.

http://i.imgur.com/9xxdDXl.gifv

I did it three times. As can be seen its not working, but SOMETHING is happening. As far as i can tell, its only showing the final frame of the animation

As mentioned, this one is non-looping, and unlike my problem in the OP, seems to be respecting that setting. Out of curiosity i tried altering one of the versions to play looped instead. Everything else is the same

Heres the result of that: http://i.imgur.com/01EJhrz.gifv

Again, this is demonstrated three times in this gif
basically the issue as far as i can tell is that this one starts halfway through instead of at the beginning of the animation. hits the end, and restarts since its looping. Why doesn't it start at the beginning? Who knows. do you?

Code used to trigger these animations

            mat_insert = image('icons/obj/machines/research.dmi', src, "protolathe_[material.name]")
overlays.Add(mat_insert)
world << "Adding overlay: [mat_insert]"
sleep(10)
overlays.Remove(mat_insert)


overlay is added, code waits 1 second, then removes it again

Animated overlays seem completely screwed up, i can't get them working right at all. WHAT is going on?
i have no idea at all what flick is, perhaps you could explain that? will flick ensure that things play once/from the start/at intended speed?

What am i misunderstanding about icon states?
I didn't read through your entire problem so I'm sorry if this isn't what you're looking for. flick() is a visual proc that makes an atom look a particular way for the full duration of the icon state.

As Yut Put mentioned, you cannot flick overlays, so you'll need to create a new obj and then have it flick, it's up to you if you want to del() it afterwards or just throw it's invisibility var to 101 depending on how often this telepot is being used.

Whenever we mention something you don't understand, refer to the dm reference guide: http://www.byond.com/docs/ref/

More specifically, here's everything you need to know about flick():
http://www.byond.com/docs/ref/info.html#/proc/flick

Here's a quick example, be sure to change the sleep() time to the length of your flick()
var/obj/shape = new/obj(src.loc)
flick('icons/effects/teleport.dmi',shape)
sleep(10)
del(shape)
For your first question, I believe the blend proc is blending the animation you want at rate of 1 frame, because that's what the original icon is set to. Specifically because you're using the atom's icon, like so:
shape = new /icon(subject.icon, subject.icon_state)


In terms of the second question, and this may or may not be correct given that I don't have access to a stable test environment, I suspect your issue stems from the proc sleeping without a waitfor setting, effectively freezing the animation until the final frame, when it's removed from overlays. So what's happening is that sleep(10) freezes the animation until the final frame, then the animation ends and is removed. When you repeat the animation, it once again jumps to the last frame after sleep(), then plays the first two frames of the second iteration. Then the overlay is removed.
I'm going to give you my version of the image flick, the ghetto solution to a 511 feature, modified for a generic codebase:

/image/proc/flick_overlay(atom/A, time = 1, flags = RESET_COLOR|RESET_ALPHA|RESET_TRANSFORM|TILE_BOUND)
set waitfor = 0
appearance_flags = flags
A.overlays += src
sleep(time)
if(A && A.loc) A.overlays -= src


Appearance flags tell the image to ignore those parameters when attached to an object. You generally want this, but not always. A and A.loc check to see if the object hasn't been garbage collected yet, as a lot of codebases use qdel(). The rest should be self explanatory. You can override these parameters after creating the image, so read up on what the appearance flags do.
I usually call this through an animation proc, but it can be called through whatever you want.

So it would look something like this:

var/image/I = image('icons/obj/machines/research.dmi', src, "protolathe_[material.name]")
I.flick_overlay(src, 10)