Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
08-22-2005 10:05
I'm sure I'm doing something stupid, but I've read the wiki about returns and it's not helping me! So I've got some bits of code that I'm snipping from, the pertinent parts are: integer offset_x; integer offset_y; integer offset_z;
scale(float here, float scale) { integer offset; if(here==0) { offset=0; } else { offset=(integer)(here/scale); } return offset; } default { touch_start(integer total_number) { if(llGetLocalPos()==llGetPos()) { llSay(0, "Root"); } else { vector here=llGetLocalPos(); vector scale=llGetScale(); offset_x=scale(here.x, scale.x); offset_y=scale(here.y, scale.y); offset_z=scale(here.z, scale.z); vector temp; temp.x=offset_x; temp.y=offset_y; temp.x=offset_z; llSay(0, "Local Pos is "+(string)temp); } } }
But I get an error, return statement type doesn't match function return type. I'm sure it's simple, but can anyone explain what I'm doing wrong please?
|
Stefan Nilsson
Registered User
Join date: 14 May 2005
Posts: 8
|
08-22-2005 10:44
You haven't declared the return type (which I guess you want to be 'integer'?)
--- snip ---
integer offset_z;
integer scale(float here, float scale) {
--- snip ---
Does the trick.
|
Max Case
Registered User
Join date: 23 Dec 2004
Posts: 353
|
08-22-2005 14:36
From: Stefan Nilsson You haven't declared the return type (which I guess you want to be 'integer'?)
--- snip ---
integer offset_z;
integer scale(float here, float scale) {
--- snip ---
Does the trick. My guess is you want floats to return, not integer, so make the integer scale(.... actually float scale(... Also, you may want your offset vars to be floats all around, since you are dealing with vectors (and will probably want decimals.). Thanks for help other day BTW - Went with your suggestion- a to z + A - Z + 0-9 for storage. Seems to be working.
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
08-22-2005 15:58
Thanks Stephan, that fixed.
Max, glad to hear your code worked, and trust me, integers is what I wanted to return, I can pull them out of vectors just as easily as floats, and I want to squash rounding errors early.
|
Max Case
Registered User
Join date: 23 Dec 2004
Posts: 353
|
08-22-2005 16:08
From: Eloise Pasteur Thanks Stephan, that fixed.
Max, glad to hear your code worked, and trust me, integers is what I wanted to return, I can pull them out of vectors just as easily as floats, and I want to squash rounding errors early. darn. I guessed wrong. 
|