„DavaStorage-Helper.cs“ hinzufügen

master
Chris 2020-06-04 07:39:28 +00:00
parent e93470e044
commit 2368ed74fc
1 changed files with 51 additions and 0 deletions

51
DavaStorage-Helper.cs Normal file
View File

@ -0,0 +1,51 @@
//DATA STORE LOGIC
list getDataListFromDataStorage(key _storage)
{
return llCSV2List(osGetDataValue("game.inventar.objekt." + _storage + ".inventar"));
}
saveDataListToDataStorage(key _storage, list _dataList)
{
string _csv = llList2CSV(_dataList);
osSetDataValue("game.inventar.objekt." + _storage + ".inventar", _csv);
}
integer checkDataEntryInDataList(list _dataList, string _key)
{
integer _inListPosition = llListFindList(_dataList, [_key]);
if(_inListPosition == -1)
return FALSE;
return TRUE;
}
string getDataEntryFromDataList(list _dataList, string _key)
{
integer _inListPosition = llListFindList(_dataList, [_key]);
if(_inListPosition == -1)
return "";
return llList2String(_dataList, _inListPosition + 1);
}
list setDataEntryInDataList(list _dataList, string _key, string _value)
{
integer _inListPosition = llListFindList(_dataList, [_key]);
if(_inListPosition == -1)
{
_dataList += [_key, _value];
return _dataList;
}
return llListReplaceList(_dataList, [_value], _inListPosition + 1, _inListPosition + 1);
}
//Example
list _dataStorage = getDataListFromDataStorage("storage.example");
_dataStorage = setDataEntryInDataList(_dataStorage, "test.entry", "dummy");
llOwnerSay(getDataEntryFromDataList(_dataStorage, "test.entry"));
saveDataListToDataStorage("storage.example", _dataStorage);