Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 180503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:35:52+00:00 2026-05-11T14:35:52+00:00

This is a WoW (World of Warcraft) lua script question. Not many of these

  • 0

This is a WoW (World of Warcraft) lua script question. Not many of these get asked here but I have no where to turn and Stackoverflow is the programmer oasis for answers.

Question:

Wowwiki states that the 2nd, 3rd, 4th arguments are your calling functions 1st, 2nd, 3rd arguments. I don’t find this to be true. I find that the 3rd, 4th, 5th arguments end up being the 1st, 2nd, 3rd arguments.

Link: http://www.wowwiki.com/API_pcall

Function:

function myTest(arg1)    return arg1 .. 10;  end  

Problem:

local retOK, ret1 = pcall(myTest,'string value');  

when I try the sample I get an error of ‘trying to perform concatenate on local ‘arg1′ (a nil value)’. If I change the code to:

local retOK, ret1 = pcall(myTest,'string value', 'bob');  

then I get the output of ‘bob10’. Where does the 2nd argument go and what is it for?

More Testing:

function BobsToolbox:RunTest()    local test1, value1 = pcall(BobsToolbox.Test1, 'string value');    SharpDeck:Print('Test1: ' .. tostring(test1) .. ' Value: ' .. tostring(value1));  end   function BobsToolbox:Test1(arg1)    return arg1 .. '10';  end  

Results: attempt to concatenate local ‘arg1’ (a nil value)

function BobsToolbox:RunTest()    local test1, value1 = pcall(Test1, 'string value');    SharpDeck:Print('Test1: ' .. tostring(test1) .. ' Value: ' .. tostring(value1));  end   function Test1(arg1)    return arg1 .. '10';  end  

Results: string value10

I am new to lua and I can’t understand why these are different.

New Question:

The following code works but why?

function BobsToolbox:RunTest()   local test1, value1 = pcall(BobsToolbox.Test1, 'string value');   SharpDeck:Print('Test1: ' .. tostring(test1) .. ' Value: ' .. tostring(value1)); end  function BobsToolbox.Test1(arg1)   return arg1 .. '10'; end 

What’s the difference between the following: (‘.’ vs ‘:’)

  • function BobsToolbox.Test1(arg1)
  • function BobsToolbox:Test1(arg1)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T14:35:53+00:00Added an answer on May 11, 2026 at 2:35 pm

    Lua Documentation:

    http://www.lua.org/pil/16.html

    This use of a self parameter is a central point in any object-oriented language. Most OO languages have this mechanism partially hidden from the programmer, so that she does not have to declare this parameter (although she still can use the word self or this inside a method). Lua can also hide this parameter, using the colon operator. We can rewrite the previous method definition as

    function Account:withdraw (v)      self.balance = self.balance - v  end  

    and the method call as

    a:withdraw(100.00)  

    The effect of the colon is to add an extra hidden parameter in a method definition and to add an extra argument in a method call. The colon is only a syntactic facility, although a convenient one; there is nothing really new here. We can define a function with the dot syntax and call it with the colon syntax, or vice-versa, as long as we handle the extra parameter correctly:

    Account = { balance=0,     withdraw = function (self, v)          self.balance = self.balance - v      end  }   function Account:deposit (v)      self.balance = self.balance + v  end   Account.deposit(Account, 200.00)  Account:withdraw(100.00)  

    Possible Conclusion:

    With this in mind I assume that when calling a ‘:’ function using ‘pcall’ you must supply the ‘self’ argument.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Wow, what a stupid question you might say. But is it possible? I have
I have a recipe tracker tool for World of Warcraft players here: http://www.wowgeeks.com/tracker.php?item=recipes .
this is my first question here. I have the following jquery code: $(document).ready(function(){ $(a).click(function(){
Wow, it's hard to find a simple explanation to this topic. A simple many-to-many
This IS NOT homework, but it is a practice that the teacher gave us
I have some xml like this: <animal name=Bow Wow type=dog> <birthDate>May 17,2001</birthDate> <descirption>Bla bla
Good afternoon, Wow what a title. Basically here is the thing. If have a
Hey guys. So, I have a Python script. Let's call it Pythonfile.py (Wow, I
This problem came up in the real world, but I've translated it into a
I saw app inventor and have tried it and thought wow this could really

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.