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: Stop errors?

Previous Thread :: Next Thread 
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
24 Feb 2013 07:38 AM
Hi ya'!


Ok, as you might guess from the topic, I'm trying to stop any errors there might be in a script, since I don't want it to give output.



So, with non-yielding (whatever you can call it, functions without a wait()) functions, it would be as simple as using pcall or xpcall.

But what if I don't know if there's a wait() in the function? I still want it to run if it's bug-free.


Any ideas?


- As, I was so surprised today. NOT THE COMMON PANCAKES! D:
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
24 Feb 2013 07:47 AM
Quite easily, I would belive:

local script = "print('Hi')
wait(2)
print('Bye')"
if string.find(script, "wait(%d+)" or string.find(script, "wait()") or string.find(script, "wait(%d+.%d+)") then
--Has wait
ypcall(loadstring(script)())
else
--Doesn't have wait
pcall(loadstring(script)())
end
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
24 Feb 2013 07:59 AM
oh, ... not... exactly what I meant. :/



Ok, one-line definition of topic: A way to stop output from ypcall.




- As, humhum, why isn't everyday humday?
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
24 Feb 2013 08:08 AM
I could sandbox the functions, but I don't like doing so.

Input:
print("Hello")
wait(2)
pprint("Wuzzup, error")


Output:
pcall(function() print("Hello") end)
wait(2)
pprint("Wuzzup, error")




?... no, that's a very bad solution D:

- As, we're under the curse of snow in these northern lands of frost and death.
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
24 Feb 2013 08:10 AM
I belive if you just hook it up on it's own (just run ypcall) it doesn't output, except for "ypcall requires atleast 1 argument" which it shouldn't output (I have no idea why, it doesn't output in my scripts.)
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
24 Feb 2013 08:14 AM
Uh, tried to do

ypcall() ypcall(function prrint("hi") end) ypcall(function print("HI") end)


No output. But then I changed to just the last ypcall, yet no output. ypcall broken?


^ 2 above, forgot pcall on the error line.



- As, what can you say when you stare on a tree with leopard skin and a top hat?
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
24 Feb 2013 08:19 AM
*fail* I should have made myself clearer

If you don't index ypcall() in variables (something like, local success, err = ypcall()) it shouldn't error, but it still outputs the error. I belive you could do something like this though:

function handle(err)
end
function f()
local a = nil
return a+1
end
print(xpcall(f,handle)) >Should only print 'false'
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
24 Feb 2013 08:22 AM
Hm, I wonder if... ok, copypaste time... but first explaining:

I wonder if the code below (if we say that "connect" is used in Script2, while "run" is executed in Script1) will crash Script2 instead of Script1, if there was an error.


------------------------------------------------------------


eventName = {
["connected"] = {},

["connect"] = function(f,fn)
local n = #f.connected + 1
f.connected[n] = fn
return {
["disconnect"] = function()
f.connected[n] = nil
end
}
end,

["run"] = function(f,...)
for _,v in pairs(f.connected) do
v(unpack(...))
end
end
}


------------------------------------------------------------

Code source: http://www.roblox.com/Forum/ShowPost.aspx?PostID=52670254







- As, my friend just promised to spam ROBLOX until his user gets removed. Tru story.
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
24 Feb 2013 08:24 AM
If I am thinking correctly, since script2 is calling the value from script1, script1 would error.
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
24 Feb 2013 08:33 AM
Hm, well, I'll try test it.


I wonder if we then can use setfenv or something.. to.. uhm... yeah, somehow "glitch" the environment over to Script2. No, I'm just talking nonsense. D:



- As, oops, it's first when the old studio is completely removed. ^
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
24 Feb 2013 08:47 AM
You can kinda get the environment over to script2, I belive.
script 1
function _G.stuff()
return "print('hi')"
end


script 2
loadstring(_G.stuff())()
>hi

That should work for having a function in a different script environment.
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
24 Feb 2013 08:51 AM
Right now, I'm handling errors like not valid member, read only properties and such with the TestService (testservice:Check(false, error)).



hm, but to make the stuff you just posted to work with this 'meta service'... urgh, I guess that's somewhat different.




- As, clickpack.
Report Abuse
einsteinK is not online. einsteinK
Joined: 22 May 2011
Total Posts: 1015
24 Feb 2013 09:09 AM
Or use the instance type BindableFunction.
(Warning, like with _G it works different for a server than a player)
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
24 Feb 2013 09:14 AM
Nah, I don't like using instances for this test.


Also, I just found out that I made a mistake, so that if you tried:

_G:GetService("SarcasmService").Name = "Something", then it wouldn't trigger the metaevent allowing .Changed to trigger.


> Script runs through table to see if Name exist.
> Name exist. STOP --------------------------------------------------
> If Name didn't exist, go to metamethod.
> In metamethod, the code for triggering .Changed is located. Aw D:




- As, should we maybe turn all methods and events into locked stuff, so they cannot be changed?
Report Abuse
einsteinK is not online. einsteinK
Joined: 22 May 2011
Total Posts: 1015
24 Feb 2013 09:20 AM
Use metastuff _index?
It will be called when indexed and I guess also new value when ... = ""

Then you can do tests like "Is the new value a string? no? ERROR!"
Then really do realdata.Name = newvalue
Or to get the value (Stuff = Table.Name)
You just return realdata.Name
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
24 Feb 2013 09:23 AM
Right now, I'm using somewhat the same method as with the "_Proxy" properties, just with _Meta. Then I use rawest when it's going to be set, and rawget to get it. Hm, yeah.



- As, why can't I stop posting random stuff here?
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
24 Feb 2013 09:46 AM
So, what would be a nice way to stop this code (as well as any other code running over more than one frame) from sending error to the output?

-------------------

print("Hello world")

wait(2)

delay(1, function() pprint("Hello world?") end)

workspace.Nname = false

-------------------



- As, we have an error at line 137, don'cha know? Wait, it was just a check.
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
24 Feb 2013 10:10 AM
Ok, I've ended up using:


coroutine.wrap(function(key) xpcall(v(key), function(err) if err then game:service("TestService"):Check(false, "Hello") end end) end)(key)

Where key is the value that function v will get. Function v is the function that we don't know will glitch.


Output was...
_G:GetService("SarcasmService")... bug-stuff, this line is good.
_G:GetService("SarcasmService")... line 1, this line is good too.
Workspace.SarcasmService:line 135 or something like that (The line I've written down ^), which is not good, as we want to erase all tracks of that script.
stack end



- As, yeah, this stuff doesn't seem to make any changes at all?
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
24 Feb 2013 10:22 AM
Hey, does xpcall work on a function that contain wait(1)?


- As, oh, I'm getting tired of these weird messages.
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
24 Feb 2013 10:52 AM
Ok, I think I've found a solution.


Yet, I need a way to turn a function into a string? Or...

Here's what I've found: http://www.roblox.com/Forum/ShowPost.aspx?PostID=58421891#58421891



- As, topictopictopicyaaaaay!
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
24 Feb 2013 11:32 AM
Okay, so before we end off here...




Would there be a way I could detect from Script1, which script is calling this global function?

--------------------- Script1:

function _G:somefunc(var) print(self, var, script) end
wait(2)
_G:somefunc("Hello")

--------------------- Script2:

wait()
_G:somefunc("Hi there!")

---------------------



Now, that will in both cases return Script1 as 'script'.
What I'm in search of is some way to get _G:somefunc() to print Script2, without needing Script2 to pass in an argument for itself? getfenv maybe?



- As, let's all dance in one server next Saturday!
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
24 Feb 2013 03:11 PM
Hooray, released the first test of this service.


Would you mind try playing with it for a while?

http://www.roblox.com/MetaService-SarcasmService-item?id=107807122





- As, I am going, bye. Not forever though, heh.
Report Abuse
einsteinK is not online. einsteinK
Joined: 22 May 2011
Total Posts: 1015
28 Feb 2013 11:45 AM
xpcall can't use waits -.-
use ypcall instead, that one CAN actually accept yields (downloading stuff, waiting, ...)
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
28 Feb 2013 12:22 PM
< Yeah... but ypcall will send errors to the output too 3: That's awful!

- As, if I told you I'm using xpcall, then I won't use it, muhohohoho.
Report Abuse
einsteinK is not online. einsteinK
Joined: 22 May 2011
Total Posts: 1015
28 Feb 2013 12:41 PM
Good point, and I'm not capable (so I guess nobody) to catch ypcall errors in xpcalls ...

But, why bother the output?
It's only irritating in studio, but not online, like not -.-
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