0 Favourites

Python error, can't solve

This forum is currently in read-only mode.
  • Hello,

    I am currently working on a new project and I'm using python, the problem is that when I start the game, I have an error message and I don't have any idea of where it comes from.

    For the moment the game only have this code (and it works) :

    import os.path
    
    totalObjects = INI.ItemValue("objectsList", "objects")
    objects = 0
    line = 0
    lineObjects = 0
    
    while objects < totalObjects:
    	objects += 1
    	lineObjects += 1
    	if lineObjects > 5:
    		line += 1
    		lineObjects = 1
    	objx = (745 + ((lineObjects - 1)* 55))
    	objy = 105 + (line * 55)
    	System.CreateByName("object", 1, objx, objy)
    	SOL.object.SetValue("name", INI.ItemString("objectsList", objects))
    	if os.path.isfile(System.AppPath + "images/" + SOL.object.Value("name") + ".png"):
    		SOL.object.LoadFrameFromFile(System.AppPath + "images/" + SOL.object.Value("name") + ".png")
    	else:
    		SOL.object.LoadFrameFromFile(System.AppPath + "images/undefined.png")
    [/code:zdl4z7u6]
    
    But I get this when I start the game  (I click ok and then everything works fine, I mean, the code above do what he must do) :
    [code:zdl4z7u6]
    ---------------------------
    Error
    ---------------------------
    Traceback (most recent call last):
      File "<string>", line 1387, in <module>
    TypeError: Error when calling the metaclass bases
        __init__() takes exactly 1 argument (4 given)
    
    ---------------------------
    OK   
    ---------------------------
    [/code:zdl4z7u6]
    
    Has anyone an idea of how to fix this  ?
    
    Thanks in advance 
    Regards, player.elite
  • Hmm, maybe + is acting as an argument? I've not used Python much but checked out some other ways to join the strings together: http://stackoverflow.com/questions/4435 ... o-a-string

    Also, I think events would be faster for this task than Python, is there any specific reason you're using Python? (if you want events already made for that you can check out the source of my I Had Hope game: http://ihadhope.blogspot.ca/p/download.html )

  • Well I'll give a look

    The reason I'm doing this in python is that because the game will be 99% editable, I want to let users mod what they want using python (editing txt python file then they are executed by construct)

    Edit : another reason is that with python I can have temp variables and with events I'd have to create useless global variables...

    Edit 2 : String addition is not the reason, if I replace all my script by anything in python (example : print "hello") it shows me the error message too...

  • Ah good point and have you copied the Python 2.6 DLL from the Construct Classic directory to your export folder? (and told it to include Python in export?)

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Yes ofc :p

  • Unfortunately that's about as deep as my Python knowledge goes sorry Hopefully someone else can stop in and check this out!

  • I think this was a problem in my code (maybe the fact my Sprite is called "object" ?). I recoded everything and now it works

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
48 2,824
C2isthetruth's avatar
C2isthetruth
Unread hot topic
0 Favourites
Depth sorting - almost solved
62 5,164
lucid's avatar
lucid
Unread hot topic
35 3,128
deadeye's avatar
deadeye