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: Whats the use in this?

Previous Thread :: Next Thread 
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
01 Aug 2015 11:19 AM
do
print'hi'
end
Report Abuse
IoIiderp is not online. IoIiderp
Joined: 05 Feb 2012
Total Posts: 8613
01 Aug 2015 11:21 AM
Its a block.
You can use local variables in there.
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
01 Aug 2015 11:22 AM
A do end is like creating a new scope.
If you want to do something in a difference scope, but don't need the statements let's say, use do end.

local x = 10;

do
x = 100
print(x)
end

print(x)

> 100
> 10

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
01 Aug 2015 11:24 AM
do
local iSpecializinq = "noob"
end

print(iSpecializinq)

>> nil



??
Report Abuse
IoIiderp is not online. IoIiderp
Joined: 05 Feb 2012
Total Posts: 8613
01 Aug 2015 11:26 AM
@power
You didn't declare it was local?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
01 Aug 2015 11:46 AM
iSpec it printed nil because local variables only exist in the block they were created in.
Report Abuse
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
01 Aug 2015 11:48 AM
@cnt

I know that, i was confirming 'do' acted as a block.
Report Abuse
distalDigitPhalanx is not online. distalDigitPhalanx
Joined: 25 Jan 2015
Total Posts: 1509
01 Aug 2015 11:53 AM
I use it so that I can collapse large portions of code so that I don't have to look at it.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
01 Aug 2015 11:55 AM
Same, also when I want to wrap something and it needs access to the old one, ie:

do
local _table = table;
table = setmetatable({}, {__index = _table;});
table.clear = function(tbl) for key in next, tbl do tbl[key] = nil; end
end
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