Post new topic    
Page 1, 2  »
Metal Slime
Send private message
Disabling and enabling map layers with plotscripting? 
 PostSun Sep 21, 2014 5:37 pm
Send private message Reply with quote
Is this possible? I'd like to do something where buildings and places you can go into have a normal outside view and then go to a cutaway interior view once you're inside. I think it'd be as simple as just adding an extra on-top layer with the outdoor view stuff (roof, parapets, etc.) and switching that layer off to reveal the cutaway interior view when stepping into a building, then switching the layer back on upon stepping outside.

I ctrl+F'd through the plotscript dictionary but didn't see any commands that appear to deal with switching layers on and off.

I'm going into more detailed map design now so I'd like to plan accordingly based on whether this is possible or not.
Metal King Slime
Send private message
 
 PostSun Sep 21, 2014 6:14 pm
Send private message Reply with quote
I believe that set slice visible is the command you're looking for.

What you'd need to do would be to get the handle of the slice that has the layer you're looking for with lookup slice. You would then use set slice visible to show or hide that layer.
Being from the third world, I reserve the right to speak in the third person.

Using Editor version wip 20170527 gfx_sdl+fb music_sdl
Metal Slime
Send private message
 
 PostSun Sep 21, 2014 6:20 pm
Send private message Reply with quote
Awesome! Thank you. I'll give this a try today. Smile
Metal Slime
Send private message
 
 PostSun Sep 21, 2014 7:32 pm
Send private message Reply with quote
Shoot, realizing that I've never done plotscripts that deal with getting slice handles or anything like that. Hopefully I'll be able to figure this out.


Yeah, dismal failure so far, hspeak is telling me that I can't use = to make a variable something. I dunno what to do about that.

EDIT:
Specifically, lookup slice in plotdict has an example of getting a handle

variable(portrait)
portrait = lookup slice(sl:textbox portrait)
if(portrait) then(
replace portrait sprite(portrait, 5)
)

but hspeak doesn't allow "variable = " and gives me an error message: "unimplemented keyword/operator = is not permitted inside a script"

Here's what I attempted.:

Code:
plotscript, hide exterior, begin
   variable(overhead)
   overhead = lookup slice(sl:map layer1)
   set slice visible(overhead, off)
end

Liquid Metal King Slime
Send private message
 
 PostSun Sep 21, 2014 10:15 pm
Send private message Reply with quote
You are very close!

to assign a value to a variable, you use :=

Code:

plotscript, hide exterior, begin
   variable(overhead)
   overhead := lookup slice(sl:map layer1)
   set slice visible(overhead, off)
end
Metal Slime
Send private message
 
 PostSun Sep 21, 2014 10:52 pm
Send private message Reply with quote
Bob the Hamster wrote:
You are very close!

to assign a value to a variable, you use :=

Code:

plotscript, hide exterior, begin
   variable(overhead)
   overhead := lookup slice(sl:map layer1)
   set slice visible(overhead, off)
end


Grin You are a lifesaver! Now I know how to assign values to variables.

Except, then I got another error message, but now I can't replicate it for some reason.... but getting the error message prompted me to try this:

Code:
plotscript, hide exterior, begin
   set slice visible(lookup slice(sl:map layer1), off)
end


And that works too. Only one line! Then I replaced off with on for "show exterior" in a separate script and it works absolutely perfect. Yay!
Liquid Metal Slime
Send private message
 
 PostMon Sep 22, 2014 11:27 pm
Send private message Reply with quote
Cool. I can't wait to see this in action.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Metal Slime
Send private message
 
 PostTue Sep 23, 2014 1:30 am
Send private message Reply with quote
sheamkennedy wrote:
Cool. I can't wait to see this in action.


Here's a quick demonstration:
https://www.dropbox.com/s/mcq5ljb1e3r1fj4/cutawaytest.zip?dl=0

I put layers 0 and 1 below the walkabout layer and made layer 2 one of the exterior view layers (specifically the roofing), so if the hero walks in front of the building exterior on the bottom it won't overlay the building on top of the character's head.
Liquid Metal Slime
Send private message
 
 PostTue Sep 23, 2014 2:30 am
Send private message Reply with quote
You may or may not need this advice, but I tend to find that it's best to plan ahead for the eventuality of needing more advanced layers by assigning layers 0-2 as bottom layers and 3 and 4 as overhead layers by default. This makes it easier to plan for more complicated designs without having to go back and rescript everything to account for layer changes. If your plan is to keep things simple, then maintaining the default layers (0,1 for bottom, 2 for overhead) is probably good enough. But if you want detailed roofs, grounds, or really, detailed anything, then you might want to set up each map with more layers and then fill them in as needed.
Place Obligatory Signature Here
Metal Slime
Send private message
 
 PostTue Sep 23, 2014 2:41 am
Send private message Reply with quote
Yeah, I was actually going to do that once I get real maptiles rolled out. It may get tricky, for example if I wanted to do an overhead layer that's for the interior view.

I think this might work:
Layer 0: Base background layer
Layer 1: Exterior view layer that is not overhead
Walkabout/NPC Layer
Layer 2: Interior cutaway view layer that is overhead
Layer 3: Exterior view layer that is overhead

Then I could make the hide/show scripts only switch visibility for Layer 1 and 3. I'd have to make sure that Layer 3 covers Layer 2, though, or else interior view stuff wouldn't be covered up when outside. Or, I could make Layer 4 a special/as-needed layer to cover up problem tiles in those cases.
Liquid Metal Slime
Send private message
 
 PostTue Sep 23, 2014 5:28 am
Send private message Reply with quote
Foxley wrote:
Yeah, I was actually going to do that once I get real maptiles rolled out. It may get tricky, for example if I wanted to do an overhead layer that's for the interior view.

I think this might work:
Layer 0: Base background layer
Layer 1: Exterior view layer that is not overhead
Walkabout/NPC Layer
Layer 2: Interior cutaway view layer that is overhead
Layer 3: Exterior view layer that is overhead

Then I could make the hide/show scripts only switch visibility for Layer 1 and 3. I'd have to make sure that Layer 3 covers Layer 2, though, or else interior view stuff wouldn't be covered up when outside. Or, I could make Layer 4 a special/as-needed layer to cover up problem tiles in those cases.


Another option that may relieve this, but could be more advanced to script, is:
-Make each roof a backdrop slice.
example) House A could be slice 1, House B could be slice 2 etc...

-Then have a script which runs when the map initializes, the script will load each of the roofs in the corresponding (x,y) position on the map.

-Then make a second script which is triggered by zones. When you enter House A then zone 1 is stepped on, thus slice 1 is hidden. When you exit House A then zone 2 is stepped on, thus slice 1 is made visible. (Kind of like an on off switch for that house's roof.

Advantages for using this method:
1) Only the house your inside will have the roof removed
2) You can load all roof slices to a single map layer, thus all other layers will be free for complex layered drawing of maps
3) Since you are showing/hiding slices rather than a layer, you could create a room-by-room effect in which you could reveal 1 room at a time as the player traverses a castle for instance....

Disadvantages for using this method:
1) Slightly tougher script to set up
2) If house has a very large roof then you may have to load a group of slices, and hide a group of slices for that particular roof.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Liquid Metal Slime
Send private message
 
 PostTue Sep 23, 2014 5:30 am
Send private message Reply with quote
Also I checked out the Cutaway test and it looks great so far.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Metal Slime
Send private message
 
 PostWed Sep 24, 2014 2:46 am
Send private message Reply with quote
Thank you!

Also, I think I've got this fully working, in case anyone is interested:

Code:
#***********************
#* Cutaway view toggle *
#***********************

# Use the following layers in this order:
#   - Map layer 0: base background
#   - Map layer 1: exterior view background
#   - Walkabout/NPC layer
#   - Map layer 2: interior view foreground
#   - Map layer 3: exterior view foreground

#   Then, place a step-on NPC with 'hide exterior' at the first step going into a building,
#   and 'show exterior' at the first step going outside a building (e.g. the doorstep)

#   Also, disable Map Layer 2 in the map editor if the map starts in an exterior view area.
#   This prevents the interior foreground layer from being shown on top of the exterior background layer.

plotscript, hide exterior, begin
   set slice visible(lookup slice(sl:map layer1), off) #-Turns off the exterior background layer
   set slice visible(lookup slice(sl:map layer3), off) #-Turns off the exterior foreground layer
   set slice visible(lookup slice(sl:map layer2), on)   #-Turns on the interior foreground layer
end

plotscript, show exterior, begin
   set slice visible(lookup slice(sl:map layer1), on)   #-Turns on the exterior background layer
   set slice visible(lookup slice(sl:map layer3), on)   #-Turns on the exterior foreground layer
   set slice visible(lookup slice(sl:map layer2), off)   #-Turns off the interior foreground layer
end
Liquid Metal Slime
Send private message
 
 PostWed Sep 24, 2014 3:09 am
Send private message Reply with quote
Thanks for sharing!

This also just lead me to another idea I had awhile back regarding faking transparencies. I was just thinking, what would happen if I used this code to make a foreground map layer flicker on, and off at a specified rate (example. every tick). I presume it would make it appear that the tiles on that layer would be 50% transparent. Now what if I made the map tiles on that layer look like clouds. This should make it appear as if my character is semi-visible while passing below these clouds. It could make for a nice effect, but I fear it may also slow down the game immensely depending on the size of the map.

I have seen people do rain-like effects in their games without noticeable slow downs though, so I could be wrong. I'll have to give it a try, but unfortunately don't have time at the moment.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Liquid Metal King Slime
Send private message
 
 PostWed Sep 24, 2014 3:13 am
Send private message Reply with quote
Actually, I think toggling the visibility of a map layer every tick would have no noticeable slowdown.

it might be seizure inducing, but it won't slow you down :)
Display posts from previous:
Page 1, 2  »