Page 1 of 1

[development] Technical Forms - EOS version

Posted: Tue Jan 14, 2020 10:19 pm
by mandarynkorian
Hi all,

I would like to share what I recently did in EOS editor. Some time ago user Rinascere created a tease app called Technical forms. App also has origin in other tease with the same name created by figroll.
On my side: I worked on recreating a sample commands in EOS tease and I finished that part. I'm not so good in creating a stories, but if you would like to help in a process or create your own game, you can work with my scripts.

Here is what you have to add to "init script" section:

Code: Select all

var listOfSoundsWithListener = []

function wait(ms){
   var start = new Date().getTime();
   var end1 = start;
   while(end1 < start + ms) {
     end1 = new Date().getTime();
  }
}

function playList(list){
  for(i = 0; i< list.length-1; i++)
  {
     if(!InList(listOfSoundsWithListener,list[i])) {
        listOfSoundsWithListener.push(list[i])
        console.log('added '+list[i])
        listToPlay = list
        Sound.get(list[i]).addEventListener('end',function(){
          playNext(listToPlay)
        }
     )}
  }
  Sound.get(list[0]).play()
}

function playNext (list) {
    wait(100)
    list.shift()
    if(list.length> 0){
      console.log('playing now: '+list[0])
      Sound.get(list[0]).play()
    }
}

function InList(array, toFind){
  for(var i = 0; i < array.length; i++) {
    if (array[i] == toFind) {
      console.log(true)
        return true
    }
  }
  console.log(false)
  return false
}
That part is going to each page. It contains sounds that we want to play one after another.
First section with stop() functions are used to preload sounds.
Next section takes sound IDs specified in Audio:Play action
Last line with function playList is playing sounds one after another and stop after last one.

Code: Select all

Sound.get('cat4').stop()
Sound.get('dog4').stop()
Sound.get('emma_begin').stop()
Sound.get('emma_stop').stop()
Sound.get('emma_dog').stop()
Sound.get('emma_cat').stop()

var list = [
  'emma_begin',
  'emma_dog',
  'dog4',
  'emma_cat',
  'cat4',
  'emma_stop'];
  
playList(list)
Here is how it looks in EOS editor. There are few sounds added, each with ID and Eval at the end.
Image

I'm also adding a screenshot with how I set ID to sound, because I found it hard to do at beginning.
Image

Pack of audio samples is available here
https://gofile.io/?c=GhTTgR

That is basicaly everything. Please let me know about any issues. If you didn't see Technical Forms by Rinascere, please see URL below.
viewtopic.php?f=26&t=21898

Re: [development] Technical Forms - EOS version

Posted: Wed Jan 15, 2020 3:02 am
by undeniable_denial
I can tell you've put a fair amount of effort into this. I have heard of "Technical Forms" but I haven't tried it yet, so I don't really know what it entails.

I like your dynamic approach. Obviously, playing a bunch of sound files consecutively could be done with just timers but your way is much more flexible which, I assume, is relevant.

I have a few tips for your code but, first, let me say: Good job on figuring out events!
Regarding events: Have you considered using a completely silent mp3 combined with an "end"-event to simulate a wait? Your while-loop certainly works but you're blocking everything with it.

Regarding your inList-function. JavaScript actually already has this. It's called "indexOf". You can check if an array contains an item like this:

Code: Select all

if (array.indexOf(item)>-1) {...}
Lastly, but that's not really important, you could use your "list" to stop() all the sounds in a for-loop instead of explicitly.

I would love to see an EOS-version of "Technical Forms". Then I would probably finally play it.