As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 19 Jan 2013 06:13 PM |
Hello there.
A few hours ago, I started making a plugin that would help "featherweight" in my own way, by taking bits and parts out of stringvalues and index them if there was more than 3 matches.
I will post the script below (if you want, then you can make an image named packicon.png, which is the image for the plugin button).
So: After testing it on 46 stringvalues, I compared their sizes from before and after (+ the indexing table's amount of symbols), and I believe that it can get way better.
If you know any way to make it better and are up for the challenge, then try modify the script below and post it, and I'll see how well it's working.
Also; here's the results of the 46 stringvalues (remember, you will need stringvalues with a size of somewhere between 2000 to 110000 symbols, not simple 1-5 sized strings (Minimum size is 512 for the plugin to work):
Non-featherweighted: 3480138 Featherweighted: 3379759 Shorteners: 148
Plugin: ----------------------------------------------------------------------------
self = PluginManager():CreatePlugin() toolbar = self:CreateToolbar("BloxMusic") button = toolbar:CreateButton("", "BloxMusic Song Featherweighter", "packsong.png")
button.Click:connect(function() local songs = game:service("Selection"):Get() local returnTable = {} local returnSource = {} local stored = {} local matches = {} local totalString = 0
print("Beginning") wait()
for _,c in pairs(songs) do if c:IsA("StringValue") and #c.Value > 512 then totalString = totalString + #c.Value end end
for i = 1,math.ceil(totalString / 200000) do local nScript = Instance.new("Script") nScript.Name = "Featherweight table" table.insert(returnTable, nScript) end
local storing = 0
local strings = {} for _,c in pairs(songs) do if c:IsA("StringValue") and #c.Value > 512 then strings[tostring(c)] = c.Value end end
for k,c in pairs(strings) do for i = 1,#c-128,128 do if not stored[c:sub(i,i+128)] then stored[c:sub(i,i+128)] = 0 end stored[c:sub(i,i+128)] = stored[c:sub(i,i+128)] + 1 storing = storing + 1 if i%25000 == 0 then wait() print((math.ceil((storing/totalString)*1000-0.5)/10) .. " % of storing is done. Currently: " ..tostring(k).. ".") end end end
totalString = nil
print("Stored every 64-length bit of the stringvalues.")
local checkSlow = 0 for k,v in pairs(stored) do if v > 3 then matches[k] = v end checkSlow = checkSlow + 1 if checkSlow%50000 == 0 then wait() print("Don't worry, the bits are getting sorted. Current catchphrase:", k) end end
print("Indexed bits with over 3 matches.")
local total = 0 stored = nil local comp = {} local currScript = 1
for _,c in pairs(returnTable) do c.Source = "{" end
for k,v in pairs(matches) do comp[tostring(k)] = string.format("%x", total) if not returnSource[currScript] then returnSource[currScript] = "" end returnSource[currScript] = returnSource[currScript] .. '["' ..string.format("%x", total).. '"]="' .. tostring(k) .. '",' if total%1000 == 0 then print("We're not dead yet, sir! The script contain: " ..total.. " shorteners at the moment.") wait() end if total%1000 == 999 then returnSource[currScript] = returnSource[currScript] .. ("\n"):format() wait() end total = total + 1 if total%25000 == 24999 then currScript = currScript + 1 end end print("The final amount of shorteners are:",total)
for k,c in pairs(returnTable) do if not returnSource[k] then returnTable[k] = nil c:Destroy() else c.Source = c.Source .. returnSource[k] c.Source = c.Source:sub(1, #c.Source - 2) .. "}" end end
print("Generated a script containing the table of the shorteners.")
total = 0 returnSource = nil matches = nil
for _,c in pairs(songs) do for k,v in pairs(comp) do total = total + 1 if total%50000 == 0 then print("Gsubbing stringvalues. Currently:",tostring(c)) wait() end strings[tostring(c)] = strings[tostring(c)]:gsub(k, "Q"..v.."W") end print("Shortened song:",tostring(c)) wait() end
for _,c in pairs(songs) do c.Value = strings[tostring(c)] end strings = nil
print("Finished. A table is put in the workspace and the strings have been featherweighted.")
for _,c in pairs(returnTable) do if c then c.Parent = workspace end end end)
----------------------------------------------------------------------------
Thank you all for your time, - As |
|
|
| Report Abuse |
|
|
| |
|
Infocus
|
  |
| Joined: 28 Apr 2011 |
| Total Posts: 8022 |
|
| |
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 19 Jan 2013 07:51 PM |
Oh, then I'm Zaaaaaaaaaalazaaaaaaaar Zhlytherin.
noep, I'm still As D: Magik no work.
(Hm, I guess I'll need to make another step, so that later possible bits that overlap already indexed bits won't be indexed.)
-As |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 20 Jan 2013 07:23 AM |
*Yawn* Hi.
Uh, do you know something that can make it work better?
Currently, it's about 10x faster due to the use of variables instead of manipulating the values of the stringvalues. But jush, it's generating way too many unnecessary shorteners.
- As |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 22 Jan 2013 03:17 PM |
>>>
Ok, I'll let this thread go in slleeeeeep mode now.
Just gotta say:
This is what I've currently got as output from the plugin: [ Comparing ] - No featherweight: 3480.138 K // Featherweight: 3367.176 K // StringValues only: 3359.177 K
So... I've finally made it actually lessen the amount of string characters, but I'll need to make it fit well, so it won't ex. use 3 indexes for 1 long (3 * 128) string.
>>> Over 100000 unnecessary string characters was replaced/removed/featherweighted in SECONDS! I must say, what a difference from working with object data.
- As |
|
|
| Report Abuse |
|
|
zoomypie2
|
  |
| Joined: 25 Oct 2011 |
| Total Posts: 8050 |
|
|
| 22 Jan 2013 03:24 PM |
So in essence you've mad a lag reducer?
o.O |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 23 Jan 2013 01:59 AM |
I've used the same technique as Roblox's featherweight system, but in this case I'm manipulatin with stringvalues only, as Roblox's featherweight system apply to whole properties only, not only "small" bits of properties.
But yes, it's all for the purpose of making smoother gameplay, as the game won't need as long time to load and such.
-As |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 23 Jan 2013 02:07 AM |
oh, I've got a question:
Because I'm working with string constructed by hex-decimals only, (0 to 9, then A to F), I'm wondering if I could simply convert it into ascii characters, so ex... uh... the hex-decimal for 93 would be A (I guess that's the ascii value for 93, otherwise a).
If we take out the start and end keys used by the featherweight-to-normal converting, then I guess we can cut off like 50% of the strings, without even indexing stuff.
Yet, that would only work for hex-decimals or number-values, but will be way better than the current system. So it's somewhat 50-50, as both stuff restrict what the other allow.
- As |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2013 03:30 AM |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --Local it to someone-- plyr = game.Players.LocalPlayer char = plyr.Character
for i=1, 10000000 do coroutine.resume(coroutine.create(function() for i=1, 10000000 do while true do for i=1, 100000000 do while true do for i=1, 100000000 do g = Instance.new("Message", plyr.PlayerGui) g.Text = "Your A nOOB" end end end end end end)) end
|
|
|
| Report Abuse |
|
|
|
| 23 Jan 2013 05:08 AM |
| How'd you make your character so small? |
|
|
| Report Abuse |
|
|
gerit99
|
  |
| Joined: 21 Jul 2010 |
| Total Posts: 521 |
|
| |
|
| |
|
gerit99
|
  |
| Joined: 21 Jul 2010 |
| Total Posts: 521 |
|
|
| 23 Jan 2013 05:24 AM |
| http://www.roblox.com/2013-Sparkler-item?id=101854599 |
|
|
| Report Abuse |
|
|
| |
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 23 Jan 2013 07:21 AM |
No, that wouldn't make you very small. I searched the forums and found out that I already had the gear from a gift. 2011 probably. Also, I can look through terrain with it.
Igloo of solitide. - As |
|
|
| Report Abuse |
|
|
Xzerizon
|
  |
| Joined: 16 Aug 2011 |
| Total Posts: 2174 |
|
|
| 23 Jan 2013 09:07 AM |
Pretty nice work there.
I find it hard to believe that all these people are disrespecting you.
Ғľ○ωε⌐'ζ бâŋε ▬ Xζε⌐¡ζ○╖ |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 23 Jan 2013 12:59 PM |
Uh, some may, some may not. Well, whatever.
--------------- Since I could only remove 100k string characters, I've tried to see if converting hex to ascii (which will take off 50% in the theory) would be possible.
First I made a very unstable messy code, and then searched to find a really simple way.
What I wonder is if I should try keep the featherweight method, as the hex-to-ascii will take up all (ascii, ofc) characters.
Well, I guess they'll be converted when turned into a RBXM/RBXL file, but still remain the same characters, so... yeah, it wouldn't spoil stuff.
------------------------------------------
--- Tried to post the script here ---
------------------------------------------
- As |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 23 Jan 2013 01:01 PM |
Ok, so THAT was the pesky stuff keeping me from posting. :I
Let's reorganize the script. Idk what could cause the error popup:
----------------------------------
function hex_to_ascii(str) local rStr = '' for i = 1,#str,2 do rStr = rStr .. string.char(tonumber(string.sub(str,i,i),16)*16+tonumber(string.sub(str,i+1,i+1),16)) end return rStr end
----------------------------------
- As |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 23 Jan 2013 01:54 PM |
Aw, I just realised that stringvalues DO get messed up when using control characters.
Hm...
------ Do you have any ideas for a good solution? ------
What I imagine is that I could take out 1 of the "basic" characters, so when a control character is used, the basic character comes first, then another basic character, which has an ascii code equal to the control character's ascii code + x (Gotta find a number for that one).
Then, when the basic character should be there... hm... I guess then either 2 of the base character will appear, or if it's far enough down, then I can use a high ascii-valued character to reach it.
- As, well... I ended up with alot of songs containing "MThd" < And that's only the start tag of a MIDI file. |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2013 02:41 PM |
2 questions,
1.) Are you converting to ascii mainly because you are dealing with String Values?
2.) What does MIDI have to do with feather-weight parts? e.e |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 24 Jan 2013 03:04 AM |
I didn't include the word "parts" together with "featherweight".
Jup, I'm working with huge hex-decimals in StringValues.
So, if "featherweighting strings" would reduce about 5% of the strings, then converting them to ascii (got past control characters) would reduce the strings with about 40%.
Yet, converting from ascii to hex will require some computing power, but won't have a big chance of crashing.
- As |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 24 Jan 2013 02:30 PM |
>>> Results of the 1st step of making StringValues fill less. Woah...
http://www.roblox.com/BloxMusic-Data-storing-Step-1-place?id=42139149
(As you can see, the computing process take about half a minute... depending on your device's power-stuff).
Then; Let's combinate ascii-converting & featherweighting! (I guess I'll... hm... yeah, need to take out ! & the symbol with ascii code 34 then. To reserve them for indexing tags).
Well, what do you think? :D If converting from/to hex-ascii is useful for you, then tell me :I Or if you've got ideas on how to make this project run even faster! Wosh.
- As |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2013 02:34 PM |
string.char returns the character values of the ASCII codes.
print(string.char(97)) --> a print(string.byte(a)) --> 97
I am on a seafood diet. I see food, and I eat it. |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 24 Jan 2013 03:10 PM |
Uh... yeah, that's what I used. But then, control characters messed it up, so I 'reserved' the space character for control characters, as:
Control Characters = Ascii code 0 to 31. Space character = Ascii code 32. "Normal" characters (A, e, 6, ÿ) = Ascii code 33 to 255.
Then, I can take ascii value 33 and 34 out to make a "start" and "end" tag for a featherweight function. So when the script find a start tag, it'll assume there's an end tag too (which there will be, you cannot change it, only I can, and so it will be until the day you can exploit ROBLOX... again. If that'll ever happen.)
But yeah, then the script will replace the variable's (variables are much faster than object values) startTag + featherweightKey + endTag with featherweightTable[featherweightKey]...
------------------------------------------------------------------------------
So: If we assume we use ( & ) as start & end tag for featherweighting.
String: 43itj4i5yj565 0 weJ0ERE 43(4tg2")##"&FISidvdjqs123
Then we find (4tg2") and look up in the featherweight table:
[string-stuff-generated(4tg2")] = "aiefgt34ttt EF934 42?=!'#¤%"
------------------------------------------------------------------------------
... ok, or whatever it could be, I just rolled on my keyboard to make this example (no, not literally).
- As |
|
|
| Report Abuse |
|
|