How to increase a Value [SOLVED]

Xilefenko
04 Nov 2016, 17:25

This is probably a dumb question but I want that every time you go trough a certain room a Value should increase by one.
I have ALWAYS problems with that!


Xilefenko
04 Nov 2016, 18:38

If I do it that way:

Kiesweg1.durchlaufen = Kiesweg1.durchlaufen + 1

I get an error:

Error running script: Error compiling expression '+ 1': SyntaxError: Unexpected token "+"; expected one of "NOT", "-", <INTEGER>, <REAL>, <STRING_LITERAL>, "True", "False", <HEX_LITERAL>, <CHAR_LITERAL>, "null", <DATETIME>, <TIMESPAN>, "(", <IDENTIFIER>, "if", or "cast"Line: 1, Column: 1

Niekitty
04 Nov 2016, 22:54

Wow... okay, I'm not a code guru or anything, but just off hand, my first thing to check when I hit an error like that is whether or not I remembered to change the Attribute to an Integer or not. Beyond that, I'd probably have to go digging for a few hours at it, but that is something to look at, maybe?


Xilefenko
05 Nov 2016, 00:15

I've checked and the Attribute is an Integer. It is set to 0


hegemonkhan
05 Nov 2016, 01:02

seemingly from the error message, it's not recognizing the '+' operator (nor the multiplication: * operator, nor the division: / operation, nor the modulus: % operator) as neither an addition operation nor a concatenation operation.

have you been doing direct coding (with your entire game code) ??? if you have... you may just have a typo/syntax mistake in a prior code line, which is also messing up this code line (and misguiding us), possibly...


The Pixie
05 Nov 2016, 08:37

The error message suggests Quest is seeing "+ 1" somewhere on its own or in brackets, and not with the rest of the line. I created an objecte called "Kiesweg1" in a test game, and gave it an integer attribute, "durchlaufen", and the line works fine for me.

As HK says, it may not be this line at fault. Try adding print statements:

msg("before")
Kiesweg1.durchlaufen = Kiesweg1.durchlaufen + 1
msg("after"

If it really is that line, you should see the "before" and then the error message, but not the "after".


Xilefenko
05 Nov 2016, 10:31

OK I've solved it now!
I tried it with the message before and after the attribute
That problem was an old line of code, hidden in the exit that I forgot
But now it is working just fine!
Thanks