|
Post by fireblaze420 on Oct 23, 2015 17:13:12 GMT
Could you guys help me in making a savegame option for 3d rad
|
|
|
Post by r on Oct 23, 2015 20:28:42 GMT
///==================================================================
///Save 2 File - A handy data save/load system
///==================================================================
string[] buffer(0);
///String Splitter
string[] S2FStringSplitter(string input, string key)
{
string[] strList(0);
string start, end, temp = input;
int i = 0, pos = 0;
while (true)
{
pos = iStringFind(temp,key,0,true);
if (pos != -1)
{
strList.resize(i+1);
iStringLeft(start,temp,pos-1);
iStringRight(end,temp,iStringLen(temp)-pos);
temp = end;
strList[i] = start;
i ++; if (i > 1000) break;
}
else
{
strList.resize(i+1);
strList[i] = end;
break;
}
}
return strList;
}
///Get Line Number
int S2FGetID(string key, bool add)
{
int l = iStringLen(key);
if (buffer.length() == 0)
{
buffer.resize(1);
return 0;
}
for (int i=0; i<buffer.length(); i++)
{
string temp;
iStringLeft(temp,buffer[i],l+1);
if (temp == key+";") return i;
else if (i == buffer.length()-1 && add)
{
buffer.resize(i+2);
return i+1;
}
}
return -1;
}
///Load File
bool S2FLoadFile(string path)
{
int file = iFileReadOpen(path);
buffer.resize(1000);
if (file > -1)
{
int i = 0;
string data = " ";
while (data != "")
{
iFileStringRead(file,data);
if (data != "")
{
buffer[i] = data;
i ++;
}
}
buffer.resize(i);
iFileClose(file);
}
else
{
buffer.resize(0);
return false;
}
return true;
}
///Save File
bool S2FSaveFile(string path)
{
int file = iFileWriteOpen(path);
if (file == -1) return false;
else
{
for (int i=0; i<buffer.length(); i++)
{
iFileStringWrite(file,buffer[i],true);
}
iFileClose(file);
}
return true;
}
///Load Float
float S2FFloatGet(string key)
{
int id = S2FGetID(key, false);
if (id == -1) return -1;
else
{
string[] list = S2FStringSplitter(buffer[id],";");
return iStringVal(list[1]);
}
}
///Save Float
void S2FFloatSet(string key, float value)
{
int id = S2FGetID(key, true);
///test = id;
if (id != -1) buffer[id] = key + ";" + value;
}
///Load String
string S2FStringGet(string key)
{
int id = S2FGetID(key, false);
if (id == -1) return "Error";
else
{
string[] list = S2FStringSplitter(buffer[id],";");
return list[1];
}
}
///Save String
void S2FStringSet(string key, string value)
{
int id = S2FGetID(key, true);
if (id != -1) buffer[id] = key + ";" + value;
}
///Load Vector
Vector3 S2FVectorGet(string key)
{
int id = S2FGetID(key, false);
if (id == -1) return Vector3(-1,-1,-1);
else
{
string[] list = S2FStringSplitter(buffer[id],";");
return Vector3(iStringVal(list[1]), iStringVal(list[2]), iStringVal(list[3]));
}
}
///Save Vector
void S2FVectorSet(string key, Vector3 value)
{
int id = S2FGetID(key, true);
if (id != -1) buffer[id] = key + ";" + value.x + ";"+value.y + ";" + value.z;
}
///Load Quaternion
Quaternion S2FQuaternionGet(string key)
{
int id = S2FGetID(key, false);
Quaternion q; iQuaternionFromEulerAngles(q,-1,-1,-1,"xyz");
if (id == -1) return q;
else
{
string[] list = S2FStringSplitter(buffer[id],";");
q.x = iStringVal(list[1]); q.y = iStringVal(list[2]); q.z = iStringVal(list[3]); q.w = iStringVal(list[4]);
return q;
}
}
///Save Quaternion
void S2FQuaternionSet(string key, Quaternion value)
{
int id = S2FGetID(key, true);
if (id != -1) buffer[id] = key + ";" + value.x + ";"+value.y + ";" + value.z + ";" + value.w;
}
///==================================================================
///==================================================================
|
|
|
Post by fireblaze420 on Oct 23, 2015 20:41:18 GMT
Could you explain how this script works and with what we should link it and how to activate it.well I am weak in scripting but anyways thanks for the script DUDE!!!!!!☺
|
|
|
Post by r on Oct 23, 2015 21:16:43 GMT
i don't know how to use it,try ask for help from others i still new. ps:i didn't make this script i randomly found it in the old forum. this might help you,but in my case i couldn't understand anything from it. what_emoticon what_emoticon what_emoticon Function_Save2File.3dr (141.17 KB) Function_Save2File_Encrypted.3dr (104.62 KB)
|
|
|
Post by fireblaze420 on Oct 23, 2015 21:31:28 GMT
No problem u did ur best I like it thanks bro
|
|
|
Post by r on Oct 23, 2015 21:41:58 GMT
no problem bro. just try it,u may learn something from it,then u can teach me.
|
|
|
Post by fireblaze420 on Oct 23, 2015 21:56:27 GMT
Sure bro
|
|
|
Post by r on Oct 24, 2015 10:35:17 GMT
i have a project use this script with the menu and other stuff(uncompiled),i can upload the projects but the skin-mesh files for the menu are 10 mb,i will try to upload them as soon as possible,i think that you have to compile the 3 projects to make the game work,am sure that this will help you a lot.
|
|
|
Post by r on Oct 24, 2015 12:33:21 GMT
|
|
|
Post by fireblaze420 on Oct 24, 2015 12:37:30 GMT
good luck dude
|
|
|
Post by r on Oct 24, 2015 18:57:15 GMT
|
|
|
Post by Thunder on Oct 24, 2015 19:44:01 GMT
|
|
|
Post by WhyNot on Nov 17, 2015 5:44:00 GMT
Thanks it helped me as well
|
|