1

I get the error: source_file.lua:5: attempt to call a nil value (global 'getCard')

i try to catch the right table in questCards which Index=name is the same as the given string from objName

questCards={{['name']='test1',['creatureName']='test3'},{['name']='test2',['creatureName']='test4'}}
obj='test1'
card=getCard(obj)
card['creatureName']=nil --Only for test purpose
if card['creatureName']==nil then
    --do Somthing
end
function getCard(objName)
  for k,v in pairs(questCards) do
    if v['name']==objName then
      return v
    end
  end
end
1
  • As Ihf has said, you're calling the getCard() function before you've defined it, so you need to move the function up above the call to it in the file. Commented Jul 13, 2018 at 20:21

1 Answer 1

1

The error message is telling you that getCard is not defined at the point where it is called.

You need to define getCard before calling it.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.