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] 2

Author Topic: Don't Link Scripts To Other Scripts...  (Read 3361 times)

« on: January 05, 2011, 11:07:33 AM »
in order to exchange VAL_xxx data...

use iGlobalSet() and Get instead...

it might not be apparent in the beginning, but i just finished confirming this beyond a shadow of a doubt...  linking scripts to other scripts will cause a serious degradation in the performance of your 3DRAD projects...

--Mike
« Reply #1 on: January 05, 2011, 05:09:04 PM »
good to know  ;)

jestermon

« Reply #2 on: January 05, 2011, 06:40:44 PM »
When I started out with large script integration, this "lag" is something I picked up very quickly, which of course led to me going the dll route. When globalstrings was introduced, I could gladly scrap my dll.
In my opinion, globalstrings is one of the most useful features from a scripter's point of view. Not only is it lightning fast with no message overhead, it provides a convenient place to store heaps of data without having to use arrays. And the data is available across multi-level projects.
With a little file-write and file-read, it provides an excellent little database for any project.
my 2c.
« Reply #3 on: January 05, 2011, 08:36:23 PM »
awe nuts! This means a total overhaul is in order for me... one step forward and two steps back... sigh*
« Reply #4 on: January 06, 2011, 04:39:14 AM »
awe nuts! This means a total overhaul is in order for me... one step forward and two steps back... sigh*

yeah but those two steps back will then give you 2000 steps forward!!! :)
« Reply #5 on: January 07, 2011, 07:57:07 PM »
awe nuts! This means a total overhaul is in order for me... one step forward and two steps back... sigh*

yeah but those two steps back will then give you 2000 steps forward!!! :)
:) this is true

FDX

« Reply #6 on: January 21, 2011, 12:36:23 AM »
5 years in the "future" and we go back to the "roots" (aka "globals").
Progress not always go the right direction, Mike?  ;D
Oldest 3drad user (from v1.1 till v5.2)
« Reply #7 on: January 21, 2011, 10:23:30 AM »
yup  ;D


--Mike
« Reply #8 on: January 23, 2011, 08:54:01 AM »
This is nice to know, thx :)
« Reply #9 on: January 23, 2011, 07:15:41 PM »
Forgive me in advance but I am not at my computer atm.  Is there a script example of this somewhere?
« Reply #10 on: January 31, 2011, 12:33:49 PM »
Any chance of showing a patzer how this might work?
« Reply #11 on: January 31, 2011, 02:12:38 PM »
what's that et... how what works...

--Mike

jestermon

« Reply #12 on: January 31, 2011, 02:21:26 PM »
Any chance of showing a patzer how this might work?

Set Global string array

Code: [Select]
void Main()
{

   //set up your values
   float number_00 = 12345;
   string string_00 = "Hello from input script";
   string buffer;

   //place number in a string
   buffer = number_00;

   //Place strings on global array
   iGlobalStringSet(string_00,0);   //place at index 0
   iGlobalStringSet(buffer,1);      //place at index 1;
}

Get Global string array

Code: [Select]
void Main()
{
   //make variables to receive data
   float number_01 = 0;
   string string_01 = "";
   string buffer = "";

   //get data from global array
   iGlobalStringGet(string_01,0);   //get from index 0
   iGlobalStringGet(buffer,1);      //get from index 1

   //The boo boo line in this example , sorry guys
   //number_01 - iStringVal(buffer);   //get number from string
   
   //corrected the example to be "=" and not "-"
   number_01 = iStringVal(buffer);   //get number from string

   //print out with textprint to prove we got data
   iObjectTextSet(OBJ_0, string_01 + "  "+buffer);

}

« Last Edit: February 02, 2011, 08:06:48 PM by jestermon »
« Reply #13 on: January 31, 2011, 02:32:05 PM »
thanks Jes, I was actually going back to delete this post when I saw this response.  It really is very simple...

Now the question is how to integrate this with my very messy and convoluted inventory array system.  I am a bit rusty after not having worked on my project for almost 2 months :)

jestermon

« Reply #14 on: January 31, 2011, 02:47:19 PM »
thanks Jes, I was actually going back to delete this post when I saw this response.  It really is very simple...

Now the question is how to integrate this with my very messy and convoluted inventory array system.  I am a bit rusty after not having worked on my project for almost 2 months :)

No idea what your inventory looks like, but here is a neat little way to handle inventory, and make it available to all scripts

Code: [Select]
//structure to hold inventory stuff
class INVENTORY
{
   string name;    //gun, bullet, bubblegum, bazooka etc
   int quantity;       //how many do I have
};
INVENTORY [] inventory(100);   //100 inventory slots

string S;       //used as a temp string buffer to convert numbers

void Main()
{
   int i,idx;

   //Setup dummy inventory
   if(iInitializing()){
      inventory[0].name = "parabalum 9mm";
      inventory[0].quantity = 1;

      inventory[1].name = "9mm bullets";
      inventory[1].quantity = 36;

      inventory[2].name = "MP614 Bazooka";
      inventory[3].quantity = 1;
   
      inventory[3].name = "Bazooka missiles";
      inventory[3].quantity = 6;
   }

   //either update global string array, so all scripts can see inventory
   iGlobalStringSet(inventory[0].name,0);
   iGlobalStringSet(S = inventory[0].quantity,1);

   iGlobalStringSet(inventory[1].name,2);
   iGlobalStringSet(S = inventory[1].quantity,3);

   iGlobalStringSet(inventory[2].name,4);
   iGlobalStringSet(S = inventory[2].quantity,5);

   iGlobalStringSet(inventory[3].name,6);
   iGlobalStringSet(S = inventory[3].quantity,7);


   //or use a loop to store the stuff
   idx = 0;

   for(i=0;i<4;i++){
      iGlobalStringSet(inventory[i].name,idx);
      iGlobalStringSet(S = inventory[i].quantity,idx+1);
      idx+=2; //work in steps of 3
   }

}
Pages: [1] 2