Using dissolves on an NPC's walkabout sprite

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
FnrrfYgmSchnish
Metal Slime
Posts: 741
Joined: Thu Jun 18, 2009 4:37 am
Location: Middle of Nowhere

Using dissolves on an NPC's walkabout sprite

Post by FnrrfYgmSchnish »

Hey, just tried fiddling around with this new feature and it came up with a script error when my game's script actually got to the point where the dissolve would come up. I'm assuming this is because I have no idea what I'm doing with this feature, since I don't have too much experience with slices in general.

Here's the relevant chunk of script:

Code: Select all

	set npc direction(8,west)
	play sound(4)
	wait(20)
	show textbox(576)
	wait for textbox
	wait(10)
	dissolve sprite(get npc slice(8),dissolve:flicker,20,0,false,true)
	play sound(38)
	wait(20)
	destroy npc(8)
A boss's NPC falls down and gets surrounded by electricity, has a final textbox, and then flickers away as my SFXR'ed "boss death" sound (which some of you may know as the BossDeath.ogg included with Custom) plays.

Or at least, that's what's supposed to happen.

Instead, everything works up until the flicker is supposed to happen, and then I get a message along the lines of "Slice handle 1 is not a sprite."

So... what's the actual way to get this working?
Last edited by FnrrfYgmSchnish on Mon Jan 26, 2015 7:25 pm, edited 1 time in total.
FYS:AHS -- Working on Yagziknian NPC walkabout sprites
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7660
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

The problem is in this line:

Code: Select all

dissolve sprite(get npc slice(8),dissolve:flicker,20,0,false,true) 
the "get npc slice()" command actually returns a 20x20 container slice, not the sprite. The sprite is attached as a child of the container.

Here is how I would write it:

Code: Select all

variable(spr)
spr := lookup slice(get npc slice(8), sl:walkabout sprite component)
dissolve sprite(spr,dissolve:flicker,20) 
Notice also that I left out the arguments at the end of "dissolve sprite", since those were exactly the same as the defaults, there is no need to write them
User avatar
FnrrfYgmSchnish
Metal Slime
Posts: 741
Joined: Thu Jun 18, 2009 4:37 am
Location: Middle of Nowhere

Post by FnrrfYgmSchnish »

I added in the lines of code you posted (replacing what I had before) and now... I still get an error, but it's a different one. Or actually, two different ones.

"lookupslice: invalid slice handle -100013"

Immediately followed by...

"dissolvesprite: invalid slice handle 0"
FYS:AHS -- Working on Yagziknian NPC walkabout sprites
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7660
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

Oh! Totally my fault! I wrote that wrong. I had the arguments in the wrong order. Try this instead:

Code: Select all

variable(spr)
spr := lookup slice(sl:walkabout sprite component, get npc slice(8))
dissolve sprite(spr,dissolve:flicker,20)
User avatar
FnrrfYgmSchnish
Metal Slime
Posts: 741
Joined: Thu Jun 18, 2009 4:37 am
Location: Middle of Nowhere

Post by FnrrfYgmSchnish »

Whoops. I should've checked HamsterWhisper's context help feature on those slice-related commands... would've been able to spot that error pretty quick if I had!

But thanks! I just tested the script again and now it works exactly as intended.
FYS:AHS -- Working on Yagziknian NPC walkabout sprites
Post Reply