[HELP] Call last created object in Python

This forum is currently in read-only mode.
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hey everyone..

    I searched for this around here and found something about the SOL object, but to be honest not sure if this is really what I'm looking for..

    I'm with a little question about accessing a newly created object using python and change their values... example..

    I have a script that creates a new sprite object..

    then I want this new sprite have the variable ('test') the value 10.

    So how do I call this object after created?

  • Yes, SOL is what you want. The post from ROjohound in this thread is what you are looking for:

  • As always, thanks scidave!

    This SOL object is py.csx plugin from lucid right?

    The Construct is crashing when I try to execute this script, what might be the problem?

     id=System.globalvar('GAME ID')
     query="""SELECT * FROM PLAYER_ITEMS WHERE PLAYER_ID = %s"""
     cursor.execute(query,(id))
    
     results=cursor.fetchall()
     for row in results:
    	value=row[1]
    	value1=row[2]
    	value2=row[3]
    	value3=row[4]
    	value4=row[5]
    	value5=row[6]
    	itemname="n"+str(value)
    	System.Create(itemname,2,value1,value2)
    	objref=py.GetSOL(itemname)
    	objref[py.SOLi].SetValue('R',value3)[/code:2garosdq]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here is a more basic example of what I'm trying to do..

    value=40
    name="N"+str(value)
    System.Create(name,1, 0, 0)[/code:3vd45ghj]
    
    if I try and use:
    [code:3vd45ghj]
    SOL.name.x=300[/code:3vd45ghj]
    
    It ill show an error[i](AttributeError:class SOL has no attribute 'name')[/i]
    and I really need to get the object with a script like that.. cuz the value changes and so the objects created.
    
    EDIT: It's NOW WORKING Thanks to R0J0hound!
    Had to use eval()
    here's how:
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)