plotscript, cycle palette, begin
variable (i, col1, col2, first, last)
## Create a range using color indexes in the master palette.
## This example is the first color ramp, minus index 0.
first := 1
last := 15
col1 := get color (last)
for (i, first, last, 2) do (
col2 := get color (i)
set color (i, col1)
if (i == last) then (break) ## Interrupts an odd numbered range.
col1 := get color (i+1)
set color (i+1, col2)
)
update palette
set timer (2, 1, 1, @cycle palette)
end
Here's a couple of examples:
One thing I'd like to do next is make the first and last range into script arguments, but unfortunately then using timers would become impossible since timers can't take script arguments. ( )
Last edited by Foxley on Sun Jan 14, 2018 10:26 pm, edited 1 time in total.
What's your reasoning for not using a main loop instead of timers? Just simplicity, or is there something more complicated about it that I'm not seeing?
Mostly simplicity. While timers can just be thrown into a game, you do need to set up a main loop properly so there'd be more of a scripting burden for people who're just doing light scripting for a RPG.
I figure I'll refactor some things and work it out for a main loop setup later.
Timers can't take arguments, but you could use globals, and then make a wrapper script like "start pallete cycle" that takes the arguments, puts them in the globals, and starts the cycle palette timer.
Not exactly the same thing, but might be close enough :)
col1 := get color (last)
for (i, first, last) do (
col2 := get color (i)
set color (i, col1)
col1 := col2
)
Last edited by TMC on Mon Jan 15, 2018 1:34 am, edited 2 times in total.
col1 := get color (last)
for (i, first, last) do (
col2 := get color (i)
set color (i, col1)
col1 := col2
)
[s]That works... but for some reason, when I do 1,15 for the range, it's cycling index 0 as well. I had to change "first" to 2 to make it do 1-15.[/s]
Last edited by Foxley on Tue Jan 16, 2018 9:33 pm, edited 1 time in total.
plotscript, cycle palette, begin
variable (i, col1, col2, first, last, dir)
## Create a range using color indexes in the master palette.
## If doing reverse, switch the numbers (e.g. first=15 last=1)
first := 1
last := 15
dir := 1 ## Direction: 1=forward -1=reverse
col1 := get color (last)
for (i, first, last, dir) do (
col2 := get color (i)
set color (i, col1)
col1 := col2
)
update palette
set timer (2, 1, 1, @cycle palette)
end
[s]Unfortunately the thing where it starts at 0 when you have 1 as the "first" value is still happening, not sure why.[/s]
Last edited by Foxley on Tue Jan 16, 2018 9:34 pm, edited 1 time in total.
I'll try to incorporate James's suggestion soon and see if I can find a way to work in arguments.
My ideal scenario: you can assign simultaneous independent palette cycles to different timers, each with their own range and forward/backward direction. I'm thinking I could just have pcyclefirst1, pcyclelast1, pcycledir1 globals, then pcyclefirst2, pcyclelast2, pcycledir2, etc. I'll try it out soon, unless someone else wants to do it first.
Last edited by Foxley on Tue Jan 16, 2018 9:46 pm, edited 1 time in total.