attribute different to
Deckrect
29 Nov 2016, 12:40Hello, people. A dumb question. I use GUI most of the time, and i know how creating a condition of "If Object has attribute equals to". However, i wish creating a condition where things happens "If Object has attribute different to". How may i express 'different'? "<>"?
XanMag
29 Nov 2016, 18:39You should be able to use it as an If, then else statement.
If the attribute is equal to 2, then print message, do this, do that...
Else If equal to 3 do this, do that...
Else if equal to 4 do this, do that...
Else (this is your "different") do this, do that...
Let me know if that makes sense!
The Pixie
29 Nov 2016, 20:00Yes, "<>".
Deckrect
29 Nov 2016, 20:47Thanks, guys!
I may switch to code in order to alter the symbol Pixie hinted. But it is also interesting i did never think the other way around, as XanMag suggested. Of course, the good about using the "<>" is i need only one IF statement!
hegemonkhan
29 Nov 2016, 20:52also:
if [EXPRESSION] not YOUR_EXPRESSION
for examples:
// Attribute scripting as your Expressions:
if [EXPRESSION] not player.alias = "HK"
if EXPRESSION] not player.strength_integer_attribute > 66
if [EXPRESSION] not player.strength_integer_attribute = 100
if [EXPRESSION] not player.flying_boolean_attribute
etc etc etc
// Functions as your Expressions:
if [EXPRESSION] not Got (ball)
if [EXPRESSION] not HasInt (player, "strength_integer_attribte")
etc etc etc
using Pixie's mentioned alternative command/symbol/operation for not: '<>', examples:
if [EXPRESSION] player.alias <> "HK"
if [EXPRESSION] not player.strength_integer_attribute <> 100
if [EXPRESSION] player.flying_boolean_attribute <> true
Negation (Not / Not Equals):
not xxx // Boolean Attributes only (I think)
or
not xxx = xxx
or:
xxx <> xxx
Deckrect
29 Nov 2016, 21:01I am curious about this example, HK: "if [EXPRESSION] not Got (ball)"
What does it do?
hegemonkhan
30 Nov 2016, 03:29the '[EXPRESSION]' option in the GUI/Editor's scripting allows for you to type in the code/action/operation you want, though it's syntax is a bit different in some cases from the syntax of doing direct coding (in-code), which causes some frustration for people.
It's my way to 'cheat' to be able to help people through doing something in the GUI/Editor, as I don't know its script options that well.
as for the 'Got' Script/Function:
http://docs.textadventures.co.uk/quest/functions/corelibrary/got.html
http://docs.textadventures.co.uk/quest/functions/index_allfunctions.html (scroll down to the 'Got' Function)
also my 'ball' would have to be an actual existing (or still existing) Object in the game:
<object name="ball">
</object>
if not, then you get an error.
(and if you use the 'not' operator: not Got (ball), then it's checking for effectively if you do NOT have a 'ball' Object in your inventory, as opposed to checking if you DO have a 'ball' Object in your inventory)
if you do have a 'ball' Object, the 'Got' Script/Function checks the 'game.pov' (the currently controlled Player Object if you have multiple Player Objects, or just your single Player Object, such as the default 'player' Player Object) Player Object, to see if it contains that Object (the 'ball' Object): TRUE, or not: FALSE
it's a shortcut Script/Function for iterating (via 'foreach' Script/Function) through the 'ScopeInventory' Objectlist Attribute (of specifically the 'game.pov' / currently controlled Player Object) for a 'ball' item / the 'ball' Object:
http://docs.textadventures.co.uk/quest/functions/corelibrary/scopeinventory.html
http://docs.textadventures.co.uk/quest/scopes.html (same as the below link, conveniently separated out as its own page)
http://docs.textadventures.co.uk/quest/functions/index_allfunctions.html (scroll down to the 'ScopeXXX' Functions)
also, you can achieve the same thing this way too, using the 'Contains' Script/Function:
http://docs.textadventures.co.uk/quest/functions/contains.html
if (Contains (player, ball)) {
and, you can also do this too:
http://docs.textadventures.co.uk/quest/functions/listcontains.html
if (ListContains (ScopeInventory(), ball)) {
hegemonkhan
30 Nov 2016, 03:47example of what the 'Got' Function probably does (in its underneath coding) for you:
if (Got (ball)) { /* scripts */ }
is the same as doing:
if (my_got_function (ball)) { /* scripts */ }
<function name="my_got_function" parameters="object_parameter" type="boolean">
boolean_variable = false
foreach (object_variable, ScopeInventory()) {
if (object_variable = object_parameter) {
boolean_variable = true
}
}
return (boolean_variable)
</function>
(quest could really use, loops-iterations and scripting, interrupts and terminators, if it's possible... to do so)
The Pixie
30 Nov 2016, 08:14The actual script for the Got
function is:
return (ListContains(ScopeInventory(), obj))
hegemonkhan
30 Nov 2016, 09:01hmm... is the 'ListContains' doing an iteration operation/scripting to find/check if item is in the list, or is it able to completely bypass doing an iteration method, possibly from how quest is underlyingly coded (via its OOP design) ???
Someday, I'm going to dive into quest's coding, and get familiarized with it... so busy with school work, sighs.
The Pixie
30 Nov 2016, 09:24There is a function to do that in C#, called Contains
, and I guess it uses that. That well be written in C or even machine code for speed, given how often it will get used, so may not be OOP coded ultimately. At whatever level it does the actual work, it will iterate thrpugh the list as you have, I assume, though it is likely to jump out of the loop when it finds a match (which you could have done with a return(true)
)
Deckrect
30 Nov 2016, 19:38Oh, got it. It is the GUI's "If Object had Object".