Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+1)

Thank you so much! I half understood, that makes sense it wasn't working especially since "play[]" is a function and I had a function named the same thing. I changed the button name and function name and it's now playing the sound however it is playing them all at the same time. It may have to do with the way the "while L > 0" statement is setup and how it interacts with the function, the listener shows the loop variable doing some funky stuff. also I believe that it plays all the sounds at the same time because if you set the loop slider to a high number, the sound gets very distorted like many iterations of the snare are being played at the same time. I really don't know why this is, it may be because of the way the code is. I updated the link with my new attempt (I don't think the sounds work with neocities so maybe save the html and run it in your browser or something), please take a poke around and see if you can spot anything, again thank you guys for your support and I hope one day ill be competent enough in lil to make some really cool gadgets and stuff!

(1 edit) (+2)

Here’s your problem:

if sys.ms-LST > T | sys.ms-LST = T

Lil always evaluates expressions right-to-left, which means this expression is understood like:

if sys.ms-(LST > (T | (sys.ms-(LST = T))))

…which probably isn’t what you wanted. You can fix it by adding brackets in the places you want:

if ((sys.ms-LST) > T) | ((sys.ms-LST) = T)

…or by leaning into the right-to-left pattern with something like this:

if !T<sys.ms-LST

After making that change, it plays the first four beats correctly.

(+1)

Thank you so much, I have the first track working!!!! thank you to all of you who helped, I really appreciate it. I have just 2 more questions, since lil doesn't do statements like ">=" the way I do a greater than or equal to statement is like how Screwtapello said by using brackets and the or statement " | "? My other question is how does the script in a button work? because I can only get it to run the script when I click it even with out the " on click do" function, so do buttons like only update to run the script when clicked or am I missing something? again thank you all and thank you IJ for making decker lol

(+1)

Lil has three comparison operators: equal-to (=), greater-than (>), and less-than (<). The negation of these (the ! operator) is equivalent to not-equal-to, less-than-or-equal-to, and greater-than-or-equal-to, respectively:

 a = b  # a is equal to b
!a = b  # a is not equal to b
 a > b  # a is greater than b
!a > b  # a is less than or equal to b
 a < b  # a is less than b
!a < b  # a is greater than or equal to b

If you click on a button in interact mode, its script is evaluated and sent a "click[]" event, executing the code declared in "on click do ... end". Any code outside an "on ... end" event handler will execute any time ANY event is sent to that widget. Buttons normally only get click[] events, so technically you can give them a script like

go["Next"]

instead of

on click do
 go["Next"]
end

and it will behave the same in most cases, but the former version becomes a problem with other widget types, which are sent a wider variety of events in different situations.

If you mark any widget as "animated" it will be sent a "view[]" event 60 times per second. This offers one way of making widgets and contraptions that continuously update themselves or move around, if that's the sort of thing you're alluding to trying to accomplish.

Does that help at all?