PDA

View Full Version : making unlockable gallery in ONscripter


JanX
2006-10-11, 22:52
Firstly -- thank you all for the hard work. I wouldn't have been able to play these games without the translations.

I've been making a visual novel using ONscripter -- Definitely not a programmer, so there's probably a lot more the engine can do that I haven't figured out. At this point, I've got enough basic knowledge to go ahead and make the game.

The problem is that I simply can't figure out how to make an unlockable gallery.

Here's how I want it to work: The gallery has several blank squares on it where thumbnails of the CGs will be. If you haven't unlocked a CG, then the square will remain blank. After unlocking a CG, the thumbnail will appear. Then you can click on it to view at full size.

How would one write the code?

Message
2006-10-12, 00:19
I probably shouldn't be pasting copyrighted code here... But since I've been working on this very recently, here's an undressed version of how Tsukihime handles it:

*ark_gallery
(if gallery page==1)
(put path\filename.jpg into a row of $strings)
(if gallery page==2)
(put other images into the $strings)

gosub *imagemode
goto *ark_gallery

*ciel_gallery
(if gallery page==1)
(put path\filename.jpg into a row of $strings)
(if gallery page==2)
(put other images into the $strings)

gosub *imagemode
goto *ciel gallery

*imagemode
(compare the $strings to "" and put the result in %variables)

notif %variable1==0 && fchk $string1 lsp 0,":c;image\gallery\notreg.jpg",X,Y
(same for %variable2 with $string2 for lsp 1, etc)

bg $4000,%type_crossfade_fst
btndef $4010
if %variable1!=0 && fchk $string1 btn 4001,60,15,160,120,0,0
(same for %variable2 with &string2, etc)

btnwait %4011
(return and csp -1 if right-click or exit button pressed)
(go back to btnwait %4011 if nothing happened)

csp -1
bg $%4011,%type_crossfade_fst
btndef ""
btnwait %4011

goto *imagemode

I've removed the logic to remember what page you're on etc, so the above should only be used to get a general idea of how they do it. $4000 points to the background image with faded thumbnails of all images on this page, $4010 points to a buttons image, containing the unfaded thumbs as well as highlighted buttons.

Starchanchan
2006-10-12, 04:52
Or, you could do it somewhat like this:

Upon showing the image in-game:

bg "data¥cg¥cg10a.jpg"¥
mov %200,1

And for the CG mode:

*cg_mode
bg "data¥system¥cg_mode01a.jpg",12
btndef "data¥system¥cg_mode01b.jpg"
btn 1,575,30,60,32,575,30

*cg_loop

btnwait2 %0
if %0<=0 goto *cg_loop

btndef ""

if %0=1 && %200=1 bg "data¥cg¥cg01a.jpg",12:click:goto *cg_mode




^^;; that's a cropped version of the code I'm using for my own visual novel. Let me know if you need me to elaborate.

Message
2006-10-12, 07:49
Hint: Using fchk saves you a LOT of trouble setting and checking all kinds of variables. ONS keeps a record of what's been viewed automatically. [edit: Make that a record of what's been loaded (http://nscripter.insani.org/reference/meirei/fchk.htm). This doesn't have to mean that the image was really shown.] I probably should have added that above, the fchk command is the heart of the gallery mode. The rest is mostly to make it modular.