Post new topic    
Page «  1, 2
Liquid Metal Slime
Send private message
 
 PostMon Jan 12, 2015 6:27 am
Send private message Reply with quote
Slices can be confusing until you get the hang of it. I would make a slice collection with a blank text slice in the position onscreen that you need it to be. In your script files you can use "append number" to set a string id to the song's initial time value, and then use "set slice text" to make that song's time show up on the screen.

Then you could either use a for loop, or a timer to clear the string, append the new number, and set the slice text to the updated number. I hope that helps, I didn't want to just write the script partly because I'm exhausted but also because I'm sure you're capable of figuring it out on your own. I should be here to help troubleshoot if necessary.

EDIT: There appears to be a "sound is playing" term but not one for songs. If you're going to have a countdown onscreen though, you're probably going to have to use a timer or loop anyway.

PS. I would recommend making sure the song has some silence at the end so you don't have to worry about syncing up the timer and the song time perfectly, since ticks aren't perfectly divisible into seconds.

ANOTHER EDIT: There is a "seconds of play" command that you could check in a while loop and if it equals the songs length, stop the song and game over.
My pronouns are they/them
Ps. I love my wife
Metal King Slime
Send private message
 
 PostMon Jan 12, 2015 7:22 am
Send private message Reply with quote
SongLengthTest0003.png
Tried it out for myself and it looked somethin' like this!
I think your best bet is going to be using a song that fits into the 500 kilobyte size limit for a sound effect. Sound effects can be played once, you can wait for a sound to quit playing and then do something, etc.

As far as I know, there's no way to play a "song" just one time, they loop indefinitely, and there's not even support in the internal programming stuff that make the music work to support things like that. If you have to use a "song" file instead of a sound effect, your best bet is gonna be some kind of automatic timing like kyle's suggesting. However, you need to look at the commands available:

Seconds Of Play would be a good choice, but it doesn't return how long you've played the game in seconds, it returns a value between 0 and 59. If you've played the game more than 59 seconds, it increments MinutesOfPlay by 1 and starts over at 0... and if Minutes of play is more than 59 seconds it increments hours, if hours is over 23 it increments days and so on. You'd need to account for all of those possible roll overs in your script and it'd be a nightmare.

One good way might be to have your song have some extra silence at the end so it doesn't loop, and set up a script that A) Starts playing the song, B) Shows you how many ticks have elapsed since it's done that and C) Lets you hit spacebar to stop the timer when the song is over. Then, you'd know how many ticks it takes for the song to play, and could manually shut down your mini-game thing after that number of ticks (Keeping in mind that there might be some wiggle-room one way or another based on how fast people's computers are. Probably not a huge difference!)

As for slices, I'm not sure you'd need them. Check out the description for SetTimer. You can automatically bind the timer to a string and show it wherever you want. It'd look something like

Code:

#Shows the String 1 in roughly the upper left corner
ShowStringAt (1,5,10)

#Sets up how long the timer should last
Variable (SongLength)
SongLength := #However Many Ticks You've Determined the song lasts

#Sets up the timer itself, timer 0, lasting song length, counting 1 tick at a time, triggering a certain script when it hits 0,sending the remaining time on the clock to the string 1
#script
SetTimer (0,SongLength,1,@WhateverScriptShouldRunWhenItsOver,1)


SetTimer is a really confusing command, so be sure you read the dictionary entry very carefully.

And in hindsight, you might be able to get song length in ticks just by looking at the length of the sound file in WinAmp or Windows Media Player or whatever the kids are using these days and EDIT: dividing multiplying it's length in seconds by 18.2 to convert it to ticks?

EDIT EDIT: Having checked it myself, it's more photogenic to just take the known length of the song in seconds (easily obtained for most formats) and have the timer count down by 18's.

My script now looks like

Code:

plotscript,TimerDemo,begin

playsong (0)

ShowStringAt (1,5,10)

Variable (SongLength)

#2 minutes, 47 seconds, +1 second to keep it from cuttin off.
SongLength := 168

SetTimer (0,SongLength,18,@EndIt,1)
end

script,EndIt,begin
StopSong
end


And looks like what you see in the screenshot.
Meat, Cheese, and Silicon
Send private message
 
 PostMon Jan 12, 2015 7:42 am
Send private message Reply with quote
Alright. I gave it a shot in a somewhat different way, and I expected it to work:
Code:
plotscript, timer, begin
   variable(i)
   variable(time)
   time := 4212
   for(i, 1, 4212) do, begin
      time -= 1
      show value (time)
   end
end

But all it does it display the number 0 at the bottom-left of the screen. If I substitute a constant like 6 for time it displays that number.

EDIT: Gizmog's script works perfectly! I guess I'll jus use that.
Sent from my iPhone
Meat, Cheese, and Silicon
Send private message
 
 PostTue Jan 13, 2015 12:15 am
Send private message Reply with quote
Alright, so Giz's script is working perfectly for me, but I've run into a little problem with the engine itself.

Ya see, whenever I open the items menu, stats menu, quit dialog, etc., the timer pauses even if I have the menu flag on. Since my game is pretty short and doesn't really make use of these, I removed them. I guess I'll just make a custom quit button that runs a game over script, but maybe that bug (or not) could get looked into?
Sent from my iPhone
Display posts from previous:
Page «  1, 2