local variable problems

  • hey there i'm having trouble with my local variables, they used to be global variables but that screwed my game over when it came to the Hard level as all my text boxes where just said text, anyway back to the point what i dont understand is when i enter the text as shown here <img src="http://i1114.photobucket.com/albums/k525/Cameron_Watson/ScreenShot004_zpsa218fcc1.jpg" border="0" /> that error message comes up and i cant make heads or tales of it, that is all i need to figure out how to fix then my games is finally done. also here is a dropbox link to the game in case you want to have a root around dropbox.com/s/50i46mty1wolkca/maze.capx

    Thanks in advance for all your help :)

  • Sorry I won't download a 18 Mo capx, but the error message is pretty self explaining.

    ScoreHard is an object type, not a variable.

    So it needs some more properties to be used, or possibly an instance variable name.

    Something like ScoreHard.myScore, or whatever the name of your variable is.

    Check in the list on the right, the project objects tab, you should find this object there.

  • ah ok i will try that and let you know how i get along :) did not know the file was that big i will have to compress it :)

  • agreed check to see if your using an object and not a variable. However if it is a variable make sure it's in the same scope.

    Which could be a global which is freely open and if it's a group make sure your reference is in the same grouping. I've done this a couple of times where I try to use a var which is in a different group :D

  • hate to be a pain but what you said makes no sense to me.

  • still having trouble :( anyone got any ideas?

  • Where you have you reference

    "Score: " &

    The next part needs to link to where the variable data is stored.

    ObjectsName.VariableName

    Your box should now look like this

    "Score: " & ObjectsName.VariableName

    The error should now be resolved if all the data is correct.

  • Interesting... how did you do that? You have 3 local number variables, but they do not appear to be tied to anything. Can you perhaps try generating Global Variables instead, and using them in the expression? Just right click in the event editor and click on add global variable.

    Do you know how you made those local variables? I can add more to your event editor, but cannot add a new one from scratch.

  • Do you know how you made those local variables? I can add more to your event editor, but cannot add a new one from scratch.

    Local variables are made inside events, if you create variable inside an event that is triggered it automagically becomes local variable.

  • i was using local variables because my games has 2 levels normal and hard and for some reason one blocks the other out so the text boxes just come up saying text instead of showing you your health score and time, i find construct rather confusing so if i come back saying i don't have a clue what you said then don't be offended :)

  • i know the file is to big so if you don't want to destroy your broadband just ask for a screenshot of what ever you need :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Your "ScoreHard" is a local variable to the group "Hard".

    It means that because of the scope ("range") of local variable it can only be accessed from and only from within this group (to be displayed/modified).

    <img src="https://dl.dropbox.com/u/36472942/construct/forumhelp/LocalVariableScope.PNG" border="0">

    This code should work.

    I haven't tested it, your coding is far too much spread imo, you're using too much useless groups and too many event sheets (C2 isn't C++, try to keep your code organized in another way).

    Consult this manual entry as well as this and that thread (listed in the How do I FAQ).

  • I will give that a shot if what i'm doing does not work thanks for the help guys! :)

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