blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 31 Oct 2011 04:30 PM |
Because I love you guys, I've developed a Point Access Interface, or an easy to use API for integration of point storage to Data Persistence.
pastebin: SgTswHxN
As noted in the code, here is the API:
class pai{ function LoadPointData(Player player, string key) returns int value; function SavePointData(Player player, string key, int value); function GetLastSaveTime(Player player) returns number seconds; }
Enjoy! :D |
|
|
| Report Abuse |
|
|
LocalChum
|
  |
| Joined: 04 Mar 2011 |
| Total Posts: 6906 |
|
| |
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 31 Oct 2011 04:31 PM |
| I haven't tested this yet, so it might be buggy. Hell, it might not work at all. |
|
|
| Report Abuse |
|
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 31 Oct 2011 04:34 PM |
| Oh, and to use it just drop the code portion into the top of your code. |
|
|
| Report Abuse |
|
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 31 Oct 2011 04:36 PM |
| Note that if more than one script tries to use this, it may overwrite some data, so please try to have only one script use this API. |
|
|
| Report Abuse |
|
|
|
| 31 Oct 2011 04:36 PM |
Why not save a function as a string and use it later to restore the data? @_@
~+[CROOKITY BANDED SNAKES]+~ |
|
|
| Report Abuse |
|
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 31 Oct 2011 04:37 PM |
"Why not save a function as a string"
you lost me there |
|
|
| Report Abuse |
|
|
|
| 31 Oct 2011 04:38 PM |
You obviously don't know how2lua then.
~+[CROOKITY BANDED SNAKES]+~ |
|
|
| Report Abuse |
|
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 31 Oct 2011 04:39 PM |
| Just because I don't use inefficient coding styles doesn't mean I don't know how2lua. |
|
|
| Report Abuse |
|
|
| |
|
|
| 31 Oct 2011 04:42 PM |
*title*
You spelled API wrong. |
|
|
| Report Abuse |
|
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 31 Oct 2011 04:44 PM |
"*title* You spelled API wrong."
no, PAI is an acronym for Point Access Interface |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 31 Oct 2011 04:53 PM |
| What do you mean by "Point Storage"? |
|
|
| Report Abuse |
|
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 31 Oct 2011 04:55 PM |
>What do you mean by "Point Storage"? A more efficient way to store points. By points I mean leaderboard data. |
|
|
| Report Abuse |
|
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 31 Oct 2011 04:56 PM |
| :| forgot to add an extra newline after the quote |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 31 Oct 2011 04:57 PM |
| Ah. I was thinking point as in Vector3. Might be better to change it to "Score" |
|
|
| Report Abuse |
|
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 31 Oct 2011 04:58 PM |
Access to the non-minified version:
pastebin: ATBpMtTL |
|
|
| Report Abuse |
|
|
pwnedu46
|
  |
| Joined: 23 May 2009 |
| Total Posts: 7534 |
|
|
| 31 Oct 2011 05:02 PM |
" local function ns(n) -- num to string local c=math.floor(math.log(n)/math.log(2^8)); local s=""; for m=1,c do s=s..string.char(math.floor(n/(2^(8*c)))%2^8); end return s;"
Uhh...How did you figure out the math for that. I don't see what you need the logarithms for. :o |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 31 Oct 2011 05:09 PM |
Way overcomplicated. This is better:
local function numToString(n) if n >= 0 and n < math.huge then local s=""; repeat s = s .. string.char(n % 256) n = math.floor(n / 256) until n == 0 return s; end end |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 31 Oct 2011 05:11 PM |
Or if you want the other endianity:
local function numToString(n) if n >= 0 and n < math.huge then local s=""; repeat s = string.char(n % 256) .. s n = math.floor(n / 256) until n == 0 return s; end end |
|
|
| Report Abuse |
|
|
|
| 31 Oct 2011 05:54 PM |
| Saving functions as strings is easy, you just string.dump the function and save it as a string. When you want to run the function, you load the string and you use it as an argument to loadstring. |
|
|
| Report Abuse |
|
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 31 Oct 2011 05:58 PM |
>Saving functions as strings is easy, you just string.dump the function and save it as a string. When you want to run the function, you load the string and you use it as an argument to loadstring.
Yet it shouldn't be done willy-nilly. |
|
|
| Report Abuse |
|
|
|
| 01 Nov 2011 12:32 AM |
"Efficient"
Just save the whole leaderboard instance. Anything else lags your Lua more. |
|
|
| Report Abuse |
|
|
GigsD4X
|
  |
| Joined: 06 Jun 2008 |
| Total Posts: 3794 |
|
| |
|
|
| 01 Nov 2011 04:36 AM |
*makes game*
*uses admin to save complex script in 3 parts to 3 different persons data*
*makes script to combine and run em if they all enter the server*
"HURR DURR YOU SHALL LE FIND YE OLDE 3 MASTARS OF ROBLOXIA AND LE GAME sHALL COM ALIVE PL0X ._." |
|
|
| Report Abuse |
|
|