Silent Cacophony's Recent Forum Activity

  • Hi. I'm tired, and didn't have much time to test the new build, but I'm getting crashes when trying to access private variables from Python. Perhaps I'm missing something, though.

    In the past, I've handled this by adding my own variables to the Python instances of those objects, instead of using Construct's private variables. They can be read in Construct events by using the System object's Python() command.

    I don't think that your first question is possible in construct events, due to the special notation that Construct uses for variable names. However, it should be fine from python, provided that you use a python string variable containing the global name, possibly using the workaround mentioned above.

    Such as, the python expression: system.globalvar(object.somevar)

    As for your second question, I've only found a bit of a hack that will do that. Either append the text, then set the selection to to the end of the text, or set the selection to the end of the text, then replace the selection with the text to be added. The latter is a bit prettier in practice. The set selection action will force visibility.

    Take a look at the write() method of the PyShell class in my PythonShell. It handles writing of all text to the EditBox that is used as an interactive Python shell. A simpler example, in python:

    text = "Text to add.\n"

    EditBox.SetSelection(len(EditBox.Text), len(EditBox.Text))

    EditBox.ReplaceSelection(text.replace('\n', '\r\n'))

    The EditBox uses '\r\n' as newlines.

    I don't know about your third question. Being Windows objects, I think you may have to move them out of layout or destroy them to get that behavior.

  • Hi. Back in your Animation Events, something like this should be about what you describe:

    + Player: is walking

    -> Anakin: Set animation to "Walking"

    -> Anakin: Set animation speed to 20

    + System: Else

    + Anakin: [negated] Anakin: Animation "Lightsaber" is playing

    -> Anakin: Set animation to "Idle"

    + Anakin: Animation "Lightsaber" finished

    -> Anakin: Set animation to "Idle" <---- added this entire event

    Note: These use Construct's "Copy as Text' right-click context menu function, in case you didn't know about that. '+' indicates conditions, grouped together until the '->' that indicates the actions for the event. Changes that I made in bold.

    It seems that in order to effectively use the Animation "Whatever" is playing condition, you must change the animation manually as I did in the new event. Even if it's set to play only once, it will be considered still playing until a different animation is set.

  • In the Animation event sheet, your idle animation overrides the Lightsaber almost immediately. I added the condition in bold after else in the else event to get it working, though the animation is too fast in this mock up.

    + Player: is walking

    -> Anakin: Set animation to "Walking"

    -> Anakin: Set animation speed to 20

    + System: Else

    + MouseKeyboard: [negated] Player 1 "Action" is down

    -> Anakin: Set animation to "Idle"

    Depending upon the desired behavior, you may need to make the conditions a bit more complex. I haven't worked with animations much, but I found it puzzling that I couldn't get the 'On animation playing' and 'On animation finished' conditions to work (I set the Lightsaber animation so it wasn't looping.) Not sure what that's about... I'll have to try that again later.

    You may notice that I used [negated] Player 1 "Action" is down above to keep the idle animation from overriding the Lightsaber animation. I replaced the 'Key Enter is down' below (in the Lightsabe events) with an action check as well, as it's a bit more friendly toward changing controls and such that way.

    + Player: is on ground

    + Player: Value 'canslash' Equal to 1

    + Player: [negated] is moving

    + MouseKeyboard: Player 1 "Action" is down

    -> Anakin: Set animation to "Lightsaber"

  • That demo was pretty slick all around, R0J0hound. There are some ideas in there that I hadn't thought of. Thanks for posting them.

    I see that the way you visually constructed them was pretty much as I would have. In lieu of an object that does such a thing, these objects allow some nice customization with colors, fonts, opacity, sizing, and more. This would allow them to fit into the theme of the game a bit better than a basic one.

  • That looks pretty cool, Minor

    Anyway, if you determine that you need to implement such an idea, it wouldn't be too bad to implement in Python for one of us who program with it. I know of a nice flood fill algorithm in python that could be trivially adapted to this, but a few very specific details would be needed in order to make it correctly. A lot easier to insert python code than Construct events, too.

    However, some extra overhead would be introduced, since Python cannot read Construct arrays, currently. You'd have to construct a Python list copy of the Construct array from Construct events, and call the python code, which will operate on the list, then copy the result back to the Construct array. This would likely be done in a Construct function, each time a flood fill was needed.

    Just something to think about. As I mentioned, I think it's quite possible with only construct events, too, but it would be more difficult to copy between projects.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I've yet to figure out what it does. Add/Remove sounds as if it should add or remove a custom attribute, but it doesn't seem to be aimed at that. It seems to be aimed at setting/clearing an existing attribute, but it does not work for me, either.

    Both of the above should be implemented, but the latter would be necessary to make the former useful.

  • That's getting into more difficult territory. If Construct's image manipulator or canvas had a flood fill, it would be fortunate, because they could be used as helpers for this. Alas... it is not so.

    The simplest way that i can think of to do that would be like so, in my own weird pseudocode:

    untouched = -1 # needs to b a value different than the number 1 and above
    water = 0
    z = 1 # setting this as static outside the loop makes the routine operate on the array as if it were a 2-d array, only at the z depth set.
    
    func flood_fill(array, x, y, z, fill, border):
       # Fills all connected cells surrounded by border, starting at array(x, y, z), with the value in fill.
       # Some flood fills use connected cells of same value instead of using a border.
       # flood fill algorithms can be 4-directional or 8-directional (allows diagonals to be considered connected)
       ... a bunch of code here ...
    
    count = 0
    for y = 1 to array.y_size:
       for x = 1 to array.x_size:
          if array(x,y,z) = untouched:
             count = count + 1
             flood_fill(array, x, y, z, fill=count, border=water)[/code:2bx2ys0n]
    
    I've not programmed a flood fill routine before. It should certainly be possible to implement as a function in Construct, but would certainly be easier in Python. Python doesn't work well with Construct's Array object, but that's possible, too.
    
    I'd probably look for a non-recursive algorithm using a stack to work from, since it looks as if another Construct array could be suitable for use as a stack.
    
    Maybe someone else will have an easier idea.
  • Speaking of Python, it also has array objects that can be imported via the internal array module or the external NumPy module. It may be a bit more than you'd want to bite off right now, though. The 3-D array that you're using should work fine, too.

    Don't short-sell your abilities, Minor. I've considered doing this sort of procedural generation in the past, but the idea scared me away before I even got started.

    Anyway, just because I feel compelled to point it out, this application practically begs for bitwise operations. Unfortunately, I don't see any support for them in Construct, other than through Python.

    Basically, you can just use a 2-D list or array which contains integer values. Each integer value can have different bits set for any given on/off or true/false state that you need to track. For instance, you can keep the status of bordering land in the four cardinal directions in four bits. Expressing the values in binary notation (with 0b prefix) makes it more obvious what bits are set.

    0b0001 (if land to north)

    0b0010 (if land to south)

    0b0100 (if land to west)

    0b1000 (if land to east)

    You can set the bits with the OR operator (|):

    0b0001 | 0b0100 ( = 0b0101)

    and test them with the AND operator (&):

    0b0111 & 0b0100 ( = 0b0100, testing for bit 3 set)

    Bah, too much to go into here, really. Feel free to ignore the whole bitwise thing... Mostly just me reminiscing about 8-bit computer programming practices that aren't widely used anymore.

    Keep up the good work. I like your creations so far.

  • Well, my eventual solution to making a context menu would probably end up being a group of objects containing a Text, Box or Panel (for border and background), Sprite (for selection cursor), and perhaps a Dropshadow or another sprite (for optional shadow) object. This would be a bit complex, but have a large amount of flexibility.

    But, I was intrigued with the ListBox idea. Actually, the ListBox makes a pretty decent context menu. I made one in nine events. Could be less, depending upon your needs. While it is bit less fleshed-out than I liked, it's rather simple to implement.

    I included comments in the .cap

    http://dl.dropbox.com/u/5868916/ContextMenu.cap

    If nothing else, it's an interesting exercise I may end up making the more complex one at some point. I like those menus, too.

  • Here's a bit of info on the Function Object:

    http://sourceforge.net/apps/mediawiki/c ... ion_Object

    A tip: If you're using functions that take parameters, take careful note of the Calling from expressions section. It's nicer than setting parameters individually in separate actions.

    As linkman said, Construct is somewhat limited in pasting events between projects. It will drop any references to objects in the copied from project that aren't in the project being pasted to. This will usually make a mess of them, leaving very little of the original events.

  • I'm not sure... You can drag around entire events by grabbing the left edge of the box surrounding it. You should see everything in it get highlighted yellow, and as you drag it, look for a black line indicating where it will be moved to. You can use this method to move events so that they are sub-events and such, but it can be tricky getting the black line where you want it. Sometimes you have to keep moving the pointer around 'till you get it where you want it, then release the LMB.

    Also, you can drag conditions and actions out of events into other events, but you can't make new events out of them. I'd guess that this may be your problem. In this case, I just insert a System->Always or something, delete the Always condition (leaving an empty event box,) and then drag the condition from the other event into the empty event box, then move that event wherever.

    Note that I make the distinction between events, conditions, and actions. The events contain the conditions -> actions, and they can all be dragged around in different ways. Control-dragging (ctrl key + lmb drag) is another non-obvious way to duplicate events, conditions, and actions. There are probably other things I haven't discovered yet, though they may be on the wiki somewhere...

  • Is there somewhere I can find out about more of the 'not-so-obvious' commands like the one you mentioned, Silent Cacophony?

    You may have to view the image separately to see it all:

    <img src="http://dl.dropbox.com/u/5868916/expressions.jpg">

    You can get to most of them through the point and click interface, by double-clicking any of the objects at the bottom of the upper window. Sometimes you'll need to double-click an empty area if objects are missing there, which will bring up a new window containing all of them. Then, another window such as the lower one will open with your choices. Double-click one, and it will be inserted into the expression editor at the cursor. Sometimes you'll need to replace argument descriptors with your actual arguments.

    I have to remind myself of these from time to time, by going through the different objects and seeing what they have available.

    Also, the Wiki has two pages that I like on expressions, but they are not the easiest to find:

    System Expressions - Expressions for the System object

    Expressions - General info on expressions

    Have fun!

Silent Cacophony's avatar

Silent Cacophony

Member since 11 Mar, 2010

None one is following Silent Cacophony yet!

Trophy Case

  • 14-Year Club

Progress

14/44
How to earn trophies