Silent Cacophony's Recent Forum Activity

  • Depending upon what format your source text is in, Python can also make short work of such a problem. If you can import the text into a python string (or list of strings), or even paste it into a Construct EditBox object, you can do something like this:

    text = "one plus one equals two, and four minus three equals one."
    terms = [['three', 'five'],
             ['four', 'seven'],
             ['two', 'four'],
             ['one', 'two']]
    for find, repl in terms:
        text = text.replace(find, repl)
    print text[/code:2l3t03l5]
    
    ...which results in this:
    
    [code:2l3t03l5]two plus two equals four, and seven minus five equals two.[/code:2l3t03l5]
    
    There are some [url=http://docs.python.org/library/stdtypes.html#string-methods]pretty powerful string methods built-in to Python[/url]. You can even do this in Construct.
  • I quite like fan games, myself. I intend to resurrect a few 80's games myself, eventually.

    Graphics are the bane of many a programmer, you know. That's why there are so many roguelikes around.

  • Glad to hear you've worked things out, MrMiller. I hope my example was of some help, even so. I also hope that you weren't put off by my assumption that you were a complete beginner, as I didn't have much information to go on, and I'll usually respond as such if I think it's warranted. Make no mistake, it takes more time and effort on my part to go into more detail in explanations and commenting code, and pointing out resources. I trust that you know that I was simply trying to be helpful.

    I'd still recommend poking around with Python, just because I like it so much, and I think others might as well.

    I'm not by any means an expert either, but if you need any further help, feel free to ask (though I'd probably start a different thread...) Forums are a good place to pool information together from many sources, after all.

  • Hello. I'm assuming that you basically have no experience in programming, from your comments above. If that's the case, you may have figured that you're a bit of a hard case to help. Given that you have figured out ways to make things work, such as using an object that frankly scares me (timeline), then don't give up.

    While Scirra has attempted to make make it less daunting, knowledge of programming is still needed, because setting up event sheets is, indeed, programming.

    Global variables are a very important aspect of programming in any language. In most cases, they represent values (of any given type of data) that can be accessed from within any scope of the program, and that may be changed at any time. In Construct's case, this means that they are shared among all layouts. Given global variables, and some simple conditional events based upon them, one can implement all sorts of things.

    As tulamide mentioned, they are a natural way to implement a timer.

    I've made a commented .cap with an example of a timer implemented in such a way. It sets up two similar layouts, each with a "Text" object to display the timer, where one starts manually and the other automatically. Note that the global variables are of numerical value and the "Text" object handles string values. Construct generally handles converting numbers into strings for use with objects such as the "Text" object quite transparently, as is noted in the .cap.

    I hope it helps (v0.99.84): http://dl.dropbox.com/u/5868916/Timer1.cap

    Also, I'd recommend checking out some beginner programming tutorials in general. I'm partial to Python, as it's widely regarded as easy for beginners, and can be used in Construct as well as on it's own. The concepts in normal computer programming and in event-based programming are very similar, naturally. If you're interested, here are some good resources:

    General beginner's guide: http://wiki.python.org/moin/BeginnersGuide

    A nice tutorial aimed at beginners: http://www.sthurlow.com/python/

    Another found from the first link that I liked: http://openbookproject.net/thinkcs/python/english2e/

    I should add that the two last links both start off with examples done from within the python interactive shell (IDLE), which is great for learning the basics. It simply executes individual commands or command blocks, letting you learn things step-by-step.

    I've also written a simpler version of that shell within Construct, using it's native Python support, so you wouldn't even need to install Python to try the interactive examples given in those. It's here if you're so inclined: http://www.scirra.com/forum/viewtopic.php?f=16&t=6158

  • Hi. It is a known bug with reading global variables containing text from python. It's very unpredictable. Sometimes it works, sometimes it doesn't, sometimes it crashes.

    Anyway, I couldn't figure out much of what you were doing or why you had python commands where you did in that stripped down .cap, but I would deal with the global variables normally through construct events whenever possible.

    As for the specific problem in the .cap:

    + layout2control: On Left Clicked on Box
    -> System: Run Script ("func(System.globalvar('Name'), System.globalvar('Score'))")[/code:31g2cxr9]
    
    ... changed to:
    
    [code:31g2cxr9]+ layout2control: On Left Clicked on Box
    -> System: Run Script ("func('" & global('Name') & "', " & global('Score') & ")")[/code:31g2cxr9]
    
    ... fixes the problem on my computer. This just reads the global vars from the construct event and inserts their values into the string which is to be run as a python script. Note that string values must be enclosed in quotes as I did there, and that the string can't contain the type of quote mark used( ' in this case.)
    
    Otherwise, one can usually write a python function that calls a Construct function, which returns the desired result back to the python function, which in turn returns the result... Eh, sounds worse than it is, really.  I'm not sure that would work well in this case, though. Construct has it's own quirky use of ' quotes with global variables that would probably prove difficult.
    
    Also, I noticed that you were assigning strings to global variables which were defined as numbers. I'm not sure if Construct considers the global variables to be dynamically typed, but seems as though it does.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah, so if you replace the expression in your clock display event with the one below, it should work fine.

    global('Hour') & ":" & Right("00" & str(global('Minute')), 2) & " " & global('AMPM')[/code:3p2f39y4]
    
    Anyway, Dropbox seems to work quite fine for me. Just in case you didn't know, make sure you put the file in your 'Public' folder within the Dropbox folder, and after it syncs, use the right-click context menu for [i]Dropbox -> Copy public link[/i], which copies it to the clipboard for pasting wherever.
  • 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*

  • 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.

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