Titanhex
Sep 17 2011, 04:15 AM
All my pictures are named Bar-Meter #. # being from 1 to 10.
I've got an event loop that sets and cycles through these pictures. In that loop, a variable increases by 1 up to 10, then goes back down to 1. This repeats til the player hits a button.
I know there's an easier way then creating the Show Picture event ten different times. Something like it gets the number on the end and loops through that based on the variable.
I want to make this a lot easier, so how do I do that?
Hopefully this makes some sense.
Night5h4d3
Sep 17 2011, 04:40 AM
I /think/ you could do a nested loop, something like:
CODE
while 1 # always
for i in 1..10 # up to 10
if Input.trigger?()
break # break for
end
# do stuff
end
for i in 10..1 # back down
if Input.trigger?() or Input.repeat?()
break
end
# do stuff again
end
if Input.trigger?() or Input.repeat?()
break # break while
end
end
Titanhex
Sep 17 2011, 06:13 AM
How does that make showing the picture easier than calling separate picture files every time >: ?
This is what I got, and I want it to be easier to call the pictures since I know there's a way to grab the picture to load by a string followed by a number.to.string. Since the variable # is the same end number it should work.

Also bonus if someone could tell me how to do it so it can do the picture call at a varying "frame rate" while keeping a 1 frame wait in the loop, so that the button press can be easy and accurate but the rate at which this bar "increases and decreases" can be changed.
Night5h4d3
Sep 17 2011, 09:13 AM
You'd use a call script to show the picture, and as the file name, you'd pass:
"Bar-Meter #{VAR}" replacing VAR with the variable to use in the name. eg: "Bar-Meter #{$game_variables[1])}"
For the variable wait, you'd call the script version of the wait command passing $game_variables[N] as the variable rate.
eg: @wait_count = $game_variables[N]
Hope that helps.
Titanhex
Sep 17 2011, 12:49 PM
I need to do the wait portion for Input processing. If the total wait within the loop is larger than 1 then the button press check is delayed or won't register at all. So I have to keep the total wait at 1 while still cycling through images at variable rates. That's where it gets especially tricky.
Right now I have a double cog system. Think of two gears. A value called frame cycles through. Once it's gone through 1 cycle it's reset, and the number val is increased one. The full cycle of frame is determined by framerate which is just the difficulty plugged into a formula. Then it does the typical increase, then decrease once at max, increase once at min, repeat, for the val variable.
It should be the cleanest method I think.
I have another deviated question:
Script:
loop
@frame += 1
@frame > 90?@wait_count=1:break
do_stuff
Script:
finish_stuff
end
print "END!"
Done through Script in an event. Error is something about jumping. Obviously the problem is that as scripts they don't connect together. The error made it sound like there was a solution. Is there a way to combine scripts when all you have is the 11 lines per call script and 18 lines?
Night5h4d3
Sep 17 2011, 04:43 PM
The jumping error is because Script: is a label, and you're creating a label twice. A way to make the script easier to call would be to create a new def in scene_base and call it from $scene.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.