Set Parent a Slice to a Map Layer

Make games! Discuss those games here.

Moderators: Bob the Hamster, marionline, SDHawk

Post Reply
User avatar
Soda_piggy
Slime Knight
Posts: 163
Joined: Tue Oct 16, 2007 1:18 am
Location: Osaka, Japan
Contact:

Set Parent a Slice to a Map Layer

Post by Soda_piggy »

Hey guys! Quick question, under Slice Functions in the Plotscripting Dictionary it says, and I quote, "You may set parent a slice to a map layer to make it move with the camera just like heros and NPCs do." However, it does not offer an example of the proper syntax to make this happen. I have tried several different ways, but can't seem to get it to work. Something like this:

Code: Select all

spritetops:=createcontainer(320, 200)
setparent(spritetops, sl:maplayer 1)
It's probably easy, and I admit I'm rusty on my plotscripting, but if anyone can help, I'd really appreciate it! Thanks!
<a href="https://www.sodapiggymusic.com">Soda Piggy Website</a>
User avatar
sotrain515
Red Slime
Posts: 59
Joined: Wed Dec 26, 2012 3:23 pm

Post by sotrain515 »

Well, I don't have my code in front of me, but I believe what you're missing is the "lookup slice" command around your sl:map layer 1. sl:map layer 1 is just an enum of some kind I believe, whereas lookup slice will return a reference to the actual slice object.

Code: Select all

spritetops &#58;= createcontainer&#40;320, 200&#41;
set parent&#40;spritetops, lookup slice&#40;sl&#58;map layer1&#41;&#41;
User avatar
Soda_piggy
Slime Knight
Posts: 163
Joined: Tue Oct 16, 2007 1:18 am
Location: Osaka, Japan
Contact:

Post by Soda_piggy »

Much appreciated! Everything works perfectly now. Thanks! :)
<a href="https://www.sodapiggymusic.com">Soda Piggy Website</a>
User avatar
Bob the Hamster
Liquid Metal King Slime
Posts: 7460
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

sotrain is exactly correct. slice lookup codes cannot be used in place of handles, you have to use the "lookup slice" command to get a slice handle from a slice lookup code
Post Reply