3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1]

Author Topic: iGlobalStringStringSet/Get better then scripts linked together?  (Read 1325 times)

« on: August 25, 2011, 02:09:29 AM »
I think the title says it all. Do I save performance by using iGlobalStringSet/Get instead of linking scripts together?

It's in this situation: I got a fps addon (homemade) and I'm working on a zombie addon. In the fps addon, a script reads the players location. The zombie addon needs to know the player location too. So I can either link the zombie script to the fps addons rigidbody sphere, or use iGlobalStringSet to magically send the location to the zombie script.

Another advance of using iGlobalStringSet, when I put some of the addons together, I don't need to link much to anything. Everything work by itself! 

But let's get back to the question.
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #1 on: August 25, 2011, 08:40:38 AM »
yup... read this thread from january--> http://www.3drad.com/forum/index.php?topic=5953.0

--Mike
« Reply #2 on: August 25, 2011, 08:45:10 AM »
Thank you. Stupid of me. Should have seen it.
One more question, is there an easier way to send away a vector then creating 3 strings?
And how to send a quaternion?
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #3 on: August 25, 2011, 08:50:34 AM »
assemble the string on the sender side putting a space at the end of each element... send the vector over as a single string "0 0 0"...  and parse the string on the receiver side  for the spaces separating each element...

--Mike



« Reply #4 on: August 25, 2011, 08:54:46 AM »
Okay, but how to take out all the elements of the string?
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #5 on: August 25, 2011, 11:56:56 AM »
here's a simple example...

Quote
Vector3        playerLoc;
string         strX,strY,strZ;

int            playerChar     =OBJ_22;
int            textObj        =OBJ_44;

void Main(){
 
   //                  get the player location a vector3   
   iObjectLocation(playerChar,playerLoc);
   
   //                   get the component parts x.y.z
   //                   and convert each to a string
   iStringStr(strX,playerLoc.x,"%4.3f");
   iStringStr(strY,playerLoc.x,"%4.3f");
   iStringStr(strZ,playerLoc.x,"%4.3f");

   //                   concat the strings into one big
   //                   string, adding a * char as a separator                 
   iObjectTextSet(textObj,strX + "*" + strY + "*" + strZ);
   
}

that's how you pack em in... you should be able to figure out how to get em out...

(more coming)

--Mike
« Last Edit: August 25, 2011, 11:59:02 AM by Mike Hense »
« Reply #6 on: August 25, 2011, 12:32:33 PM »
Thanks, but the problem is that I don't know how to get them out.
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #7 on: August 25, 2011, 12:34:17 PM »
... do ya see the more coming at the end???

i understood your question... wait one...

--Mike
« Reply #8 on: August 25, 2011, 12:35:32 PM »
I'm sorry. I'm childlike impatient.

 ;D

And I love it!
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #9 on: August 25, 2011, 12:54:10 PM »
oh... heres the full logic (more or less)...

this should show how to do everything...

Code: [Select]
Vector3        playerLoc;
string         strX,strY,strZ, bigString, retString, retStrX, retStrY, retStrZ;
string         retBigString;

int            playerChar     =OBJ_22;
int            textObj        =OBJ_44;
int            textObj2       =OBJ_66;

int            firstSeparator, secondSeparator, end;

void Main(){
 
   //                  get the player location a vector3   
   iObjectLocation(playerChar,playerLoc);
   
   //                   get the component parts x.y.z
   //                   and make em into a string
   iStringStr(strX,playerLoc.x,"%4.3f");
   iStringStr(strY,playerLoc.y,"%4.3f");
   iStringStr(strZ,playerLoc.z,"%4.3f");

   //                   concat the strings into one big
   //                   string, adding a * char as a separator
   bigString=strX + "*" + strY + "*" + strZ ; 
   //                   store it in globalString space 11
   iGlobalStringSet(bigString+"#",10); 
   //                   show it on screen               
   iObjectTextSet(textObj,"");iObjectTextSet(textObj,bigString);


   //                   now to unpack em

   iGlobalStringGet(retString,10);

   //                   find first *
   firstSeparator=iStringFind(retString,"*",0,true);

   //                   find second *
   secondSeparator=iStringFind(retString,"*",firstSeparator+1,true); 
   //                   find last *
   end=iStringFind(retString,"#",0,true);

   //                   now we know where the vectors break up
   //                   so we can retrieve the 3 strings
   iStringLeft(retStrX,retString,firstSeparator-1);
   iStringMid(retStrY,retString,firstSeparator+1,secondSeparator);
   iStringMid(retStrZ,retString,secondSeparator+1,end);


   retBigString=retStrX +"*" +  retStrY +"*" + retStrZ  ;
   iObjectTextSet(textObj2,""); iObjectTextSet(textObj2,retBigString); 
   
   //                   test a number
   OUT_88=iStringVal(retStrX);
   
}

good luck...

--Mike
« Reply #10 on: August 25, 2011, 12:59:02 PM »
Thanks. But I think it's easier to just send all of the vector elements in their own string.
Do you know if costs extra performance every time you can another iGlobalStringSet/Get?
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #11 on: August 25, 2011, 12:59:17 PM »
And how to send a Quaternion?
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #12 on: August 25, 2011, 01:55:25 PM »
Quote
Thanks. But I think it's easier to just send all of the vector elements in their own string.
well... that's your choice... i took the time to show you how to do it, now you say it's easier to do it string by string... now you ask about quaternions...

sorry Roberto... i'm not wasting any more time showing you a solution when you're only gonna turn around and say "Thanks. But I think it's easier to just send all of the quaternion elements over in their own string"...

do it the easy way if you want... (one whole string space for single element... what a waste... i mean, it's not like global string space is an unlimited resource)...

anyways... you'll find out...

good luck...


--Mike
« Reply #13 on: August 25, 2011, 02:19:38 PM »
I'm sorry man.
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #14 on: August 25, 2011, 05:28:45 PM »
Quote
And how to send a Quaternion?
Basically the same way. Just use euler angles.

Also, it doesn't have to be a huge long complicated script. Once you understand it, then you can rewrite it in your own way. Make it as simple as you want.

I don't know if cramming info into one string will save on performance, because isn't it the same amount of information being stored either way?
Pages: [1]