TyranoBuilder Visual Novel Studio

TyranoBuilder Visual Novel Studio

forza-jordan 14 Aug, 2015 @ 8:44pm
Button While Images Loop
Is there a way, and how do I explain this, of making buttons work while images are looping?

Okay, I have a series of images in animation rolling at 100ms (not a gif, but 13 seperate images), and they loop nicely. But when I try to add a button, to move on from the loop, it will not work. I try putting a button after each image too, but it does not work. I then set a stop after the fourth loop just to be sure, and when the images stop rolling, the button does indeed work.

If you understand any of that, then is there a way to be able to press a single button while images are in the process of looping (without suggesting use a gif). Helpful suggestions would be appreciated.

Also while I'm on the subject, is there a way for images to appear for a certain amount of time before they are removed, without them being faded in and out, and, when set to 0ms, without them flashing on and off each time?
Last edited by forza-jordan; 14 Aug, 2015 @ 8:46pm
< >
Showing 1-15 of 15 comments
jay_rab 15 Aug, 2015 @ 12:31am 
is it an animated image or character? as with characters they do have a wait tag that defaults to true will load the image before moving on, if this is the case then you are always loading a image and never moving on. you could set this to false http://tyranobuilder.com/tyranoscript-tags-reference/#chara_show
forza-jordan 15 Aug, 2015 @ 12:41am 
Just images of something looping around. If I combined them into a gif file, would a stop button work while the gif loops?
jay_rab 15 Aug, 2015 @ 9:44am 
A gif will work in that case, you could also use this if your wanting to not lose quality http://gtm.steamproxy.vip/sharedfiles/filedetails/?id=477796693

What is the script or layout that you are using to animate though? I might be able to offer a better solution
forza-jordan 15 Aug, 2015 @ 10:46am 
Literally just lable, show image, show image, show image, show image, show image, etc etc, then jump back to the lable. It works but then slows down as the images keep piling up and when i add remove image after the lable, it either stops working, or it basically removes the image before looping (causing a flash/jump in the scene).

I know this must sound like rookie mistakes to you, but I've only been using this game since Monday, so I'm still getting to grips with things.
delacannon 16 Aug, 2015 @ 3:44am 
To do a loop of images through a multiple tb_show_image is a little bit excessive. You could use instead an spritesheet with all the sprites in the same image and loop through.

How to do it

First you need to group all the images with the same dimensions in a single horitzontal spritesheet. You could use this useful generator:

https://draeton.github.io/stitches/

And outupt an image like this:

http://imgur.com/18iVEnq

Once you have your image ready upload it to TB at the default image folder.

http://imgur.com/Ns2PHYu

Then add this two custom macros at the begining of your game. [play_anim_sprite] and [remove_anim_sprite] like so http://imgur.com/gkInrhf

;___play_anim_sprite______ [macro name='play_anim_sprite'] [layopt visible=true layer=1] [eval exp='tf.sprite_width=mp.sprite_width'] [eval exp='tf.sprite_width=mp.sprite_width'] [eval exp='tf.total_width=mp.total_width'] [eval exp='tf.sprite_x=mp.sprite_x'] [eval exp='tf.sprite_y=mp.sprite_y'] [eval exp='tf.spritesheet=mp.spritesheet'] [eval exp='tf.fps=mp.fps'] [iscript] if(mp.fps==null){ mp.fps=12; } var layer = $(".1_fore").append("<div class='loop_image'></div>"); tf.sprite_image = layer.find(".loop_image"); var now, delta, num = 0; var then = Date.now(); var interval = 1000 /mp.fps; var target = Math.round(mp.total_width - mp.sprite_width); var loop = true; tf.req = null; tf.sprite_image.css({ "background": "url("+mp.spritesheet+")", "background-position": "0px 0px", "position": "absolute", "opacity": 0, "top": mp.sprite_y + "px", "left": mp.sprite_x + "px", "width": mp.sprite_width+"px", "height": mp.sprite_height+"px" }).fadeTo(1000,1); function anims() { tf.req = requestAnimationFrame(anims); now = Date.now(); delta = now - then; if (delta > interval) { then = now - (delta % interval); if (num >= target) { image.css("background-position", "0px 0px"); if (loop) { num = -sprite_width; } else { cancelAnimationFrame(tf.req); } } else { tf.sprite_image.css("background-position", "-="+mp.sprite_width+"px 0px"); } tf.num += mp.sprite_width; } } anims(); [endscript] [endmacro] ;___remvoe_anim_sprite______ [macro name='remove_anim_sprite'] [iscript] cancelAnimationFrame(tf.req) tf.sprite_image.remove(); [endscript] [endmacro]

Then call the macros http://imgur.com/6pzWh0e

;________________________________________ ;@spritesheet=url image ;@sprite_width= width of a single sprite ;@total_width = width of the spritesheet ;@sprite_x / sprite_y = image position on the screen ;@fps = change speed of the animation default is 12 ;________________________________________ [play_anim_sprite spritesheet='./data/fgimage/default/scot.png' sprite_width=108 sprite_height=140 total_width=864 sprite_x=100 sprite_y=200]

Result of the moving image
http://imgur.com/aTKcGxz

To get rid of the animation at any time use:
[remove_anim_sprite]

macros:
https://gist.github.com/delacannon/1dcbbb690df6a47e4408

I hope it could help!
Last edited by delacannon; 16 Aug, 2015 @ 3:47am
forza-jordan 19 Aug, 2015 @ 1:17pm 
Well I have a new thing I'd like to get resolved, that I've spent the last 9 hours on but have gotten absolutely no where - fast.

I have a button image uploaded. Or to say, I have 4, named button1.gif, button2.gif, button3.gif and button4.gif. I have a menu where it goes to 4 characters to speak to. They start out with their original expressions, which they need to be when you go to see the character for the first time. But if you go back, you need to be able to skip the introduction to the character and then join the scene with the last expression it remembered.

Let me try an example of what I'm talking about. You visit Dave for the first time (there is no one called Dave in my game, its just an example). During your time with Dave, Dave dies. So his expression changes to "Dead". When you return to the main menu selection, Dave is now dead. But if you were to press the button going to see him again, it would go straight back to the intro where Dave is alive, rather than moving on and trying to talk to Dave about something else.

I've tried to get to grips with this code from the tags reference but I just do not understand how I go about it.

[eval exp="f.test=500"]
;↑assign to game variable test to a number
[eval exp="f.test2='Example String'"]
;↑assign game variable test2 to Example String
[eval exp="sf.test=400"]
;↑assign system variable test to a number
[eval exp="f.test2=f.test*3"]
;↑assign game variable test2 to 3x game variable test

What does any of that mean? f.test is the character, right, but how I do ask if expression is dead then goto? [if chara/1/dave_is_dead.gif then] type of thing.

Oh, I'm basically asking for a multi use button. Or, if Dave is dead, to hide the intro button and allow another button visiting Dave to show up instead.

As you can probably tell, I'm not making too much sense after 9 hours of failure.

Edit : I mean Dave would be still useful even when dead. When alive you can enter him for a 3 legged race. But when he's dead, he can only really compete in a wheelbarrow race. I've over thought this.
Last edited by forza-jordan; 19 Aug, 2015 @ 1:19pm
jay_rab 19 Aug, 2015 @ 2:49pm 
rather then focusing on the actual image of dave how about setting a variable for him and the other characters that is checked when you go to him

This would be the variable that you will set for each of the characters at the start of your scene:
[eval exp="f.dave=0"]
[eval exp="f.james=0"]
[eval exp="f.bob=0"]

Then we want to set our checks at the start of the scene with dave
[if exp="f.dave==0"]
[chara_mod name="dave" time="600" storage="chara/1/dave_alive.png" ]
[elseif exp="f.dave==1"]
[chara_mod name="dave" time="600" storage="chara/1/dave_dead.png" ]
[endif]

The ^above^ is going to give you an alive dave if his variable hasnt been messed with, but when it checks the next time it will show him as dead because before we leave dave and his scene we will go:
[eval exp="f.dave = f.dave + 1"] and then we will jump back to your part were you can meet all the characters but now daves variable equal to 1, so when you go to the scene it is going to use the dead expression rather then the alive one.

delacannon might have a simpler way of doing this but this is one way that you could do it.
Last edited by jay_rab; 19 Aug, 2015 @ 2:55pm
forza-jordan 19 Aug, 2015 @ 4:21pm 
I've no idea if any of that has worked, because I can't work out the button command for it.

Where, if anywhere, should this go?

[if exp="f.dave == 1"]
[jump storage=dave.ks target=*snuffedit]
[else]
[jump storage=dave.ks target=*imdave]
[endif]

After the buttons on the selection screen, after the lable from the original button command on the selection screen or after "imdave" lable in the dave character selection screen?
jay_rab 19 Aug, 2015 @ 4:48pm 
Depends, First if you have "dave's" scene being dictated by f.dave then why did you need to test his expression? if your jumping to snuffedit then you will be using the dead dave, and if your jumping to the imdave you would use the alive one so why did his expression need an if statement?
forza-jordan 19 Aug, 2015 @ 5:02pm 
I don't know. That's what I'm trying to fathom. What I want to know is how to get the same button to go to two different things (a dead dave or a living dave) without making a second button and putting it underneith it. The above code that I put in I saw somewhere, I forget now, but its basically that which I'm asking for help with.
jay_rab 19 Aug, 2015 @ 5:27pm 
just make a third label called something like davecheck and have the button go to that, then put the script you linked after that label.
forza-jordan 19 Aug, 2015 @ 7:57pm 
Is that lable set in the scene you're pressing the button from, or the scene you're going to? Because my button will do one thing, or the other, but overall will not do both. Is it because the code has two "jumps" in it?
jay_rab 19 Aug, 2015 @ 9:29pm 
you need to set your button to the new label and then have the
[if exp="f.dave == 1"]
[jump storage=dave.ks target=*snuffedit]
[else]
[jump storage=dave.ks target=*imdave]
[endif]

under that new label
forza-jordan 20 Aug, 2015 @ 7:44am 
That isn't helping, it doesn't answer what I'm asking. I already have the 3 lables. "gotodave" on the selection screen where the button is.

Selection Scene

lable select
join scene dave
join scene james
join scene bob
image button dave.ks
image button james.ks
image button bob.ks
stop
lable gotodave
page break
*tyrano script (with the above script on)*
jump dave.ks *gotodave

- the jump at the bottom is so I don't have to delete it and remake it, it's not an issue.

Dave Scene

lable gotodave
exit scene dave
exit scene james
exit scene bob
*tyrano script (with the above on)*
stop

lable imdave
(and all the stuff under here)
stop

lable snuffed it
(and all the stuff under here)
stop

lable returntoselection
jump selection.ks *select

There are two places I'm trying to work out where to put the script, but neither of them function properly. They do one thing, or the other. When you go around the houses with it, the button will always send you to imdave. If you change the variable in the script, then it will always send you to snuffedit. But it will never send you to imdave first, then once you've killed dave and returned to selection, send you to snuffedit.

Do you see what I'm trying to say? I've done everything you've said to, but it's just not working and I'm unsure of where specifically to place the script.

Edit: When you do go around and return to Dave after he's dead, his expression does show him as dead, but it does not jump to the appropriate part of the scene, you start talking to him from scratch.
Last edited by forza-jordan; 20 Aug, 2015 @ 7:58am
forza-jordan 20 Aug, 2015 @ 9:03am 
Actually, I think I've just worked it out.

Underneith the point where Dave's expression changes to dead (on the Dave scene), i put this

[eval exp="f.dave=1"]

"1" being the expression that dave is now dead. I pressed the button back to the main selection screen and then clicked on the button to go to Dave and now it seems to be working a treat!
Last edited by forza-jordan; 20 Aug, 2015 @ 9:04am
< >
Showing 1-15 of 15 comments
Per page: 1530 50

Date Posted: 14 Aug, 2015 @ 8:44pm
Posts: 15