How do I correctly use an OR block?

Not favoritedFavorited Favorited 0 favourites
  • 7 posts
From the Asset Store
Place blocks on a board, join them together to form even bigger blocks!
  • Just when I think I'm finally starting to understand this program... <sigh>

    Why doesn't this work:

    In global values I set versionType = "Testing"

    LayoutName = "lay05_coreGame"

    Seems simple, but when I run this code str_test is always an empty string ""

    Possibly relevant:

    - the layout is lay5_coreGame which uses sht5_coreGame.

    - sht5_coreGame includes sht00_globalLogic

    - the code above is in sht00_globalLogic

  • Well, it's not an issue with the OR block or "On start of layout". I just tried this:

    When I launch my layout and look at the debugger I see:

    versionType = "Testing"

    str_Test = "Testing"

    So I verify that versionType = "Testing" and then immediately test if versionType = "Testing" and it fails. (If it had succeeded str_test would be "OK")

    If I delete "versionType = 'Testing'" it succeeds. Why can't I check the value of this global string? I'm SO confused.

    UPDATE: I just added a new global variable called verNum and set it to 1. Then I changed my condition to:

    verNum = 1

    This works! Why doesn't the string work?

  • Did you put the string "Testing" with quotation marks in the variable definition? Remove them.

  • dop2000

    SERIOUSLY??? You define the value of a global string by NOT including quotation marks??? I spent HOURS working on this yesterday. Good grief...

    I've been using Construct 3 for years, how did I not run into this before? I guess I have mostly used global numbers. Argh

    I thought I was taking crazy pills last night. I simplified it down to 3 events:

    Set global string to "Testing"

    1. Confirm global string --> "Testing"

    2. If global string = "Testing" --> FAIL!

    WTH??????

  • Haha, yeah, I still forget about this sometimes and instinctively wrap string variables in quotation marks. Sometimes I wish C3 was stricter about this, more like traditional programming languages.

    On the other hand, this lets you store entire JSON strings in variables without needing to escape every quotation mark.

    For example:

    Text variable myJSON = {"name":"John", "age":30, "car":0}

    Instead of:

    Text variable myJSON = "{"""name""":"""John", """age""":30, """car""":0}"

  • On the other hand, this lets you store entire JSON strings in variables without needing to escape every quotation mark.

    For example:

    Text variable myJSON = {"name":"John", "age":30, "car":0}

    Instead of:

    Text variable myJSON = "{"""name""":"""John", """age""":30, """car""":0}"

    Thought I'd try this. Figured out that you can use the first version when declaring a variable, but can't use it in expressions or when using System -> Set Value.

    So sure it's that useful? Doesn't appear to be a substitute for the JSON plugin.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So sure it's that useful? Doesn't appear to be a substitute for the JSON plugin.

    It's not a substitute. This allows to store short JSONs directly in the code, without having to load them from files with AJAX. I'm using this trick all the time.

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