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: Practical Uses For:

Previous Thread :: Next Thread 
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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 is not online. 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 is not online. Arkose
Joined: 26 May 2013
Total Posts: 745
28 Mar 2015 05:42 PM
ROBLOX uses, or just in general?
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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 is not online. 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 is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
28 Mar 2015 05:44 PM
@above*
Report Abuse
NotAshley is not online. 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 is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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 is not online. 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
juniorjfive is not online. juniorjfive
Joined: 05 Jan 2010
Total Posts: 671
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
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
28 Mar 2015 06:02 PM
http://www.roblox.com/Forum/ShowPost.aspx?PostID=45890315
Report Abuse
digpoe is not online. 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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
verbalAKspray is not online. verbalAKspray
Joined: 09 Jul 2014
Total Posts: 23685
28 Mar 2015 06:18 PM
% is useful for Enums

Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
28 Mar 2015 06:23 PM
"2D arrays would be good for a chess or checker board, for example."
Ninja'd D:
Report Abuse
verbalAKspray is not online. verbalAKspray
Joined: 09 Jul 2014
Total Posts: 23685
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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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
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