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: Debris

Previous Thread :: Next Thread 
Tenal is not online. Tenal
Joined: 15 May 2011
Total Posts: 18684
12 Oct 2011 06:59 PM
[ Content Deleted ]
Report Abuse
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
12 Oct 2011 07:02 PM
You can change the max items for it.

Regards,
~Scarfacial
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
12 Oct 2011 07:14 PM
[ Content Deleted ]
Report Abuse
EMAN381 is not online. EMAN381
Joined: 27 Nov 2007
Total Posts: 4300
12 Oct 2011 07:50 PM
Is Debris even used today?

I don't use it and never did,

What is it's purpose anyway?
Report Abuse
greedyshadowlugia is not online. greedyshadowlugia
Joined: 03 Oct 2011
Total Posts: 3
12 Oct 2011 08:03 PM
yes. Its used for survive the disasters.
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
12 Oct 2011 08:04 PM
[ Content Deleted ]
Report Abuse
bunnybunn264 is not online. bunnybunn264
Joined: 04 Oct 2010
Total Posts: 5409
12 Oct 2011 08:30 PM
Oysi, why pcall?
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
12 Oct 2011 08:31 PM
"Is Debris even used today?"

Of course,

print("Hello World!")
game.Debris:AddItem(nub,123)
print("Hello World! PS. Nate890 is awesome")

that wouldn't wait 123 seconds before it printed "Hello World! PS. Nate890 is awesome" and 'nub' will be deleted in 123 seconds

print("Hello World!")
wait(123)
nub:remove()
print("Hello World! PS. Nate890 is awesome")

that would wait 123 seconds to remove 'nub', like the the debris method, but it would also wait 123 seconds to execute the rest of the script, thus waiting 123 seconds to print "Hello World! PS. Nate890 is awesome"

­<'+1 Post. Ujelly?'>
Report Abuse
EMAN381 is not online. EMAN381
Joined: 27 Nov 2007
Total Posts: 4300
12 Oct 2011 08:37 PM
I see.
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
12 Oct 2011 08:49 PM
[ Content Deleted ]
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
12 Oct 2011 08:52 PM
function addItem(item,lifeTime)pcall(game.Debris.AddItem,game.Debris,lifeTime or 10,item)end
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
12 Oct 2011 08:55 PM
function addItem(item, lifeTime) pcall(delay, lifeTime or 10, function() item.Parent = nil end) end

--Code created by oysi, edited by nate890.

­<'+1 Post. Ujelly?'>
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
12 Oct 2011 08:56 PM
dang dang dang dang dang reverse the number and item arguments in mine dang dang dang dang dang
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
12 Oct 2011 08:59 PM
My collector library, not debugged, but it gives an example:

-- Could've used tail calls to save stack space, decided not to. Tail calls require you to put 'return' everywhere. It increases efficiency, but also makes the code more ugly.

--[===[ Variables prefixes:
nVar: new
tVar: template
cVar content of 'var'
]===]

local collector = newproxy(true) -- The collector library.

function import()
getfenv(0).collector = collector
end

function add(item, lifetime)
-- Removes or disconnects an item after a certain ammount of time.
-- The item can be an object or a connection.
assert(tonumber(lifetime), "bad argument #2 to 'add' (number expected, got " .. type(lifetime) .. ")")
-- I use 'tonumber(lifetime)' to know if the value provided can be converted to a number, but there is no need to convert it manually, that is done automatically.
if pcall(function() item:GetChildren()) then -- If the item is an object, then...
delay(lifetime, function()
item:Remove() -- I hate how we can't give arguments to the delay function.
end)
elseif pcall(function() assert(item.connected == true) end) then -- Else, if the item is a connection, then...
delay(lifetime, function()
item:disconnect()
end))
else
error("bad argument #1 to 'add' (object or RBXScriptConnection expected, got" .. type(item) .. ")")
end
end

function create()
-- Creates a collector that will collect everything you tell it to collect and that will destroy it all when you terminate tbe collector.
-- It keeps a list of every item added to it. When you terminate the collector, every item of that list is removed/disconnected.
local self = newproxy(true)
local items = {} -- The list of all the items that were collected by the collector.
getmetatable(self).__index = {
terminate = function(self2) -- The self defined here is the same as the one defined up there. They just have different names so we can compare them and throw an error if they're not identical.
assert(self == self2, "Expected ':' not '.' calling member function terminate")
for _, item in pairs(items) do
pcall(item.Remove, item)
pcall(item.disconnect, item)
end
end;
add = function(self2, item)
assert(self == self2, "Expected ':' not '.' calling member function add")
assert(pcall(function() item:GetChildren() end) or pcall(function() assert(item.connected == true) end), "bad argument #1 to 'add' (object or RBXScriptConnection expected, got " .. type(item) .. ")")
table.insert(items, item)
end;
}

-- Since I'm a nice person, I allow both camelCase and PascalCase for my methods. =)
local alias = getmetatable(self).__index
alias.Terminate = alias.terminate
alias.Add = alias.add
end

getmetatable(collector).__index = {
import = import;
add = add;
create = create;
}

_G.collector = collector -- Export the library.
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
12 Oct 2011 08:59 PM
To use in a script, just call _G.collector.import(), the content of the library will then be stored in the environment in a variable called 'collector'.
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
12 Oct 2011 09:12 PM
"-- Since I'm a nice person, I allow both camelCase and PascalCase for my methods. =)"

WAIULEAVESTUPIDCOMMENTS?

­<'+1 Post. Ujelly?'>
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
12 Oct 2011 09:17 PM
@nate890

WAIUSAYSTUPIDTHINGSTHATMAKENOSENSE?
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
12 Oct 2011 09:19 PM
WAIUNOREADWITHLOGICALTHINKING?

­<'+1 Post. Ujelly?'>
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
12 Oct 2011 09:21 PM
How is my comment stupid?
Report Abuse
pwnedu46 is not online. pwnedu46
Joined: 23 May 2009
Total Posts: 7534
12 Oct 2011 09:23 PM
WAIUSUCHAHYPOKRIT

inb4combobreaker


~ I'm a unicorn ~
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
12 Oct 2011 09:23 PM
"-- Since I'm a nice person, I allow both camelCase and PascalCase for my methods. =)"

DAT WAS USELESS.

­<'+1 Post. Ujelly?'>
Report Abuse
pwnedu46 is not online. pwnedu46
Joined: 23 May 2009
Total Posts: 7534
12 Oct 2011 09:24 PM
@Julien: WAIUEARLYTOAST!??!?!?!?

floodcheck x1


~ I'm a unicorn ~
Report Abuse
pwnedu46 is not online. pwnedu46
Joined: 23 May 2009
Total Posts: 7534
12 Oct 2011 09:26 PM
"DAT WAS USELESS."

I r betr cuz my comments are only somewhat useless. (somewhat == 95% useless)


~ I'm a unicorn ~
Report Abuse
Scriptishish is not online. Scriptishish
Joined: 16 Oct 2007
Total Posts: 1231
13 Oct 2011 02:09 PM
WAISOSERIOUS

Lets put a smile on that face.

--I cant wait for B:AC--
Report Abuse
Tenal is not online. Tenal
Joined: 15 May 2011
Total Posts: 18684
13 Oct 2011 02:17 PM
[ Content Deleted ]
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