Page 1 of 1
P-Switch effect Toggles on and off during a level
Posted: Mon Oct 07, 2019 3:50 pm
by Chilly14
How can I get the P-Switch effect to toggle on and off throughout a level without using any switches or blocks? And while the effect is taking place, how do I disable the music?
Re: P-Switch effect Toggles on and off during a level
Posted: Mon Oct 07, 2019 3:56 pm
by Emral
Re: P-Switch effect Toggles on and off during a level
Posted: Mon Oct 07, 2019 4:09 pm
by Chilly14
Thank you!
Added in 11 minutes 47 seconds:
Actually, it's not working. It's telling me that the error expected "=" near "end".
Added in 2 hours 45 minutes 50 seconds:
Here's the error:

Re: P-Switch effect Toggles on and off during a level
Posted: Mon Oct 07, 2019 9:24 pm
by Hoeloe
You'll need to show your code, otherwise we can't tell you what the problem is.
Re: P-Switch effect Toggles on and off during a level
Posted: Mon Oct 07, 2019 10:27 pm
by Chilly14
Re: P-Switch effect Toggles on and off during a level
Posted: Mon Oct 07, 2019 11:02 pm
by Hoeloe
So, the issue here is that you've misunderstood the documentation. Take a look at this again:
Misc.doPSwitchRaw(boolean activate)
See how it has 1) brackets after it, and 2) something inside those brackets?
The brackets tell the program this is a function call - that means you're asking the program to do something (not just moving data around). The thing inside the brackets is an argument - that tells it some information about what you want it to do (and the documentation also tells you the type of data it expects). In this case, an example might be:
Misc.doPSwitchRaw(true)
which would enable the p-switch effect.
Re: P-Switch effect Toggles on and off during a level
Posted: Tue Oct 08, 2019 11:25 am
by Chilly14
Still not working, here's the code again:
https://hastebin.com/ohonanaboz.rb
Re: P-Switch effect Toggles on and off during a level
Posted: Tue Oct 08, 2019 12:13 pm
by Hoeloe
What is data here? You never define that, so you'll probably get an error saying you were "attempting to index a nil value" - that is, you tried to do:
data.timer
when data doesn't exist. That doesn't make sense, since it can't look for the timer field inside something non-existent, so it'll just error.
Speaking of which, you don't actually need to use a timer at all here. You can just check lunatime.tick(), which will give you the current game tick.
Re: P-Switch effect Toggles on and off during a level
Posted: Tue Oct 08, 2019 12:22 pm
by Chilly14
Now it works! Thanks so much!