PDA

View Full Version : Urrghhh - that scripting problems again


jakov.sosic
21st September 2001, 21:15
I'm trying to put a wu shader visualization in my skin by using

SystemObject.getLeftVuMeter(); etc....

now this is a problem:

I don't know how to run my function constantly, because
when I press Play button it runs only once, but I would want it
to run constantly.
Is there any way to code it? Maybe running it every 10 miliseconds?
This is a code:


System.onPlay(){
wushader();
}

wu_shader(){
int L, R;
L = System.getLeftVuMeter();
L = L/255 * 128;
R = System.getRightVuMeter();
R = R/255 * 128;
WuImageL.resize(215,86,L,4);
WuImageR.resize(215,100,R,4);
}

lunarboy1
22nd September 2001, 02:40
use a timer with a very small delay and do:


Global Timer vutimer;

System.onScriptLoading()
{
vutimer = new Timer;
vutimer.setDelay( 5 ); /* 5 is Milliseconds. Can be lowered */
if ( System.getPlayItemString() != "" )
{
vutimer.start();
}
}

System.onScriptUnloading()
{
delete vutimer;
}

System.onPlay()
{
vutimer.start();
}

vutimer.onTimer()
{
wu_shader();
vutimer.start();
}

wu_shader()
{
int L, R;
L = System.getLeftVuMeter();
L = L/255 * 128;
R = System.getRightVuMeter();
R = R/255 * 128;
WuImageL.resize(215,86,L,4);
WuImageR.resize(215,100,R,4);
}


I'm sure my code is a little clumsy but i think it gets the job done.

lunarboy1
22nd September 2001, 02:47
the getPlayItemString member function is used to see if anything is currently playing. The play sring is nothing when nothing is playing so if the string isn't nothing, then the timer should start because a song is already playing when the script was loaded.

jakov.sosic
23rd September 2001, 14:03
Thanks dude! I understand scripting, you don't have to explain it
:)


By the way, your script has some mistakes, but I managed to fix them.
Now it works perfectly.
And also I'm using a bit higher delay, 120 milliseconds,
but in time between another function resizes layer slowly from one point to another if you understand what am I saying.
This way it looks smoother :)

Thanks for your help
;)

lunarboy1
23rd September 2001, 19:06
yea .. i hacked out that script in like 5 min so it probably sucked big time, but i'm glad you got the general gist of it.

Hope the skin works out great.

jakov.sosic
24th September 2001, 15:13
I don't know about skin working out great :(

Also, one more question for everyone who knows scripting more than I do:


Function abcd();

abcd{
Timer slow;
slow = new Timer;
slow.setDelay(10);

slow.onTimer(){
argument 1;
argument 2;
argument 3;
// etc......
}


}



Why the italic text isnt possible???
When I try to compile it, it says syntax error and points at "{".
Then I set this:


slow.onTimer();

So I have question. When I set that argument, is it working as a delay of 10 miliseconds (pauses script before continuing) or does nothing, and is it possible to call an extern Function from within other Function by using onTimer (or simply put some arguments in onTimer block).
Thanx

s0be
24th September 2001, 15:53
Function abcd();

abcd() {
Timer slow;
slow = new Timer;
slow.setDelay(10);
[I]
slow.onTimer(){
argument 1;
argument 2;
argument 3;
// etc......
}

Insert Red Text

/*
S0Be
*/

jakov.sosic
24th September 2001, 16:01
brackets were mistake in question, not in real script :(

I'm still searching for answer on my previous post :(

:( :( :(

Naamloos
24th September 2001, 16:26
have you tried without arguments?

Francis
24th September 2001, 16:53
Originally posted by jakov.sosic
I don't know about skin working out great :(

Also, one more question for everyone who knows scripting more than I do:


Function abcd();

abcd{
Timer slow;
slow = new Timer;
slow.setDelay(10);

slow.onTimer(){
argument 1;
argument 2;
argument 3;
// etc......
}


}



Why the italic text isnt possible???
When I try to compile it, it says syntax error and points at "{".
Then I set this:


slow.onTimer();

So I have question. When I set that argument, is it working as a delay of 10 miliseconds (pauses script before continuing) or does nothing, and is it possible to call an extern Function from within other Function by using onTimer (or simply put some arguments in onTimer block).
Thanx

You can't put a function in a function, here is the right way to do it :

Global Timer slow; // <- make "slow" a global variable accessable by all functions/events

Function abcd();

abcd() {
slow = new Timer;
slow.setDelay(10);
} // <- close function abcd

slow.onTimer(){
argument 1;
argument 2;
argument 3;
// etc......
}

Francis.

s0be
24th September 2001, 17:09
heh, I didn't even notice the discrepency in the braces... it's a monday...

/*
S0Be
*/

lunarboy1
25th September 2001, 03:27
yea.. Francis is right. 'slow' is only used in the braces and nowhere else. Atleast thats how the compiler interperets it :)