First off, there's a huge mistake in your script. When you use a
if condition, you should use the
== operator and not the
= operator. The first one compares two objects, the second one makes the left object equal to the right object.
CODE
if @on_off = false
<main process>
else
<do something>
end
for example, will
always perform the <main process> since a condition like
if @on_off = false is always true.
To create a proper condition, you should write it this way:
CODE
if @on_off == false
<main process>
else
<do something>
end
with the == operator replacing the = operator.
As for the loop, the correct way to do that is this:
CODE
for i in 0...$game_switches.size
if @hours == i
$game_switches[i] = true
else
$game_switches[i] = false
end
end
what this script does: the for cycle check the whole array of switches and, if the id matches the hour, a certain switch is actived.
I suggest you limit the cycle to 24, since this script would automatically switch off any switch not corresponding to the current hour:
CODE
for i in 0...@max_hours #check a switch per hour
if @hours == i
$game_switches[i] = true
else
$game_switches[i] = false
end
end
Try modify it according to these hints

I hope this can help,
Jens