I wasn't sure myself if the " ToInt " could convert the textual string VALUE of "three" into the numerical " 3 ", so Jaynebonne already beat me to it.
now that I know myself, thanks to Jaynebonne's post, let me just echo what he said:
unfortunately, the converting command functions (or whatever they're actually called, meh), such as the " ToInt ", only convert the TYPE of the attribute, NOT the abc~word characters VALUE itself (like "three") of a string attribute into a numerical VALUE (like "3").
if (STRING type attribute = INTEGER type attribute) { script } -> error, as a STRING is not an INTEGER
if (STRING type attribute = STRING type attribute) { script } -> no error
if (INTEGER type attribute = INTEGER type attribute) { script } -> no error
if (ToInt (STRING type attribute = INTEGER type attribute)) { script } -> no error
if (INTEGER type attribute = INTEGER type attribute) { script } -> no error
An Attribute creation and its own attributes:
Name:
Type:
Value:
some examples:
Name: strength
Type: int (integer)
Value: 50
Name: attack
Type: script (making a verb; or a command though its not via an attribute creation)
Value: (your direct script block or a call function to a function's script block, I don't want to write out a script block for attack)
Name: health_status
Type: string
Value: wounded
Name: physical_damage
Type: double
Value: 0.0
Name: dead
Type: boolean
Value: false
-------
the problem lies in~with the scripting, often when you use an attribute, the script (such as the "if (object.attribute = ...) " returns it as a string type, while on the other side of the equals is an integer type or return integer type, so often you need to add the " ToInt " to get the left side of the equals into an INTEGER type too.
also, the problem lies in that:
the character value of a numeric, such as "0" or "100", (is ~ can be) both a string and an integer, so quest needs to know whether, that "5" VALUE is the STRING TYPE or the INTEGER TYPE, as it needs to know this, as that's how its logic works, by comparing an attribute type to another attribute type, if they're not the same type such as when they're suppose to be, like in the case with an equal sign, then quest is unable to do it, displaying an error, as to its logic, STRING ("Y") TYPE NOT EQUAL TO INT ("X") TYPE, when you specified for it that it needs to be "X" TYPE = "X" TYPE or "Y" TYPE = "Y" TYPE.
quest's engine's logic basically works like this:
your scripting:
if (object_1.attribute = object_2.attribute) {
do_this_script_1
} else {
do_this_script_2
}
quest then checks your scripting like this (it automatically does the additional check of the attributes' TYPES for you):
if (object_1.attribute.type = X and object_2.attribute.type = X) {
if (object_2.attribute.value = Y and object_2.attribute.value = Y) {
(then, do_this_script_1)
} else {
(then, do_this_script_2)
}
} else {
ERROR, ~ "quest doesn't recognize function: expression type STRING_32 and expression type INT_32"
}
so, this is why you may have to manually add in the "converters" (such as ToInt), to your own script, to get quest to be able to pass its own automatic check of the TYPES of your attributes.
----------------------------------
Attributes
Name: strength
Type: string (sorry for doing this as my stupid example, as I don't know of nor can find an actual example of where you need to plug in the ToInt, grr)
Value: 100
Name: endurance
Type: int
Value: 100
so, basically:
if (HK.strength = 99) { HK.physical_damage=49.5 } -> NO error, as quest can recognize the " 100 " as an INT type to make up with the " strength " INTEGER type's value (ie the characters: "100")
however, if you got:
if (HK.strength = orc.endurance) { msg ("HK does zero damage to the orc") } -> error, as STRING TYPE is not equal to INTEGER TYPE (as can be seen, quest doesn't care that both of the VALUES are numerical)
if (ToInt (HK.strength) = orc.endurance) { msg ("HK does zero damage to the orc") } -> no error