Can i save a database in GE ??

Talk about making games.

Can i save a database in GE ??

Postby BloodRaven » Tue Feb 08, 2011 1:35 pm

my new game needs a small help ! BLACK DUSK one of my game[its a 3d shooting game :D :D ] i'm trying to convert models(images) to GE, not easy but done, i decided to go with a rpg game but my doubt
can i create a database with GE ?? i need to create an inventory, thats done but how to save items in inventory :?: ,
inventory is in realistic style so i need to save every position of items, i saved it using a loop and checking each cells but the problem is some of them share 2 or more cells, i cann't check that !!
if cell 1 and 2 contains guns and it saved and cell 4 & 5 sharing one mission item and it is big , is there any way to save this kind of inventory.
i checked 4 and automatically add it to 5, but i got vertical items, it will share 4 and 7 so how i know the item is big and it horizontal or vertical ???please help ....
Attachments
inventory.jpg
szII_gif.gif
Last edited by BloodRaven on Wed Feb 09, 2011 2:18 am, edited 4 times in total.
blooDRaven
User avatar
BloodRaven
 
Posts: 52
Joined: Sun Jul 26, 2009 11:53 am
Location: India
Score: 1 Give a positive score

Re: Need Help !!

Postby schnellboot » Tue Feb 08, 2011 2:46 pm

cool
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Can i save a database in GE ??

Postby Bee-Ant » Wed Feb 09, 2011 3:34 am

Database in this would be array.
OK, go to the Script Editor, add some variable called Inventory or something, choose YES on the array and give the textbox the value. In that screenshot, you have 16 slots, then type 16.
Image
You already know array? the index starts from 0.
So, if you want to fill the first slot, then it should be:
Code: Select all
Inventory[0]=1; //for example 1 is the code for 'gun'

You can fill more slot with the same way.
Code: Select all
Inventory[1]=2; //for example 2 is the code for 'blade'
Inventory[2]=5; //for example 5 is the code for 'shorgun'
Inventory[15]=7; //for example 7 is the code for 'grenade'

And 15 would be the last index.
Where to put the code?
Well, you should put it in where you add the weapon. maybe in shop?or something.
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Can i save a database in GE ??

Postby BloodRaven » Wed Feb 09, 2011 3:45 pm

thanks, i did almost same like this but i'm using not a fixed inventory, players can move items through the inventory, so first time one item may be in first cell another time may be in another cell...and weapons are not purchasing it is picked from field.
I changed the concept little bit, i had a common actor-actor_gun in inventory, if i had pick a gun a new actor array is added and change its image and want to save all actors pos using a loop..
my doubt is if i had 4 guns,actor_gun[1], actor_gun[2], actor_gun[3] and actor_gun[4],
actor_gun[3] and actor_gun[4] uses 2 cells, one is vertical and other is horizontal
actor_gun[1] takes item[1], actor_gun[2] takes item[2], actor_gun[3]-vertical one takes item[4] & item[7], and actor_gun[4] takes item[5] and item[6],
these are the values for guns
Code: Select all
actor_gun[1] = 1;
actor_gun[2] = 2;
actor_gun[3] = 3;
actor_gun[4] = 4;
actor_gun[5] = 5;

i saved item[4] & item[7] = 3
i saved item[5] & item[6] = 4
how can i load all actors and gives the exact position used ?
blooDRaven
User avatar
BloodRaven
 
Posts: 52
Joined: Sun Jul 26, 2009 11:53 am
Location: India
Score: 1 Give a positive score

Re: Can i save a database in GE ??

Postby schnellboot » Wed Feb 09, 2011 6:15 pm

It would be nice if you could tell me a bit more about your problem.
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Can i save a database in GE ??

Postby BloodRaven » Wed Feb 09, 2011 10:55 pm

i used ge for a long time so i forgot how to save an array :(
i solved the main part of my problem by myself :D by adding item_cond[] array,if item_cond[] =1 then it is a normal item only one cell needed and 2 it needs more cell ..
in short i want to save item[] array with the all actor_gun[].x,actor_gun[].y, also item_cond[] array which stores the guns value
blooDRaven
User avatar
BloodRaven
 
Posts: 52
Joined: Sun Jul 26, 2009 11:53 am
Location: India
Score: 1 Give a positive score

Re: Can i save a database in GE ??

Postby schnellboot » Wed Feb 09, 2011 11:04 pm

so you solved it or not
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Can i save a database in GE ??

Postby Bee-Ant » Wed Feb 09, 2011 11:16 pm

BloodRaven wrote:in short i want to save item[] array with the all actor_gun[].x,actor_gun[].y, also item_cond[] array which stores the guns value

Oh... so in this case you need 2D array...
Code: Select all
int MasterItem[10][8]; //[10] is the small array total, [8] is the total attribute


So, this is how to store:
Code: Select all
MasterItem[0][0] = actor_gun[0];
MasterItem[0][1] = actor_gun[1];
MasterItem[0][2] = actor_fun[2];

MasterItem[1][0] = item_cond[0];
MasterItem[1][0] = item_cond[1];

//etc...


This is the full map of MasterItem[10][8] if you still confused on how to use it.
Code: Select all
MasterItem[10][8]=
{
    0,0,0,0,0,0,0,0,    //actor_gun[0-8]
    0,0,0,0,0,0,0,0,    //item_cond[0-8]
    0,0,0,0,0,0,0,0,    //takes_item[0-8]
    0,0,0,0,0,0,0,0,    //etc1[0-8]
    0,0,0,0,0,0,0,0,    //etc2[0-8]
    0,0,0,0,0,0,0,0,    //etc3[0-8]
    0,0,0,0,0,0,0,0,    //etc4[0-8]
    0,0,0,0,0,0,0,0,    //etc5[0-8]
    0,0,0,0,0,0,0,0,    //etc6[0-8]
};


MasterItem[0][0-8] used to store actor_gun[0-8], MasterItem[1][0-8] used to store item_cond[0-8] etc...

But, to save/load 2D array, you need your own function.
Code: Select all
void LoadItem(char FileName[32])
{
    FIle *f=fopen(FileName,"r");
    int i,j;
    for(i=0;i<10;i++)
    {
        for(j=0;j<8;j++)
        {
            fread(&MasterItem[i][j],1,sizeof(int),f);
        }
    }
    fclose(f);
}
void SaveItem(char FileName[32])
{
    FIle *f=fopen(FileName,"w");
    int i,j;
    for(i=0;i<10;i++)
    {
        for(j=0;j<8;j++)
        {
            fwrite(&MasterItem[i][j],1,sizeof(int),f);
        }
    }
    fclose(f);
}

Usage:
Code: Select all
LoadItem("FileName.txt");
SaveItem("FileName.txt");


But hey, aren't loadVars("filename","groupname") and saveVars("filename","groupname") usable also to save all the arrays???
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Can i save a database in GE ??

Postby BloodRaven » Thu Feb 10, 2011 3:22 am

this i can use,now i can save all using that, the positions of x and y of actor_gun, item_cond ...
i think this will help thanks .....
blooDRaven
User avatar
BloodRaven
 
Posts: 52
Joined: Sun Jul 26, 2009 11:53 am
Location: India
Score: 1 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron