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: Way to use less data?

Previous Thread :: Next Thread 
Geomaster is not online. Geomaster
Joined: 05 Jul 2008
Total Posts: 1480
22 Sep 2013 03:35 AM
I've got a localscript-based weapon that's very coroutine reliant. However, when more than one are running at once it seems to slow down a bit. I'm probably overlooking a more efficient method, but:

This coroutine is constantly running:

local trans = coroutine.resume(coroutine.create(function()
while wait() do
for i = 1, 20 do
outer.Transparency = outer.Transparency + (.6/20)
outerc.Transparency = outer.Transparency + (.6/20)
wait(.01)
end
wait()
for i = 1, 20 do
outer.Transparency = outer.Transparency - (.6/20)
outerc.Transparency = outer.Transparency - (.6/20)
wait(.01)
end
end
end))


This coroutine triggers to slowly dissapate the beam whenever the character fires it (mouse):

coroutine.resume(coroutine.create(function()
for i = bullet.Transparency, 0, -.1 do
bullet.Transparency = 1 - i
wait(.01)
end
game:GetService("Debris"):AddItem(bullet, .2)
end))

This one serves the same purpose as before, but for an area-based explosion field:

coroutine.resume(coroutine.create(function()
for i = 1, 10 do
boom.Transparency = boom.Transparency + (0.6/10)
wait(.01)
end
boom:Destroy()
end))
end

This one triggers in the missile firing function to remove it after 8 seconds:

coroutine.wrap(function() wait(8) b:remove() end)


Are there some that I just don't need? Some that I can change around?
Report Abuse
DragonODeath is not online. DragonODeath
Joined: 02 May 2011
Total Posts: 1252
22 Sep 2013 03:37 AM
Yes. instead of remove, do :Destroy()
Report Abuse
Geomaster is not online. Geomaster
Joined: 05 Jul 2008
Total Posts: 1480
22 Sep 2013 03:38 AM
..Annnnything else?
Report Abuse
DragonODeath is not online. DragonODeath
Joined: 02 May 2011
Total Posts: 1252
22 Sep 2013 03:40 AM
Bleh bleh, never seen so much wait()'s, in one script. Ever.
Report Abuse
Geomaster is not online. Geomaster
Joined: 05 Jul 2008
Total Posts: 1480
22 Sep 2013 03:41 AM
So, where along the line would that be..helpful? Because I'm picking up: caustic, detrimental, and lazy from that.
Report Abuse
DragonODeath is not online. DragonODeath
Joined: 02 May 2011
Total Posts: 1252
22 Sep 2013 03:44 AM
Really, I don't use Debris:AddItem(). But it's your choice.
Just remove the timeless wait.

local trans = coroutine.resume(coroutine.create(function()
while wait() do
for i = 1, 20 do
outer.Transparency = outer.Transparency + (.6/20)
outerc.Transparency = outer.Transparency + (.6/20)
wait(.01)
end
for i = 1, 20 do
outer.Transparency = outer.Transparency - (.6/20)
outerc.Transparency = outer.Transparency - (.6/20)
wait(.01)
end
end
end))
Report Abuse
Geomaster is not online. Geomaster
Joined: 05 Jul 2008
Total Posts: 1480
22 Sep 2013 03:47 AM
The beam function actually returns the beam after adding it to debris (there are modifications needed for some things). Calling Destroy on it would give me an error, I'd assume
Report Abuse
DragonODeath is not online. DragonODeath
Joined: 02 May 2011
Total Posts: 1252
22 Sep 2013 03:50 AM
Oh ok.
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
22 Sep 2013 04:28 AM
Use RunService, not wait()

That should make it lag less.
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