This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
MudkipTheEpic's profile picture

pcall: bad argument #1: value expected?

Started by MudkipTheEpic, 14 May 2013 - 07:58 PM
MudkipTheEpic #1
Posted 14 May 2013 - 09:58 PM
When ever I try this code, it always errors with startup: 95: bad argument #1: value expected. It is weird, because I try/define everything and then when it gets to this pcall statement, it errors on me.

Installer (Beta)

pastebin get 2LVGRcKi install

PS: Debug prints is what I use to debug, don't hate me! XD

Edit: Oh ya, the code.

https://github.com/M...ob/beta/startup
Mackan90096 #2
Posted 15 May 2013 - 01:41 AM
I think you didn't declare the "func" function.
KaoS #3
Posted 15 May 2013 - 03:01 AM
I think you didn't declare the "func" function.
loadstring returns a function, setfenv returns the function it edited (in this case the loadstring return). I think the issue is that the loadstring is returning nil. Please check that the http.get function is getting the right information and if you loadstring it make sure it returns a function
MudkipTheEpic #4
Posted 15 May 2013 - 09:44 AM
I print the type of the func function, it prints function.

And even if you put pcall(lolololololrotortlotlrtlorto) in the LUA prompt it doesn't say that, only when you put pcall().

Edit: Nevermind, fixed the problem.
KaoS #5
Posted 15 May 2013 - 10:38 AM
what was the problem? I be curious
MudkipTheEpic #6
Posted 15 May 2013 - 06:53 PM
Apparently, in loadfile, if the file has a syntax error, it returns a function with no value? I don't think it actually works that way, or .OSRunner/Boot/startup had a weird problem on line 95. (But when I changed the line on the regular /startup, it also changed the line in the error to the line with that same code.)

I think that it was just a mistake on my part.
KaoS #7
Posted 15 May 2013 - 07:56 PM
heh. I just realized that it was not pcall that was causing that issue… it was setfenv lol, loadstring returned nil which caused setfenv to error before pcall even ran