Page 1 of 3

Stealth's Music Player: Version 0.1d - UPDATE 12/24

Posted: 04 Nov 2008, 18:18
by Stealth870
LATEST VERSION HERE.

Hurray! My first real widget! So, I finally figured out all the basic stuff. Thanks Lurker for the help on the timer stuff.

This widget contains all the TA songs in OGG format. I guess if you already have them in MP3, you can just convert so I'll attach the widget by itself if you want it like that.

It's very messy, I'm quite the Lua noob, so it might not be as efficient as it should be, buuut...it does:
Randomly play tracks
Dynamically activate battle music with fading
Kill babies


Here ya go: http://www.just-deserts.com/misc_files/ ... h_music.7z

I only have 2 kinks to be fixed. 1 is a nil error, that pops its head now and again. I can't really figure out why, but restarting the widget helps if you see it. It works for the most part. :P The second is I need to get the battle music to play a little better.

Right now it will activate battle music nicely with a fadeout, and then a timer launches. It will take approximately 1 minute for the widget to say "Ok, we're not in battle mode". However, if a unit is attacked right afterwards, it will activate battle mode again. This means, sometimes during a battle, the music will fade and play another battle song. It's really not that annoying, as 1 minute is good for battle music I assume, but I definitely want to get that working properly. :mrgreen:

Anyway, hope you guys like it. It's under the CC License, so do what you want with it, just throw my name somewhere in there. :-)

Re: Stealth's Music Player: Version 0.1

Posted: 04 Nov 2008, 21:13
by imbaczek
what does your widget consider as "battle"? any battle or only on-screen battle?

Re: Stealth's Music Player: Version 0.1

Posted: 05 Nov 2008, 00:02
by Argh
any battle or only on-screen battle?
Any damage, to any Unit anywhere, on any Team, as currently written. I'd strongly suggest filtering it by Team.

Re: Stealth's Music Player: Version 0.1

Posted: 05 Nov 2008, 00:46
by REVENGE
Hey, mind if I go through and make revisions if I have the time later this week?

Re: Stealth's Music Player: Version 0.1

Posted: 05 Nov 2008, 01:09
by Stealth870
Oooh snap. Good point Argh. I didn't realize that UnitDamaged included everyone's. O_O So I guess that will need fixing as well. :lol:

Go for it REVENGE, it is CC. I'm just throwing it out there since everyone wants "something" rather than nothing I guess. :mrgreen:

Re: Stealth's Music Player: Version 0.1

Posted: 05 Nov 2008, 01:12
by Argh
Meh, it's no problem, just a quickie fix anyhow. IIRC, UnitDamaged returns the unitID, unitDefID, and Team as the first three parameters anyhow.

Just check team vs. Team, and voila, problem's fixed.

Re: Stealth's Music Player: Version 0.1

Posted: 05 Nov 2008, 01:18
by Stealth870
Cool. I'm looking through the Lua doc but can't find the section where the widget:blabla stuff is. Is it even documented or am I suppose to look in the LuaUI folder for that info?

Re: Stealth's Music Player: Version 0.1

Posted: 05 Nov 2008, 01:28
by Argh
The default return values of the various callins aren't documented at all, basically, so it's either check out stuff in CA (where trepan helped out jK a lot, and jK wrote some of the source, so they both knew what did what) or just puzzle it out, by testing vs callin(a,b,c,d)--> Spring.Echo(a,b,c,d), see if it returns nil or not.

A lot of callins return (u, ud, team) as the first three parameters, but there are numerous exceptions, such as GameFrame.

I should probably document this in the Wiki, it annoys me that such a basic and important piece of information isn't available.

Re: Stealth's Music Player: Version 0.1

Posted: 05 Nov 2008, 01:36
by Stealth870
It would be most appreciated. :mrgreen:

Re: Stealth's Music Player: Version 0.1

Posted: 05 Nov 2008, 01:39
by Super Mario
It would be nice if we can add our music to it manually. :-)

Re: Stealth's Music Player: Version 0.1

Posted: 05 Nov 2008, 01:53
by Stealth870
You could always just change around the values in the tables (2 tables, one for battle songs, and another for construction songs). Problem is, I use the length of each specific song for specific calculations, and seeing as how there is no function to get that easily (which would also simplify custom music) it will probably be left out for a bit. ;P I've requested the function, hopefully next version will have it. :)

Re: Stealth's Music Player: Version 0.1

Posted: 05 Nov 2008, 01:57
by Argh
I'm in the process of documenting the callins right now, I'll put up on the Wiki when it's done, so that it can get looked over and any holes can get fixed (I'm sure there will be mistakes, I'm just going through what I can find anything for).

Should make this a bit easier in the future, eh?

Re: Stealth's Music Player: Version 0.1

Posted: 05 Nov 2008, 02:09
by lurker
On that note, if you just want a list of parameters without additional helpful information, open LuaUI/widgets.lua and skip most of the way down the file.

Re: Stealth's Music Player: Version 0.1

Posted: 05 Nov 2008, 03:02
by Argh
The very basic version is up now. Still cleaning it up.

Re: Stealth's Music Player: Version 0.1

Posted: 05 Nov 2008, 03:20
by Warlord Zsinj
I don't understand the complexity involved here at all, so apologies if I'm requesting the impossible/unfeasible, but would it be possible to adjust the algorithm as follows:

(Excuse my shitty pseudocode, I'm no coder)

if nothing is happening play [building music]

if anything takes damage anywhere play [tension music]

if damage is being dealt at a rate of (0.1*[total HP on the map])/60 seconds then play battle/victory/defeat music.

Decide which to play of battle/victory/defeat music based on:

if damage is being dealt in a minute is at a rate of:
(total damage dealt vs total damage being dealt to your troops ) <0.25 then play victory music

if damage is being dealt in a minute is at a rate of:
(total damage dealt vs total damage being dealt to your troops ) >0.75 then play defeat music

else play battle music

does that make sense?

(the actual detail values can be adjusted of course, but hopefully you get the idea)

Re: Stealth's Music Player: Version 0.1

Posted: 05 Nov 2008, 03:21
by lurker
Don't forget aftermath music :twisted:

Re: Stealth's Music Player: Version 0.1

Posted: 05 Nov 2008, 03:26
by Argh
I think that doing what you want would be too expensive CPU-side to bother with, WZ. Getting total HP, etc. would involve giant table searches, which is bad news in terms of performance.

Better to just trigger states based on simpler stuff- the number of unit deaths over X seconds, etc.

Oh, and the call-ins are documented at a basic level and sorted out, although I need to get back to learning about FBO stuff now so I can't be arsed to write example code. See the Wiki.

Re: Stealth's Music Player: Version 0.1

Posted: 05 Nov 2008, 03:37
by lurker
It wouldn't be expensive nor require any table searches the way I would design it...

And an hp scan every couple seconds would be cheap if you did feel like table searching.

Re: Stealth's Music Player: Version 0.1

Posted: 05 Nov 2008, 03:43
by Argh
Eh? You read what he wants, in terms of logic?
if damage is being dealt at a rate of (0.1*[total HP on the map])/60 seconds then play battle/victory/defeat music.
if damage is being dealt in a minute is at a rate of:
(total damage dealt vs total damage being dealt to your troops ) <0.25 then play victory music
If you have a way to do that without table searches, great, but I can't think of a way to do that properly without iterating through the UnitIDs, myself.

Re: Stealth's Music Player: Version 0.1

Posted: 05 Nov 2008, 03:44
by aegis
the dps widget isn't extremely cpu intensive...