Object Manipulation with Python

This forum is currently in read-only mode.
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • I ran into a problem while trying to play with that new Python functions.

    System.Create('Sprite',1,random.randint(200,400),random.randint(200,400))
    SOL.Sprite.Filter=System.RGB(255,255,255)[/code:3r40wsxi]
    I simply wanted to set the colour filter of newly created sprite, but unlike setting the position it thrown an error "NoneType object is not callable"
  • [quote:eq5613lp]it thrown an error "NoneType object is not callable"

    System.RGB(255,255,255)

    is incorrect, it's:

    System.rgb(255,255,255)

    Notice the lowercase.

    -cheers

  • GAH!

    I must explain myself: built in Pyhton editor suggested usage of "RGB"(caps) i thought that it was correct.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It really useful for me, thanks for the info that you guys have been discussing.

  • Luomu, that will work no problem. Also you can eliminate the "objref" variable and do it directly:

    System.Create('Sprite', 1, 0, 0)
    SOL.Sprite.x =300[/code:2fstjl4k]
    

    And how do I get the new created object in the condition below?

    value=40
    name="N"+str(value)
    System.Create(name,1, 0, 0)[/code:2fstjl4k]
    
    if I try and use:
    [code:2fstjl4k]
    SOL.name.x=300[/code:2fstjl4k]
    
    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..
  • Try this:

    value=40
    name="N"+str(value)
    System.Create(name,1, 0, 0)
    newobj=eval('SOL.' + name)
    newobj.x=300[/code:1a1ac7tf]
    
    eval() evaluates any python string.  Now you will only have an error if there is no object named "N40".
  • Try this:

    value=40
    name="N"+str(value)
    System.Create(name,1, 0, 0)
    newobj=eval('SOL.' + name)
    newobj.x=300[/code:1m2irun2]
    
    eval() evaluates any python string.  Now you will only have an error if there is no object named "N40".
    

    It worked!!!!!!! thank you!!

Jump to:
Active Users
There are 2 visitors browsing this topic (0 users and 2 guests)