|
| 28 Mar 2015 05:40 PM |
2D tables
linked lists
Modulus
Please, do not say checking if a number is even for modulus.
Also do not say a word about elo rating for linked lists :) |
|
|
| Report Abuse |
|
|
NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
|
| 28 Mar 2015 05:42 PM |
Modulus can do more than checking if a number is even. You can check if it's a multiple of any number.
function isMultipleOf(num, mult) if num % mult == 0 then return true else return false end end |
|
|
| Report Abuse |
|
|
Arkose
|
  |
| Joined: 26 May 2013 |
| Total Posts: 745 |
|
|
| 28 Mar 2015 05:42 PM |
| ROBLOX uses, or just in general? |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2015 05:43 PM |
@NotAshley Well, I know that, but when is anybody ever gonna really need that (name some, that would be practical uses)
#above ROBLOX uses :) |
|
|
| Report Abuse |
|
|
NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
|
| 28 Mar 2015 05:43 PM |
For me, a practical use for modulus would be in for loops. This will only run code once every 5 iterations:
for i = 1, 100 do if i % 5 == 0 then print(i.." is a multiple of 5!") end end |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 28 Mar 2015 05:44 PM |
What's a 2D table? What's a linked list? What's a wiki?
I used modulo to convert numbers into different bases. |
|
|
| Report Abuse |
|
|
| |
|
NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
|
| 28 Mar 2015 05:45 PM |
| To expand on my previous example, I've used this for animating weapon effects. I have a loop that creates a blocky fire effect on the target player every .1 seconds 50 times, and every 10th time, it creates a blast effect and damages them. |
|
|
| Report Abuse |
|
|
Stefan631
|
  |
| Joined: 23 Dec 2010 |
| Total Posts: 1350 |
|
|
| 28 Mar 2015 05:46 PM |
Can't you use tonumber() with 2 arguments to convert into a different base?
I saw someone use modulo for a team splitter. |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2015 05:48 PM |
| @Stef That was probably me, that was only one of the only reasons I used modulus :) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 28 Mar 2015 05:49 PM |
'2D tables' Sometimes used for maps among other things (like tbl[x][y] = "mine" or whatever).
'linked lists' I don't see any practical use that would make my script 'work' better.
'Modulus' Checking if something divisible by something, checking if a number is even/odd, "looping your index" through a table (you could use other methods which might be more efficient, but this is sometimes shorter). Encryption (believe it or not) Getting a certain series of bits from some number (% 256 would give you the least significant byte of the number) And a lot more. |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2015 05:49 PM |
I cant explain this, but it works as a "Next page" thing..?
local Table = { 'Hello', 'Im', 'just', 'a', 'really', 'cool', 'table.' }
local mouse = game.Players.LocalPlayer:GetMouse(); local index = 0 -- index value
mouse.Button1Click:connect(function() index = index % #Table + 1 -- When index value is the same number as the index's in the Table, it will revert back to 1. print(Table[ index ]) end) |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2015 06:02 PM |
http://www.roblox.com/Forum/ShowPost.aspx?PostID=45890315
|
|
|
| Report Abuse |
|
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 28 Mar 2015 06:05 PM |
Linked lists work great for my labyrinth generator.
In fact, Linked lists work great for anything node-based. |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2015 06:16 PM |
Modulo is used in a Diffie-Hellman exchange, if I understand correctly. Modulo make so many things way more convenient. How could you not find it practical?
2D tables are extremely useful too. Why wouldn't it be? The only way I can think of that you would not see the practicality in it is if you didn't understand it, but I'm sure you do. It's really useful, but I can't think of any solid examples to support this claim. |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2015 06:17 PM |
"Modulus"
Only someone not experienced in binary wouldn't be able to find a practical use for that. It's probably the only efficient way to convert bytes to bits. |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2015 06:18 PM |
"But I can't think of any solid examples to support this claim"
Well then I guess you see why I don't see much practicality in it huh?
Also, I didn't say modulus wasn't practical, I was just looking for new, clever and creative ways to use it :) |
|
|
| Report Abuse |
|
|
| |
|
|
| 28 Mar 2015 06:19 PM |
"Also, I didn't say modulus wasn't practical"
I didn't say you said that either >.> |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2015 06:19 PM |
"do not say checking if a number is even for modulus." It allows you to check if a number can be evenly divided by another number. It allows you to see whether a number is prime.
Another practical use for modulo that I use quite often is to convert numbers between bases. It is also very commonly used to make a number wrap around. |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2015 06:21 PM |
Modulus can be used to see if a number is odd (ha, I didn't say even).
On a serious note, modulusa can be used to create a circular buffer or check whether a number is a multiple of another number. It's also used in LCG random number generation.
As for linked lists, there is no practical use in Roblox since tables are already dynamic.
2D arrays would be good for a chess or checker board, for example. |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2015 06:22 PM |
"Well then I guess you see why I don't see much practicality in it huh?" Oh, I see practicality alright. I've used multi-dimensional lists SO MANY TIMES over the past week. ArbiterOfDeath's parser is just one of them. It allows you to create a hierarchy. It is quite practical, really.
You can also use them to store position data for a game. You can create graphs using them too. |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2015 06:23 PM |
"2D arrays would be good for a chess or checker board, for example." Ninja'd D: |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2015 06:23 PM |
stuff like scrolling thru players for a spectate gui or something like that
Right.MouseButton1Click:connect(function() Num = Num + 1 View((Num %(game.Players.NumPlayers)) + 1) end)
Left.MouseButton1Click:connect(function() Num = Num - 1 View((Num %(game.Players.NumPlayers)) + 1) end)
or property Enums like this
Right.MouseButton1Click:connect(function() Num = Num + 1 script.Parent.Style = Num % 6 end)
Left.MouseButton1Click:connect(function() Num = Num - 1 script.Parent.Style = Num % 6 end) |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2015 06:25 PM |
Also, elaborating on my "How could you not think they are practical?!": http://www.roblox.com/Forum/ShowPost.aspx?PostID=158831003 |
|
|
| Report Abuse |
|
|