|
| 25 Feb 2012 10:55 AM |
for i, v in pairs(workspace:GetChildren()) do if v.Name == "DissapearingJump" then v.Touched:connect(function(hit)) wait(.001) v.Transparency = .1 wait(.1) v.Transparency = .2 wait(.1) v.Transparency = .3 wait(.1) v.Transparency = .4 wait(.1) v.Transparency = .5 wait(.1) v.Transparency = .6 wait(.1) v.Transparency = .7 wait(.1) v.Transparency = .8 wait(.1) v.Transparency = .9 wait(.1) v.Transparency = 1 v.CanCollide = false wait(5) v.Transparency = 1 wait(.01) v.Transparency = .9 wait(.01) v.Transparency = .8 wait(.01) v.Transparency = .7 wait(.01) v.Transparency = .6 wait(.01) v.Transparency = .5 wait(.01) v.Transparency = .4 wait(.01) v.Transparency = .3 wait(.01) v.Transparency = .2 wait(.01) v.Transparency = .1 wait(.01) v.Transparency = 0 v.CanCollide = true end) end end
|
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 25 Feb 2012 10:58 AM |
local deb = true for i, v in pairs(workspace:GetChildren()) do if v.Name == "DissapearingJump" then v.Touched:connect(function(hit)) if deb == true then deb = false wait(.001) v.Transparency = .1 wait(.1) v.Transparency = .2 wait(.1) v.Transparency = .3 wait(.1) v.Transparency = .4 wait(.1) v.Transparency = .5 wait(.1) v.Transparency = .6 wait(.1) v.Transparency = .7 wait(.1) v.Transparency = .8 wait(.1) v.Transparency = .9 wait(.1) v.Transparency = 1 v.CanCollide = false wait(5) v.Transparency = 1 wait(.01) v.Transparency = .9 wait(.01) v.Transparency = .8 wait(.01) v.Transparency = .7 wait(.01) v.Transparency = .6 wait(.01) v.Transparency = .5 wait(.01) v.Transparency = .4 wait(.01) v.Transparency = .3 wait(.01) v.Transparency = .2 wait(.01) v.Transparency = .1 wait(.01) v.Transparency = 0 v.CanCollide = true wait(5) deb = true end end) end end
|
|
|
| Report Abuse |
|
|
UFAIL2
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 6905 |
|
|
| 25 Feb 2012 11:00 AM |
Inefficiency at it's worst.
Allow = true
for i, v in pairs(Workspace:GetChildren()) do if v.Name == "DissapearingJump" then v.Touched:connect(function(hit)
if Allow then Allow = false wait()
for i = 0, 1, 0.1 do v.Transparency = i wait(0.01) end
v.CanCollide = false wait(5)
for i = 1, 0, -0.1 do v.Transparency = i wait(0.01) end
v.CanCollide = true
end end) end end
~When life gives you lemons, you say 'I ain't even mad'.~ |
|
|
| Report Abuse |
|
|
C0D3Y
|
  |
| Joined: 24 Jul 2010 |
| Total Posts: 1692 |
|
|
| 25 Feb 2012 11:00 AM |
| Um, Miz, I know you're a lot better at scripting than me so feel free to tell me if I'm wrong but if you use a local variable, won't it only work inside the function it's in? |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 25 Feb 2012 11:01 AM |
@UFAIL2
I already told you this before, his script is more efficient than yours by .002%. Yours is just less coding. |
|
|
| Report Abuse |
|
|
UFAIL2
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 6905 |
|
|
| 25 Feb 2012 11:02 AM |
@COD3Y
http://wiki.roblox.com/index.php/Variable#Local_Variables
~When life gives you lemons, you say 'I ain't even mad'.~ |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 25 Feb 2012 11:02 AM |
@C0dy
I didn't end the scope, if I did end the scope than yeah, I can't use deb anymore. |
|
|
| Report Abuse |
|
|
UFAIL2
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 6905 |
|
|
| 25 Feb 2012 11:03 AM |
@miz
I aim for less lines, and making the script look clean; don't you?
~When life gives you lemons, you say 'I ain't even mad'.~ |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 25 Feb 2012 11:04 AM |
Pause time. Put the following in a Script named 'spt' in Workspace.
db = false script.Parent.Touched:connect(function(h) if db then return end db = true for i=0,1,.1 do script.Parent.Transparency = i wait() end script.Parent.CanCollide = false wait(3) for i=1,0,.1 do script.Parent.Transparency = i wait() end script.Parent.CanCollide = true db = false end)
Then, copy the following line and put it into the Command line, and hit your enter/return key.
for _,v in pairs(Workspace:children()) do if v.Name == "DissapearingJump" then Workspace.spt:Clone().Parent = v end end |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 25 Feb 2012 11:04 AM |
| Looping for a .Touched is odd.. I shall avoid it like a minor plague. >.> |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 25 Feb 2012 11:06 AM |
@UFAIL2
I don't really care if a script is efficient or not. I would rather want it to be inefficient and make it work then to be efficient but not work, no output and feel stress. Point is, I don't care, my goal to scripting is making it work, not being stressed over efficiency. |
|
|
| Report Abuse |
|
|
|
| 25 Feb 2012 11:08 AM |
@Miz I just used yours... It looks like the simplest way out of everyones script here... And I can actually tell what it does =P |
|
|
| Report Abuse |
|
|
|
| 25 Feb 2012 11:11 AM |
@Miz Your script didn't work... I tried it but nothing happends... |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 25 Feb 2012 11:16 AM |
local deb = true for i, v in pairs(workspace:GetChildren()) do if v.Name == "DissapearingJump" and deb == true then v.Touched:connect(function(hit)) deb = false wait(.001) v.Transparency = .1 wait(.1) v.Transparency = .2 wait(.1) v.Transparency = .3 wait(.1) v.Transparency = .4 wait(.1) v.Transparency = .5 wait(.1) v.Transparency = .6 wait(.1) v.Transparency = .7 wait(.1) v.Transparency = .8 wait(.1) v.Transparency = .9 wait(.1) v.Transparency = 1 v.CanCollide = false wait(5) v.Transparency = 1 wait(.01) v.Transparency = .9 wait(.01) v.Transparency = .8 wait(.01) v.Transparency = .7 wait(.01) v.Transparency = .6 wait(.01) v.Transparency = .5 wait(.01) v.Transparency = .4 wait(.01) v.Transparency = .3 wait(.01) v.Transparency = .2 wait(.01) v.Transparency = .1 wait(.01) v.Transparency = 0 v.CanCollide = true wait(5) deb = true end) end end
|
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 25 Feb 2012 01:29 PM |
| What was wrong with mine? D: I just made those many, many lines into two small loops. o.O |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 25 Feb 2012 02:34 PM |
| Maybe he doesn't get loops... |
|
|
| Report Abuse |
|
|
stravant
|
  |
 |
| Joined: 22 Oct 2007 |
| Total Posts: 2893 |
|
|
| 25 Feb 2012 02:39 PM |
If you want to see a novel way to re-write the script without needing a debounce at all, then you can do it like this too:
while true do local h = script.Parent.Touched:wait() for i=0,1,.1 do script.Parent.Transparency = i wait() end script.Parent.CanCollide = false wait(3) for i=1,0,.1 do script.Parent.Transparency = i wait() end script.Parent.CanCollide = true end
Putting stuff in that form can actually make a lot of situations a lot easier to deal with. |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 25 Feb 2012 02:48 PM |
@stravant
Isn't an event more efficient then a while loop though? |
|
|
| Report Abuse |
|
|
stravant
|
  |
 |
| Joined: 22 Oct 2007 |
| Total Posts: 2893 |
|
|
| 25 Feb 2012 03:11 PM |
| No, because the loop isn't continually running. The Event:wait() syntax tells Roblox not to run the script again until the event has happened. |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 25 Feb 2012 03:16 PM |
| Ah, ok. But what about the for loop? Some people told me that that's less efficient then just running the whole code. |
|
|
| Report Abuse |
|
|
stravant
|
  |
 |
| Joined: 22 Oct 2007 |
| Total Posts: 2893 |
|
|
| 25 Feb 2012 03:42 PM |
| They're wrong. Loops have nothing inherently wrong with them, its only when you run code with them every single frame that you have to be careful. |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 25 Feb 2012 05:27 PM |
No, like for example
This script
script.Parent.Transparency = 1 wait(1) script.Parent.Transparency = .9 wait(1) script.Parent.Transparency = .8
--And so on
To this script
for i = 1,0,-.1 do wait(1) script.Parent.Transparency = i end
They say the first script is more efficient then the second. And the people who say that are master scripters, like kingkiller1000.
(Sorry if I messed up the for loop, said it wrong. I was in a hurry.) |
|
|
| Report Abuse |
|
|
|
| 25 Feb 2012 05:43 PM |
@miz656
I doubt people like kingkiller1000 would say a such thing.
You probably understood them wrong. |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 25 Feb 2012 06:04 PM |
@julien
I remember kingkiller1000 said that to me. Though, he said it was efficient by .0002% So did spectrumz. |
|
|
| Report Abuse |
|
|
|
| 25 Feb 2012 06:10 PM |
Efficiency isn't only speed, it also includes many other things, they're wrong.
As for speed, well, there isn't any difference on ROBLOX. There are many factors that will make speed be completely independant as to which of these you use. |
|
|
| Report Abuse |
|
|