Tip - Testing function output instead of attributes
danayel
Member Posts: 25
Sometimes you want to test not an attribute itself, but the value of an attribute compared to another, or added together, or some other complex task.
GS can't currently handle this, because your test is always:
"attribute" + "comparison operator" + "function"
But if you know what the expected output should be, or if it is just a true false function, then what you can do is create a game level attribute called "zero" or "true" or whatever the expected value is, and then put inside it the expected value:
e.g.
game.zero = 0
game.true = true
Then when you do your if comparison, you do this:
game.true = complex + Function * (WhichReturns / True) + (Or * False)
Thus allowing you to compare a complex function to a fixed value when you couldn't normally, by tricking the system with a dummy attribute containing your expected result.
In my game for example, I have:
game.zero = floor(( game.pos4 pieces %(10^ game.Temp Piece ))/((10^ game.Temp Piece )/10))
Which reads a single digit out of an integer (in this case the 10s digit) and says whether it is 0 or not.
12304 = true (10s digit = 0)
12345 = false (10s digit != 0)
e.g.
GS can't currently handle this, because your test is always:
"attribute" + "comparison operator" + "function"
But if you know what the expected output should be, or if it is just a true false function, then what you can do is create a game level attribute called "zero" or "true" or whatever the expected value is, and then put inside it the expected value:
e.g.
game.zero = 0
game.true = true
Then when you do your if comparison, you do this:
game.true = complex + Function * (WhichReturns / True) + (Or * False)
Thus allowing you to compare a complex function to a fixed value when you couldn't normally, by tricking the system with a dummy attribute containing your expected result.
In my game for example, I have:
game.zero = floor(( game.pos4 pieces %(10^ game.Temp Piece ))/((10^ game.Temp Piece )/10))
Which reads a single digit out of an integer (in this case the 10s digit) and says whether it is 0 or not.
12304 = true (10s digit = 0)
12345 = false (10s digit != 0)
e.g.
Comments
would this not be the same as simply putting a "display text" behavior in the actor and then assign the text value to an attribute or an expression.
Also...you could constrain whatever value you want to report to the screen to a game.attribute and then have a "blankWorkingActor" display text of that temporary game attribute...so you can see the value on screen as you test.
Or did I miss something in the tip's intent.
But I want to test the result of a function, and not test a pure attribute. Currently GS doesn't allow a function to be compared to result (except doing it backwards like this)
In my situation, I wanted to check if 1 particular digit out of an attribute was equal to 0. But not check the entire attribute contents.
You could use it to check the first 4 characters of an attribute, or check if several attributes connected together equal a particular amount.