[SOLVED}Variable display issues.

Hello again, currently I am trying to to display variables in the status menu, like so:
set (Bobby, "test", 30)

set (, "statusattributes", NewStringDictionary())

dictionary add (Bobby.statusattributes, "test", Test: 30)

Now in the past this would have worked, yet for some unknown reason it's not. Now variables that I had set up prior before this issue work fine and are still working fine even with the variable manipulation. Thankfully the variables still can used to influence the game, it's just my usual way to display them is not working. Is anyone else having the same problem?


I assume that you mean:

set (Bobby, "test", 30)
set (Bobby, "statusattributes", NewStringDictionary())
dictionary add (Bobby.statusattributes, "test", "Test: !")

and that Bobby is the name of the object the player is currently controlling?

In your code, you had the object name missing from the set line, and the quotes missing from the dictionary add line. You were also adding the string "Test: 30", meaning that the status attributes pane will always display 30 even if the value of test changes. You should use a ! in the statusattributes dictionary, so that the display will change automatically when the attribute does.


I tried that, sorry of the poor code before (it was late and I wanted to at least get it out) yet it's still not displaying anything. I also notice unless I have something like Score or Health turned on the Status Window is nonexistent. I am very confused right now.

Edit: In case it was just a fluke I went ahead and created a new game to test (using the same code above yet now updated), yet still no Status Window at all unless I have the attributes in game being used.

Edit 2: I have just used a variable that worked in a prior game (in that game it's able to display the status window and attribute) and copied the code exactly and placed it into the test game, however it yielded the same result as Bobby.


Can you show one of the games that exhibits this issue?

When are you running this code? Are you sure that it's actually getting to that point?

The code in your first post would have caused an immediate error. As you didn't mention an error message, this makes me think that perhaps the code is never being reached.


I can't remember an error when I first started, the usual one I get is one talking about Syntax (Error running script: Error compiling expression ": SyntaxError: Unexpected end of fileLine: 1, Column: 1). Yet even with this glaring issue my games prior to this issue have displayed variables.
Now if I put in Bobby or Ashley in the set (_____, "statusattributes", NewStringDictionary()) then I get an Error running script: Unrecognized dictionary type.
In both cases my variables are still being used, can do the {player.attribute} and get a current attribute reading while they are still able to influence the game. The only problem is it's not displaying it in real time on the Status Window.

Here's the test game so you can see the issue in real time: https://textadventures.co.uk/games/view/naud8ziexukytqef7dfyta/test-game

I added Score to show that it can still display variables, but only ones from Quest itself.


In your code above, you have a line:

dictionary add (Bobby.statusattributes, "test", "Test: !")

which should work.

In the test game, you have the line:

dictionary add (Bobby.attributes, "test", Test !)

which doesn't.

statusattributes is a special attribute that the game looks for on the player object. If you use any other name, the game doesn't check for it, and doesn't do anything special with it.

The error Error running script: Unrecognized dictionary type means that you are trying to use dictionary add or dictionary remove and the first parameter is not a dictionary.

In this case, you are creating a dictionary called Bobby.statusattributes, and then trying to add something to the dictionary Bobby.attributes (which doesn't exist), so the script stops running with an error message.

If you correct attributes to statusattributes, you will get a different error, because you haven't put quotes around Test ! (which I already mentioned)


Oh my god is that why the messages keep coming up!? I'm stupid, thank you for clearing up that problem plaguing me for months now.
Also after I did the changes to the attributes to statusattributes and putting the quotation marks around the Test and Day it actually worked. I'm going to check if I can make this work on my other game, hopefully it works.

Edit: IT WORKS AGAIN! YES! Thank you very much!


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums