Silent Cacophony's Forum Posts

  • Hi. The link to your .cap file is bad, so I could not see what you were doing for timekeeping.

    However, it's fairly easy to pad a number out with zeroes to two digits. Here's an example that assumes you have a Text object for display, and use the Date object for the current time:

    + System: Every 1000 milliseconds
    -> Text: Set text to Date.GetHour & " : " & Right("00" & str(Date.GetMinutes), 2)[/code:2o3x8c7e]
    
    It simply converts the minutes to a string with [i]str(Date.GetMinutes)[/i], concatenates that onto the string [i]"00"[/i], then returns the rightmost two characters with the [i]Right()[/i] function.
    
    In this case, you'd probably just need [i]"0"[/i] in place of the [i]"00"[/i], but the two leading zeroes would be needed in case the minutes string ever returned an empty string, depending upon how you keep time.
    
    If you don't know of it, there is a page on the Wiki with a list of helpful functions for use in expessions, such as the str() and Right() functions used above:
    
    [url]http://sourceforge.net/apps/mediawiki/construct/index.php?title=System_Expressions[/url]
  • Hi. Though I'm not entirely sure what the effect is that you are going for, I can say why the building won't get chopped while the player character is in it.

    + Player1box: Player1box overlaps Buildingfloor
    + Building: Pick closest to: Buildingfloor.X, Buildingfloor.Y
    -> Inside: Set animation to "Normal0"
    -> Building: Set animation to "Cutaway"
    + System: Else
    -> Inside: Set animation to "Normal" & Global('Chopped')
    -> Building: Set animation to "Normal" & Global('Chopped')[/code:2zl0dffx]
    
    Pressing tab modifies the global variable [i]'Chopped'[/i]. Notice that [i]'Chopped'[/i] is completely ignored if the player is in the building, as the animations are set specifically to[i]"Normal0"[/i] and [i]"Cutaway"[/i].
    
    While the player is outside, the animations are set dynamically to [i]"Normal" & Global('Chopped')[/i], which does take into account the status of the global variable.
    
    So, you need to work the status of [i]'Chopped'[/i] into the first condition somehow, as you did in the second.
    
    Another thing I noticed is that the [b]Inside[/b] object probably should be picked in a similar manner to the [b]Building[/b] object for those conditions, if you don't want both to be changed as in your original problem.
    
    I wasn't able to look at the animations in the cap, as Construct crashed when I tried any of them. I assume you use a version before 0.99.84. It seems to run fine, oddly enough. It may be worth checking that you can still access those if you are working with one of the posted caps.
    
    Also, your cap link was bad in the last post.
  • I'm not quite sure why the first press of TAB does not register in that .cap, but there is a better way to structure such a condition if it's just 2 states for the variable:

    + MouseKeyboard: On key Tab pressed
       + System: Is global variable 'Chopped' Equal to 0 -> System: Set global variable 'Chopped' to 1
       + System: Else -> System: Set global variable 'Chopped' to 0[/code:3e365npy]
    
    The TAB key is checked once, and if true, the global variable is checked as a sub-event, with an else clause for the second case.
    
    Since it's easier to see the organization of events in a .cap, here's a fixed one (0.99.84):
    
    [url]http://dl.dropbox.com/u/5868916/VirusSectorFix.cap[/url]
    
    Anyway, this detects the TAB every time for me. I modified the Buildingfloor check above a bit too, though it worked fine before.
  • Just noticed this on the main page:

    Who is online

    In total there are 18 users online :: 5 registered, 0 hidden and 13 guests (based on users active over the past 10 minutes)

    Most users ever online was 63 on Wed Jul 22, 2009 1:21 pm

    Registered users: Citnarf, Google [Bot], Guyon, Majestic-12 [Bot], Silent Cacophony

    Legend: Administrators, Global moderators

    ....

    *puts on tin foil hat*

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello.

    It's odd, but I can't seem to find a way to read the HashTable or Array objects either. I assume that this will be fixed sometime, but it can be worked around as well.

    As Daiz pointed out, the 'System: Run Script' action would be the way to set python variables from a construct event. Note that if a string is used instead of a number for the value, you'll have to enclose the value in single quotes, like so:

    -> System: Run Script ("mylist[" & index & "] = '" & stringvalue "'")

    Also, retrieving the python variable value is quite easy, with the 'Python()' expression in construct. Like so :

    Python("mylist[" & index & "]")

    I'd probably just use python lists and these methods, myself.

    I've included a .cap that demonstrates this, and also a way to access a construct array from python using functions. Here:

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

  • Hi.

    I don't know if I'd really call it a bug. The problem is that you have 'Auto Rotate' checked, and a hotspot that is not centered on the sprite, so it rotates into the ground when you turn around.

    If you check 'Auto Mirror' under the angle properties, that should take care of it. Or perfectly centering the hotspot may work.

  • Thank you very much. That helped me a lot. But one little Problem is still there. How can i load an Image from an ini file with such a function ?

    INI.ItemString("item1", "image1") does not work in Function.ProcessSprite("Sprite", "Sprite2").

    If i can load the image from an ini string, my problem will be solved.

    You're welcome. I'm not terribly familiar with the INI object, but I added one and replaced the function call in start of layout with this:

    + System: Start of layout
    -> INI: Set INI file to "MyINI"
    -> INI: Write string "Sprite2" to item "Item1" in group "Group1"
    -> Function: Call function Function.ProcessSprite("Sprite", INI.ItemString("Group1", "Item1")) (and Forget picked objects)
    [/code:2h0ho73a]
    
    ... and it worked the same as before. Assuming that you're storing object names in the INI file.
    
    Also, the same as above can be done from python as:
    
    [code:2h0ho73a]INI.SetFile("MyINI")
    INI.WriteString("Group1","Item1","Sprite2")
    Function.AddParam("Sprite")
    Function.AddParam(INI.ItemString("Group1","Item1"))
    Function.Call("ProcessSprite", 0)[/code:2h0ho73a]
  • Well, you can use variables instead of string or number literals. The variable just has to contain the name in string form, or the Object ID in number form, as R0J0hound pointed out.

    The bigger issue is the fact that the python methods are messed up, but it should be possible to work around that with the function object. I made a simple example with a couple of different ways to use the function object to do image processing, including from python.

    v.99.84 Cap here: http://dl.dropbox.com/u/5868916/FunctionWorkaround.cap

  • Yeah, I can't get it to work either.

    I also noticed that there seems to be no method defined for 'Copy from sprite', which makes Python usage of the manipulator even more difficult.

  • Hi. From my interpretation of the original post, it sounds as if you only need a 2-D array, like so:

    x1y1, x1y2, x1y3,

    x2y1, x2y2, x2y3,

    x3y1 ...

    Ok, so that may not be clear, but I made a simple example based upon what you described, and showing loops as well:

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

  • I generally make a copy of an event by dragging it while holding control, then make the new condition, then delete the rest of the conditions and actions. It depends on the event, but this can be sometimes faster.

    Wow. I didn't know about the control-drag thing. Thanks for the tip. That will do nicely for me.

    I may as well add that this issue has annoyed me in the past as well...

  • Oops. After using this more, I found a bug in the way I handled detection of the 'enter' key, which also affected command editing around newlines. I also decided to add a few minor changes along with that fix.

    • Fixed the bug with 'enter' key handling, and cleaned up some unnecessary code along with it.
    • Added a control to reset the shell (control - delete.) This returns the shell to it's initial state, but leaves the Python environment the same. Any classes/functions/variables assigned will remain.
    • The shell now loses focus when a command is executing. This serves as a visual cue, and prevents extraneous input. It also regains focus automatically after exceptions are raised.
    • The first entry in the command history is now an empty string, to serve as an indicator that the beginning of the history has been reached when cycling through it. Also, other empty and exact duplicate commands are now discarded instead of being added to the command history.

    I can't seem to break it now, so hopefully that will do it.

  • Ouch... That is surely a sad amount of code for the end result. I think I'd prefer SDL or some other framework for something like that.

    Anyway, dev appreciation is surely in order for a great project such as this one. Thanks to core devs especially, and also to those who have pitched in plugins and fixes and such.

  • Thanks for the comments. I've updated this a bit.

    I've found myself using this more often, so I set about making it a bit more user friendly. After a fair amount of trying to force Construct's EditBox object to do my bidding, the result is what I consider to be a fairly respectable command line shell. It works in a manner similar to the Windows version of the Python IDLE Shell, with a command history that works similarly to older shells. Some notable features:

    • Like the Python IDLE Shell, when a command block is entered, if it evaluates to an expression, the shell will print a representation of the result (if it is not the value None.) Otherwise, it is simply executed.
    • Auto indentation similar to the Python IDLE Shell.
    • Keeps a display history of (approximately) the most recent 90,000 characters in the shell. This is able to be changed easily. Higher numbers may slow the shell's responsiveness. This display history may not be changed, but may be moved through in order to copy portions and such.
    • Keeps a command history of all command blocks that have been entered. These commands are recalled in a manner similar to the way that old unix shells work. In this case, 'control - up arrow' moves in reverse through the commands, and 'control - down arrow' moves forward through the commands. Recalled commands replace any current command entry, and may be edited (or not) and executed again.
    • All variables used in the code here were added to the 'Shell' object so that they would not pollute the global namespace. Otherwise, there is a PyShellOutput object name added to handle output.

    I had also hoped to thread the output so that it didn't display all of the output only after the command block was done executing, but ran into deadlocks when trying to access Construct objects from a thread. I scrapped that, as it's not of much consequence.

    I set the window/layout size to 640 x 480, but it's easy enough to change to one's preference. I decided against making window resizing possible, as I couldn't get it to work to my satisfaction.

    The screen shot and attachment are updated in the original post for this version.

  • Without MS we wouldn't have computers or Al gore's etherweb. So we will be their slaves forever, and love it.

    Computers and the internet would certainly still be here, had Microsoft never existed... The 'popular' OS would probably be based upon Linux, which would be fine by me.

    I'll leave it at that for a MSRANT.

    Anyway, I've always found it quite alarming how the masses of young people looking to enter any market always seem to jump on the most crowded bandwagon. How is one to distinguish oneself from the rest that way? Ah well...

    OpenGL isn't going away, in any case, so those who dare to be different can enjoy it if they wish.