think I've said this before, but I have to say it again: I really love this engine, everything is so easy... it's just awesome.
I have to populate the menu with all the pages and functionalities, but I'm already thinking on the save/load profiles stuff and, of course, no idea where to start... what would be the best approach? Do you have any good example to store data?
-- | Requires the 0.9.7 preview version of skyline or later.
obj = 0;
function onInit(objID)
obj = objID;
end
function onKeyDown( key )
-- | on key one, we will serialize the table to file.
if(key == "1")then
lprint("#&127,127,127:Saving table to JSON...")
-- | First Lets create a lua table and fill in some data to test with.
local tempTable = {};
tempTable["playername"] = "Joe";
tempTable["lastName"] = "Bloggs";
tempTable[0] = { ["a"]="Hello", [3]=200};
tempTable[1] = "World";
-- | Second: create a json object based on the table, this contains the correct
-- | metatable for the code to write the JSON data properly.
jsonObj = rapidjson.object(tempTable)
-- | Third; Lets dump the new object into a json file.
-- | > The pretty at the end is to create more readable lines. Setting false will write into one line.
-- | > For a specific location on a Hard drive e.g. E:/myFile.json
-- | > You can name the extension to whatever you want ... *.tableData, *.player etc...
rapidjson.dump(jsonObj, "C:/myfile.json", {pretty=true});
lprint("#&127,255,127:Saving table to JSON Complete!");
end
-- | on key two, we will load the files data into a table and print the data.
if(key == "2")then
lprint("#&127,127,127:Loading table to JSON...")
-- | Load the json file into a table.
myData = rapidjson.load("C:/myfile.json");
-- | Print the data to the in game screen.
sprint("playername = "..myData["playername"]);
sprint("lastName = "..myData["lastName"]);
sprint("0 = "..myData[tostring(0)]["a"]);
sprint("0 = "..myData[tostring(0)][tostring(3)]);
sprint("1 = "..myData[tostring(1)]);
lprint("#&127,255,127:Loading table to JSON Complete!");
end
end
rapidjson.dump(jsonObj, sky.getDir_GameAssets().."/SaveFolder/myfile.json", {pretty=true});
myData = rapidjson.load(sky.getDir_GameAssets().."/SaveFolder/myfile.json");
There's however something that really piss me off at the moment, which is the fact that none of the code editors (lua, rml, rcss) uses a monospaced font... I can deal with Verdana, but coding in Green Arial Italic is a PITA.
x,y = screen.worldPosToScreenPos(x,y,z); -- Returns in 0-1 ... i think.
-- | or
x,y = screen.worldPosToAbsScreenPos(x,y,z); -- return in px
lock_x, lock_y = screen.worldPosToAbsScreenPos(car_pos.x, car_pos.y, car_pos.z);
gui.setPosition( page[20], "sprite_lock", lock_x, lock_y );
page[20] = gui.loadFromTemplate("menu_20.rml",0,0);
Users browsing this forum: No registered users and 1 guest