Jump to content




pcall acting weirdly


  • You cannot reply to this topic
2 replies to this topic

#1 MudkipTheEpic

  • Members
  • 639 posts
  • LocationWhere you'd least expect it.

Posted 11 March 2013 - 10:16 AM

Somehow, pcall is acting weirdly. When I do pcall(print("test")), it prints test, but returns false and the error: attempt to call number. I am using this in the lua program.

Edit: Oh ya, pcall doesnt take arguments.

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 11 March 2013 - 10:32 AM

You're using it wrong.

pcall(print, "test")

#3 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 11 March 2013 - 10:38 AM

View PostMudkipTheEpic, on 11 March 2013 - 10:16 AM, said:

Edit: Oh ya, pcall doesnt take arguments.
Yes it does!

print("test") returns the number of the lines printed (1, in this case). pcall cannot call 1, because it's a number, not a function.

Use Lyqyd's solution.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users