Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Newbie scripter, having trouble with simple function.

Tsukasa Karuna
Master of all things desu
Join date: 30 Jun 2004
Posts: 370
07-28-2006 11:44
It goes like this. I want an object to simply loop a sound i have in its inventory.

What i have so far is:
CODE

default
{

state_entry()
{
string sound = "43eb9d36-0092-0d62-6cb5-4eddd9c7f70d";
float volume = "5";
llLoopSound(string sound, float volume);
}
}


The editor stops with a syntax error right between the ( and s, on line 7.

This looks correct as far as i can tell! What am i doing wrong here?
_____________________
".. who as of 5 seconds ago is no longer the deliverator.."
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
07-28-2006 11:53
(a) You don't put the type of the variable in the function call, just its name i.e. "sound" rather than "string sound".

(b) Volume is from 0.0 to 1.0 anyway, so there's no point in having volume being 5... just set it to 1.0.
Aodhan McDunnough
Gearhead
Join date: 29 Mar 2006
Posts: 1,518
07-28-2006 12:01
"5" is not a float, it's a string. That's where the error is originating. If you meant 5 then it should have gone

float volume = 5;

or

float volume = 5.0;

Then yes as Ordinal says, volume is from 0.0 to 1.0.

So your line should read

float volume = 0.5;

Also do not put the type declaration in the function call unless you are typecasting. So:

llLoopSound(sound, volume);
_____________________
Aodhan's Forge shop at slurl.com/secondlife/Rieul/95/213/107
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
07-28-2006 12:02
Ooh, didn't spot that. I don't think that's where that particular error is originating, but it probably would anyway... it may be implicitly casting "5" as a float like it does with integers. It's definitely not something to do anyway.

N.B. I am not Siobhan!
Aodhan McDunnough
Gearhead
Join date: 29 Mar 2006
Posts: 1,518
07-28-2006 12:05
From: Ordinal Malaprop

N.B. I am not Siobhan!


Whoops ... been reading too many Siobhan posts tonight. :p Must have been about a couple hundred so far.
_____________________
Aodhan's Forge shop at slurl.com/secondlife/Rieul/95/213/107
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
07-28-2006 12:21
It's the hair, isn't it? *huff* Well, hers is clearly dyed.