playerelite's Forum Posts

  • Hello,

    I have a problem with the unbounded scrolling feature :

    I have an enemy moving with the RTS behavior (the circled one) and I'm the other sprite.

    When I get out of the layout (with unbounded scrolling), the enemy become invisible :/ it only happens when he is moving

    How to fix this please ?

    Thanks in advance, playerelite.

    EDIT : I restarted CC and it seems to be fixed ! Any idea of what might have cause this problem?

  • Hey, thanks for this plugin, btw I have a problem when I'm using it with python :

    When you use UniqueSprite.x or UniqueSprite.y it always return "0" :/

    # v = the unique sprite instance
    
    if MouseKeyboard.MouseButtonDown(0):
    	v.SetPosition(System.MouseX, System.MouseY)
           # so now v.x, v.y should be : System.MouseX, System.MouseY
    
    hp.SetText(str(v.x) + ":" + str(v.y)) # but the text is -> 0:0
    [/code:2ql6tlk4]
    Those things works when you use the default Sprite object (the construct's one) and return the Sprite current X and current Y.
    
    Any way to solve it ? 
    
    Thanks in advance
  • Thanks !

    Now I can call any object without losing it

    I'm creating something like a "game engine" (a customizable game would be a better word), I'm done with objects (picking, attributes) etc.. and now i'm working on events :

    is there any way to access Construct Events with python ? Or should I do like pygame :

    In construct  : On key "Q" pressed : run python : pyorbit.events.append("KeyPressed:Q")
    
    and then in my "loop.py" file :
    
    for event in pyorbit.events:
         do stuff
    
     [/code:1octdss7]
    
    Thanks a lot for all the help you provided to me !
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I gave a look and I haven't seen anything that could cause this error :/

    I suppose that the game was working by the past, right?

    If yes, what have you done before the error appears ?

    Did you have 7 layouts by the past? (i've seen in your events "Go to layout 7") and your event sheet 3 name is Layout 7 events

  • If you drag an item to the "show inventory button" and then you drag another item, they both will be in 1 slot

    Cf :

    http://www.pixenli.com/images/1416/1416772224086237100.jpg[/code:2wom7wp5]
  • rghost.net / mediafire.com

  • This probably comes from your events, could you share your .cap file ?

  • Here's the gist of accessing objects and picked objects in python:

    documentation-for-span-class-posthilit-python-span-scripting_p622892?#p622892

    Behaviors are accessed like so. If the object is called Sprite and the behavior is Platform then the behavior is SpritePlatform from python. Be aware python is case sensitive.

    To access the behavior paired with the object you do it like so depending on the way you access Sprite.

    Sprite

    SpritePlatform

    Sprite

    SpritePlatform

    SOL.Sprite

    SOL.SpritePlatform

    SOL.Sprite

    SOL.SpritePlatform

    You can also see a list of them from python by setting some text to the dictionary with a snippet like this:

    Python("str(dir())")

    Also you can look at a list of methods available in a similar way:

    Python("str(dir(SpritePlatform))")

    Hey,

    Is Sprite[x] supposed to pick the "Sprite x" ?

    Because when I create for example 10 Sprite, if I do Sprite[0].SetX(1) and then Sprite[4].SetX(25) -> it's always the same Sprite object that moves :/

    EDIT : It looks like that if I create those sprite in the Construct Layout Editor (copy paste 5 time the sprite), the Sprite[x] thing is working BUT if I create those using python :

    System.CreateByName("Sprite", 1, 100, 100)
    [/code:2d8t12t0]
    
    then the Sprite[x] thing is giving me this error :
    [quote:2d8t12t0]
    ---------------------------
    Error
    ---------------------------
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\A\F\G\SRC\main.py", line 30, in <module>
        execfile("src/load_game.py")
      File "src/load_game.py", line 5, in <module>
        Sprite[1].SetX(10)
      File "<string>", line 911, in __getitem__
    IndexError
    
    ---------------------------
    OK   
    ---------------------------
    
    
    
    my python code is 
    [code:2d8t12t0]
    System.CreateByName("Sprite", 1, 500, 200)
    Sprite[1].SetX(10)
    [/code:2d8t12t0]
    
    There is 1 sprite instance created with the layout editor (Sprite[0]) and one with python (supposed to be Sprite[1])
    
    [h2][b]EDIT 2 :[/b][/h2] Sprite[x] seems to works only when ALL the code of "load_game.py" was executed, is there a way to access Sprite[x] before all the code was executed (except SOL.Sprite) ?
  • Hey !

    I found a way myself, I don't know if it's the best one but it's working !

    First, to import the class, do :

    Start of layout, python script :

    import sys, os, random
    
    class GNPC():
    	
       def __init__(self):
          # npcList
          self.npcList = []
          self.npcListMov = []
       def addNpc(self, npcObject, npcObjectRTS):
          self.npcList.append(npcObject)
          self.npcListMov.append(npcObjectRTS)
    
    npcManager = GNPC()
    [/code:22wogsv7]
    
    Then, when you spawn NPCs (for each npcs etc..) do : 
    [code:22wogsv7]
    npcManager.addNpc(SOL.entity, SOL.entityRTS)
    [/code:22wogsv7]
    
    Finally, to call event from your object : (for example : every X seconds -> for each object -> do this code)
    [code:22wogsv7]
    npcManager.npcList[0].SetValue("test", 500) # This is to call events from the object
    npcManager.npcListMov[0].MoveTo(random.randint(1,7000), random.randint(1,4000)) # This is to call events from the RTS Behavior (of the object)
    [/code:22wogsv7]
    
    [b]EDIT[/b] Btw, I don't know how to add python variables to objects in a list :/
  • Hey, well I created a class for my objects but this I don't know how to add it to Construct :/

    I tried adding it in start of layout -> Python Script -> my class etc..

    With : execfile(path to my py file)

    but it doesn't work, so, how can I add a class to a Construct project :s ?

    Thanks in advance for your help !

    player.elite

  • Is there a way to create new private variables using python ? Or do I have to create a private variable called for example "parameters" and then split the content to create something like private variables ? (exemple : parameters -> "var1_value:var2_value" etc... and then to get value1, parameters.split(":") -> parameters[0]) ?

  • Wow ! Many thanks for this quick answer

    Also, thanks for the link, I did not know about the SOL.Sprite[X] : I always thought that picking an object was replacing the last one !

    Many thanks again

    player.elite

  • Hey guys, can someone tell me how to access behaviors event with python please ?

    I mean, for example : Sprite.Behavior.RTS.MoveTo etc... ?

    Thanks in advance !

  • Ahahah :p

    Yeah, in an old project I had a lot of events and it was really buggy -> took 30 seconds to load the project (even if I have i5 3.4 GhZ processor, 8 Gb ram etc...) but now I use this way :

  • A good reason to use CC is that it's free and you can sell your game.