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 » Scripting Helpers
Home Search
 

Re: Small Instancing tip:

Previous Thread :: Next Thread 
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
21 Sep 2012 04:50 PM
i = Instance.new

Now, if you have a script that does a lot of instancing then you could use that, to me that's much easier and much faster to type.

Instance.new("Script",game.Workspace)
Instance.new("Script",game.Workspace)
Instance.new("Script",game.Workspace)

Or you can do this:

i("Script",game.Workspace)
i("Script",game.Workspace)
i("Script",game.Workspace)

Tell me which is faster to type. I just wanted to give you a tip that you could do that with an instance so you can instance something faster. Sure wish I thought of that when I had to make a 420+ line script with instancing. A lot of Instances I can tell you, it was just one script and one ScreenGui that made it work like a pro. You can also do this with printing:

p = print
p("Hia")

http://www.roblox.com/CeaselessSouls-Admin-Commands-Gui-based-item?id=92856199 -- Take one and enjoy! Read the description, has a lot of information. http://www.roblox.com/Forum/ShowPost.aspx?PostID=78242642 -- Read this no requests thread, this is all true.
Report Abuse
Dozer86421 is not online. Dozer86421
Joined: 18 Aug 2011
Total Posts: 726
21 Sep 2012 04:52 PM
No! Use local variables! Use:

local i = Instance.new()

It's better, and more efficient that way!
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
21 Sep 2012 04:53 PM
Don't use the () though, I don't care much for local, though. Here you go guys, I just made an instancing function:

function instance(ob,place)
Instance.new(ob,place)
end
instance("Script",game.Lighting)

This could be useful in some way, it's your choice.

http://www.roblox.com/CeaselessSouls-Admin-Commands-Gui-based-item?id=92856199 -- Take one and enjoy! Read the description, has a lot of information. http://www.roblox.com/Forum/ShowPost.aspx?PostID=78242642 -- Read this no requests thread, this is all true.
Report Abuse
pwnedu46 is not online. pwnedu46
Joined: 23 May 2009
Total Posts: 7534
21 Sep 2012 04:54 PM
Why would you replace something that has an obvious meaning with an obscure variable like i?
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
21 Sep 2012 04:55 PM
That would be bad coding. On some occasions people make a variable to represent math.abs (as just "abs") but doing this with all "built in" functions is bad habit
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
21 Sep 2012 04:57 PM
pwn, why not? It's just an easy way, I personally wouldn't use it, but some people may. Same with my built-in function, I may not use them often at all, but some people may. Now, here's a printing function:

a = 11
function p(content)
print(content)
end
p("Lol"..a.."lol")

Just a small example, but like I said, I may never use this. It just could come in handy sometime, you never know.

http://www.roblox.com/CeaselessSouls-Admin-Commands-Gui-based-item?id=92856199 -- Take one and enjoy! Read the description, has a lot of information. http://www.roblox.com/Forum/ShowPost.aspx?PostID=78242642 -- Read this no requests thread, this is all true.
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
21 Sep 2012 05:00 PM
If you don't practice this,
why give the information to other people?

[[
Don't tab,
its ugly and inefficient.

I do,
but you shouldn't.
]]
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
21 Sep 2012 05:02 PM
Wow,
I got mixed up my words terribly.

But,
I think you understood the point. :l
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
21 Sep 2012 05:05 PM
Dark, what now? The only thing I understood was the information part, but I gave it to them because some people may want to know or may not know and want an easier way to do this. I don't do this because I just like my code shorter without variables such as:

a = game.Workspace

BUT I am fine with:

a = 10

http://www.roblox.com/CeaselessSouls-Admin-Commands-Gui-based-item?id=92856199 -- Take one and enjoy! Read the description, has a lot of information. http://www.roblox.com/Forum/ShowPost.aspx?PostID=78242642 -- Read this no requests thread, this is all true.
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
21 Sep 2012 05:10 PM
Shorter?

'a = game.Workspace' IS shorter.

If you're aiming for the amount of lines,
then yes.

But you should be aiming for the least amount of characters.

Though,
readability is the most important,
naming variables single characters can be confusing (most of the time).
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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