[Solved]Wong paramaters being passed?

Sorry if this is in the wrong forum.
I made a module for saving my stats using CrawlSpaceLib (because I was too lazy to make my own module for saving to a file) and in that module i have

stats = {totalBubblesTouched = 0, totalBubblesMissed = 0, totalNastiesTouched = 0, totalNastiesLetPass = 0, totalMissfires = 0, totalPowerupsUsed = 0, totalPowerupsGot = 0, maxBubbles = 0, maxNasties = 0, maxMissfires = 0, maxPowerupsUsed = 0, maxPowerupsGot = 0}  
  
function saveStat(statName, statNum)  
 print(statName)  
 print(statNum)  
 if (stats[statName] == nil) then  
 stats[statName] = statNum  
 else  
 stats[statName] = stats[statName] + statNum  
 end  
end  

I then run it using this in main.lua

function missfireCheck(event)  
 if (event.phase == "began") then  
 statsControl:saveStat("totalMissfires", 1)  
 missfires = missfires + 1  
 print ("Missfires:"..missfires)  
 end  
end  
background:addEventListener("touch", missfireCheck)  

The expected output is

totalMissfires  
1  
Missfires :1  
totalMissfires  

but I get

Output Table Data:  
  
 Key: getStat Value: function: 0x466090  
 Key: stats Value: table: 0x472040  
 Key: \_NAME Value: statsControl  
 Key: \_PACKAGE Value:   
 Key: hardSaveStat Value: function: 0x466070  
 Key: \_M Value: table: 0x488640  
 Key: saveStat Value: function: 0x466050  
 Key: statsDataNilCheck Value: function: 0x472060  
  
Output string :: totalMissfires  
  
Output string :: Missfires :1  
  
Output Table Data:  
  
 Key: getStat Value: function: 0x466090  
 Key: stats Value: table: 0x472040  
 Key: \_NAME Value: statsControl  
 Key: \_PACKAGE Value:   
 Key: hardSaveStat Value: function: 0x466070  
 Key: \_M Value: table: 0x488640  
 Key: saveStat Value: function: 0x466050  
 Key: statsDataNilCheck Value: function: 0x472060  
  

Anyone know whats happening here? [import]uid: 22824 topic_id: 9821 reply_id: 309821[/import]

:’(
Anyone know?
Is it CSL’s fault or something to do with modules?
Or did I just do something wrong?

EDIT: It’s not CSL’s fault, i removed it totally from my file and it still has that problem :frowning: [import]uid: 22824 topic_id: 9821 reply_id: 35988[/import]

Just mentioned a possibiity in IRC, but how about changing:

statsControl:saveStat(“totalMissfires”, 1)

to

statsControl.saveStat(“totalMissfires”, 1)

(subtle difference, but the : is now a .)
Worth a try. [import]uid: 46639 topic_id: 9821 reply_id: 36010[/import]

:smiley:
Someone in irc(Rakoonic) got it for me. The problem was I was using "statsModule:saveStat(“totalMissfires, 1)” instead of "statsModule.saveStat(“totalMissfires, 1)” [import]uid: 22824 topic_id: 9821 reply_id: 36013[/import]

To clarify what was happening, this

statsModule:saveStat("totalMissfires", 1)

is exactly the same as this

statsModule.saveStat(statsModule, "totalMissfires", 1)

The colon is simply a shortcut for passing in the object itself as the first parameter. [import]uid: 12108 topic_id: 9821 reply_id: 36182[/import]

What default names apply to this hidden first parameter? Is it just ‘self’ or are there alternatives? [import]uid: 46639 topic_id: 9821 reply_id: 37506[/import]