generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How do I count a table in binary?

Previous Thread :: Next Thread 
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
25 Aug 2015 03:23 AM
It starts at 0 and continues until it's numbered every value in the table. How would I go about doing this?

Example:

_tab = {1,2,3,4,5}
_count = {}
for i,v in pairs(_tab)
--Whatever it does
print(_count[i])
end

--> 0
--> 1
--> 01
--> 10
--> 11
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
25 Aug 2015 03:27 AM
http://stackoverflow.com/questions/9079853/lua-print-integer-as-a-binary
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
25 Aug 2015 03:27 AM
No joke I did this this morning for fun
Report Abuse
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
25 Aug 2015 03:46 AM
THANK YOU SO MUCH!

That worked perfectly!
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
25 Aug 2015 03:54 AM
Why did you need this?
Report Abuse
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
25 Aug 2015 05:55 AM
Well, pretty much what I said; I wanted to take a table and add a binary count to it. It's for one of my encryption methods. It was supposed to be a branched tree kinda table, but I don't know if I could index it properly, so I just defaulted to manually indexing every value. I didn't want to do /all/ of it by hand, because there're about 50 characters in the table, so I used a script and printed a new table with string keys that index the letter and its corresponding binary value.

It pretty much does the same thing as the branched tree pattern would; the most common characters get the lowest values. "e" and "space" are the two most common values, so they get the lowest binary representation of 0 and 1 respectively. The least common character, "}" has a much longer value (something like 00101100).

I might be making things a little more complex than they need to be, but it's quite effective.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image