lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Roger,

The SWIG generated wrapper is expecting the following arguments:
 
    Arg1 - the SWIG generated object pointer
    Arg2 - an int (int i)
    Arg3 - an int (int d)

GameEntity.stSTR is no longer bound and so resolves to nil. Thus, arg2 is nil
and you get the error you reported. See where you used to bind this value and
see what's changed.

Regards,
-Aaron



-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Roger Durañona
Vargas
Sent: Saturday, January 23, 2010 4:57 AM
To: Lua Mailing List
Subject: problem with swig code

I have a weird error in code generated by swig. Here is the .i file:

%module GameEntity
%include <std_string.i>
%include <../include/GameEntity.h>
%{
#include "GameEntity.h"
%}

This is the class:

class BaseStats {
    public:
        int stats[stLUCK];
        //int  &operator[]  ( int index) {return stats[index];};
        int __getitem__(int i)  const ; // i is the index, returns the data
        void __setitem__(int i,int d) {stats[i]=d;}; // i is the index,
d is the data
};

So, from lua scripts I can do:

entity.stats[GameEntity.stSTR]=19;

Until a few days this was working fine, but now  Im getting an error:
Error in __setitem__ (arg 2), expected 'int' got 'nil'
i really have no idea about what did I change to produce this. As I
said, this worked perfectly, until last week, and I didnt touched the
related code, so I guess I have a problem in some place, but I have no
idea about where to search. Can somebody suggest me something?