Logic Question :) Get and Set [SOLVED]

Anonynn
23 Jul 2016, 22:39Alright, so maybe it's because I'm too wrapped up in this because I'm been staring at it for a few hours but I have a logic question that I'm having trouble getting around. I have these Functions:
GetRelationship
SetRelationship
My question is that instead of applying these to the player, I need to apply them to all the NPC's in the game, except the player. Would a "type" work? Like, for example...
type
NPC
That way I can do (if charactername.relationship="blahblah") {
}
and
charactername.relationshipscale = charactername.relationshipscal + 10
Or is there something easier? Anyone have any ideas?
Here are the codes.
return ("hostile")
}
if (player.relationshipscale = 1) {
return ("hated")
}
if (player.relationshipscale = 2) {
return ("hated")
}
if (player.relationshipscale = 3) {
return ("hated")
}
if (player.relationshipscale = 4) {
return ("hated")
}
if (player.relationshipscale = 5) {
return ("hated")
}
if (player.relationshipscale = 6) {
return ("hated")
}
if (player.relationshipscale = 7) {
return ("hated")
}
if (player.relationshipscale = 8) {
return ("hated")
}
if (player.relationshipscale = 9) {
return ("hated")
}
if (player.relationshipscale = 10) {
return ("hated")
}
if (player.relationshipscale = 11) {
return ("stranger")
}
if (player.relationshipscale = 12) {
return ("stranger")
}
if (player.relationshipscale = 13) {
return ("stranger")
}
if (player.relationshipscale = 14) {
return ("stranger")
}
if (player.relationshipscale = 15) {
return ("stranger")
}
if (player.relationshipscale = 16) {
return ("stranger")
}
if (player.relationshipscale = 17) {
return ("stranger")
}
if (player.relationshipscale = 18) {
return ("stranger")
}
if (player.relationshipscale = 19) {
return ("stranger")
}
if (player.relationshipscale = 20) {
return ("stranger")
}
if (player.relationshipscale = 21) {
return ("stranger")
}
if (player.relationshipscale = 22) {
return ("stranger")
}
if (player.relationshipscale = 23) {
return ("stranger")
}
if (player.relationshipscale = 24) {
return ("stranger")
}
if (player.relationshipscale = 25) {
return ("stranger")
}
if (player.relationshipscale = 26) {
return ("stranger")
}
if (player.relationshipscale = 27) {
return ("stranger")
}
if (player.relationshipscale = 28) {
return ("stranger")
}
if (player.relationshipscale = 29) {
return ("stranger")
}
if (player.relationshipscale = 30) {
return ("stranger")
}
if (player.relationshipscale = 31) {
return ("stranger")
}
if (player.relationshipscale = 32) {
return ("stranger")
}
if (player.relationshipscale = 33) {
return ("stranger")
}
if (player.relationshipscale = 34) {
return ("stranger")
}
if (player.relationshipscale = 35) {
return ("stranger")
}
if (player.relationshipscale = 36) {
return ("stranger")
}
if (player.relationshipscale = 37) {
return ("stranger")
}
if (player.relationshipscale = 38) {
return ("stranger")
}
if (player.relationshipscale = 39) {
return ("stranger")
}
if (player.relationshipscale = 40) {
return ("acq")
}
if (player.relationshipscale = 41) {
return ("acq")
}
if (player.relationshipscale = 42) {
return ("acq")
}
if (player.relationshipscale = 43) {
return ("acq")
}
if (player.relationshipscale = 44) {
return ("acq")
}
if (player.relationshipscale = 45) {
return ("acq")
}
if (player.relationshipscale = 46) {
return ("acq")
}
if (player.relationshipscale = 47) {
return ("acq")
}
if (player.relationshipscale = 48) {
return ("acq")
}
if (player.relationshipscale = 49) {
return ("acq")
}
if (player.relationshipscale = 50) {
return ("acq")
}
if (player.relationshipscale = 51) {
return ("acq")
}
if (player.relationshipscale = 52) {
return ("acq")
}
if (player.relationshipscale = 53) {
return ("acq")
}
if (player.relationshipscale = 54) {
return ("acq")
}
if (player.relationshipscale = 55) {
return ("acq")
}
if (player.relationshipscale = 56) {
return ("acq")
}
if (player.relationshipscale = 57) {
return ("acq")
}
if (player.relationshipscale = 58) {
return ("acq")
}
if (player.relationshipscale = 59) {
return ("acq")
}
if (player.relationshipscale = 60) {
return ("friend")
}
if (player.relationshipscale = 61) {
return ("friend")
}
if (player.relationshipscale = 62) {
return ("friend")
}
if (player.relationshipscale = 63) {
return ("friend")
}
if (player.relationshipscale = 64) {
return ("friend")
}
if (player.relationshipscale = 65) {
return ("friend")
}
if (player.relationshipscale = 66) {
return ("friend")
}
if (player.relationshipscale = 67) {
return ("friend")
}
if (player.relationshipscale = 68) {
return ("friend")
}
if (player.relationshipscale = 69) {
return ("friend")
}
if (player.relationshipscale = 70) {
return ("friend")
}
if (player.relationshipscale = 71) {
return ("friend")
}
if (player.relationshipscale = 72) {
return ("friend")
}
if (player.relationshipscale = 73) {
return ("friend")
}
if (player.relationshipscale = 74) {
return ("friend")
}
if (player.relationshipscale = 75) {
return ("friend")
}
if (player.relationshipscale = 76) {
return ("friend")
}
if (player.relationshipscale = 77) {
return ("friend")
}
if (player.relationshipscale = 78) {
return ("friend")
}
if (player.relationshipscale = 79) {
return ("friend")
}
if (player.relationshipscale = 80) {
return ("fwb")
}
if (player.relationshipscale = 81) {
return ("fwb")
}
if (player.relationshipscale = 82) {
return ("fwb")
}
if (player.relationshipscale = 83) {
return ("fwb")
}
if (player.relationshipscale = 84) {
return ("fwb")
}
if (player.relationshipscale = 85) {
return ("fwb")
}
if (player.relationshipscale = 86) {
return ("fwb")
}
if (player.relationshipscale = 87) {
return ("fwb")
}
if (player.relationshipscale = 88) {
return ("fwb")
}
if (player.relationshipscale = 89) {
return ("fwb")
}
if (player.relationshipscale = 90) {
return ("fwb")
}
if (player.relationshipscale = 91) {
return ("fwb")
}
if (player.relationshipscale = 92) {
return ("fwb")
}
if (player.relationshipscale = 93) {
return ("fwb")
}
if (player.relationshipscale = 94) {
return ("fwb")
}
if (player.relationshipscale = 95) {
return ("fwb")
}
if (player.relationshipscale = 96) {
return ("fwb")
}
if (player.relationshipscale = 97) {
return ("fwb")
}
if (player.relationshipscale = 98) {
return ("fwb")
}
if (player.relationshipscale = 99) {
return ("fwb")
}
if (player.relationshipscale = 100) {
return ("lover")
}
if (player.relationshipscale = 101) {
return ("lover")
}
if (player.relationshipscale = 102) {
return ("lover")
}
if (player.relationshipscale = 103) {
return ("lover")
}
if (player.relationshipscale = 104) {
return ("lover")
}
if (player.relationshipscale = 105) {
return ("lover")
}
if (player.relationshipscale = 106) {
return ("lover")
}
if (player.relationshipscale = 107) {
return ("lover")
}
if (player.relationshipscale = 108) {
return ("lover")
}
if (player.relationshipscale = 109) {
return ("lover")
}
if (player.relationshipscale = 110) {
return ("lover")
}
if (player.relationshipscale = 111) {
return ("lover")
}
if (player.relationshipscale = 112) {
return ("lover")
}
if (player.relationshipscale = 113) {
return ("lover")
}
if (player.relationshipscale = 114) {
return ("lover")
}
if (player.relationshipscale = 115) {
return ("lover")
}
if (player.relationshipscale = 116) {
return ("lover")
}
if (player.relationshipscale = 117) {
return ("lover")
}
if (player.relationshipscale = 118) {
return ("lover")
}
if (player.relationshipscale = 119) {
return ("lover")
}
if (player.relationshipscale = 120) {
return ("spouse")
}```
and...
```player.relationshipscale = GetRelationship()```
bergedorfcacher
24 Jul 2016, 06:19You can shorten your code a lot by doing this:
if (player.relationshipscale > 0 and player.relationshipscale < 11) {
return ("hated")
...
hegemonkhan
24 Jul 2016, 08:33there's countless ways of implementing/doing what you want...
HK edit: err... I really need to read posts fully... laughs... ignore this section, look further below (the part with the much larger code / code box, lol) about for your specific setup needs
probably one of the simpliest ways is to check if the Object is (for this example) the currently controlled Player Object (game.pov), for example:
// using a Command just for example quickness:
<command name="set_attribute_on_all_objects_except_pov_command">
<pattern>set all value #text1# on attribute #text2#</pattern> // sorry for the very long pattern, I just wanted it to be descriptive so you can understand it, a better (shortened) version of it for actual use (lol): setall #text1# #text2#
<script>
foreach (object_variable, AllObjects()) {
if (not object_variable = game.pov) {
set (object_variable, text2, ToInt (text1)) // or: set (object_variable, text2, ToDouble (text1))
// or: set (object_variable, text2, GetAttribute (object_variable, text2) OPERATOR '(ToInt/ToDouble)' (text1)) // the text1 is your value input (that will be added/subtracted/multiplied/divded/modulus'ed to the Attribute), such as for example: 10, and replace my 'OPERATOR' with your math operation symbol (+, -, *, /, %, ?etc?), an example: set (object_variable, text2, GetAttribute (object_variable, text2) + 10) // you're adding 10 to the Attribute (if the Attribute's value was 0, now it will become 10: 0 + 10 = 10. if the Attribute's value was 17, now it will become 27: 17 + 10 = 27)
}
}
</script>
</command>
this can be of course changed up a bit and/or expanded upon, as you can use another check upon an Attribute that you give to all of your Objects, to flag/indicate what type of Object they are, to narrow down to a specific group of Objects if you need to do so (for example: you don't want to give a 'life/strength/endurance/experience/etc' Attribute to a non-actor/non-character Object, such as a 'tree/cloud/bed/desk/etc' Object or a 'castle' Room Object, obviously).
as for what you specifically want with what you've provided (and if I understand it correctly, laughs):
(I went a bit overboard, well for me anyways, lol ... if my code is relatively error free, then it's capable of being expanded to handling many various setups: you'll be able to use this Function for almost anything/everything you want for handling like-stuff design/needs of your post's topic)
// "various things" for showcasing this example:
// the range (for my 'relationship_integer_attribute', which is equivalent to your: 'relationshipscale'), due to how I have this example set up, has to be within: 0 to 100, and also, as I haven't included the needed code to handle if it's less than 0 or greater than 100
<object name="player">
<attr name="type_string_attribute" type="string">pc</attr>
<attr name="relationship_integer_attribute" type="int">100</attr>
<attr name="relationship_string_attribute" type="string">irresistable</attr>
</object>
<object name="npc1">
<attr name="type_string_attribute" type="string">npc</attr>
<attr name="relationship_integer_attribute" type="int">5</attr>
</object>
<object name="npc2">
<attr name="type_string_attribute" type="string">npc</attr>
<attr name="relationship_integer_attribute" type="int">15</attr>
</object>
<object name="npc3">
<attr name="type_string_attribute" type="string">npc</attr>
<attr name="relationship_integer_attribute" type="int">25</attr>
</object>
<object name="npc4">
<attr name="type_string_attribute" type="string">npc</attr>
<attr name="relationship_integer_attribute" type="int">35</attr>
</object>
<object name="npc5">
<attr name="type_string_attribute" type="string">npc</attr>
<attr name="relationship_integer_attribute" type="int">45</attr>
</object>
<object name="npc6">
<attr name="type_string_attribute" type="string">npc</attr>
<attr name="relationship_integer_attribute" type="int">55</attr>
</object>
<object name="npc7">
<attr name="type_string_attribute" type="string">npc</attr>
<attr name="relationship_integer_attribute" type="int">65</attr>
</object>
<object name="npc8">
<attr name="type_string_attribute" type="string">npc</attr>
<attr name="relationship_integer_attribute" type="int">75</attr>
</object>
<object name="npc9">
<attr name="type_string_attribute" type="string">npc</attr>
<attr name="relationship_integer_attribute" type="int">85</attr>
</object>
<object name="npc10">
<attr name="type_string_attribute" type="string">npc</attr>
<attr name="relationship_integer_attribute" type="int">95</attr>
</object>
<object name="npc11">
<attr name="type_string_attribute" type="string">npc</attr>
<attr name="relationship_integer_attribute" type="int">100</attr>
</object>
// these have to have a constant/static interval/multiple (in this case, I'm using 'by 10s', and since the range is 0 to 100, that's why these values are from: 0 to 10, as when you divide a number in the range of 0 to 100 by 10, you'll get numbers from 0 to 10: int division in quest, and in probably most programming languages too, truncates/deletes the decimal/fraction amount), and so you must specific (10) for the Function Call's 'interval_parameter' Argument (see the 'scripting example' section):
// (strings can't start with a number character/symbol, that's why I have/need my 'item' in front of the number value/character/symbol)
<object name="global_data_object">
<attr name="relationship_integer_to_relationship_string_stringdictionary_attribute" type="simplestringdictionary">item0 = "bitter enemies"; item1 = "enemies"; item2 = "bitter rivals"; item3 = "rivals"; item4 = "dislike"; item5 = "neutral"; item6 = "like"; item7 = "friends"; item8 = "affectionate"; item9 = "lovers"; item10 = "soul mates"</attr>
</object>
// scripting example:
dynamic_conversion_multi_set_function ("npc", "type_string_attribute", "relationship_integer_attribute", "relationship_string_attribute", global_data_object, "relationship_integer_to_relationship_string_stringdictionary_attribute", 10)
// the Function (not complete... maybe, Pixie/Jay/Pertex/whoever else good at programming, can help fix and/or finish it up):
<function name="dynamic_conversion_multi_set_function" parameters="type_attr_value_param, type_attr_param, input_attr_param, output_attr_param, dict_obj_param, dict_attr_param, interval_param">
foreach (obj_var, AllObjects()) {
if (GetAttribute (obj_var, type_attr_param) = type_attr_value_param and HasAttribute (obj_var, input_attr_param)) {
if (IsInt (GetAttribute (obj_var, input_attr_param)) and TypeOf (interval_param) = "int") {
str_input_var = "item"
str_input_var = str_input_var + ToString (GetAttribute (obj_var, input_attr_param) / interval_param)
if (DictionaryContains (GetAttribute (dict_obj_param, dict_attr_param), str_input_var)) {
set (obj_var, output_attr_param, DictionaryItem (GetAttribute (dict_obj_param, dict_attr_param), str_input_var))
}
}
}
}
</function>
// if my code is error free (haha), and if put into a testable game for it, then it should (the chance of it working correctly is: 1%) produce these results:
npc1.relationship_string_attribute = "bitter enemies" // (5/10 = 0)
npc2.relationship_string_attribute = "enemies" // (15/10 = 1)
npc3.relationship_string_attribute = "bitter rivals" // (25/10 = 2)
npc4.relationship_string_attribute = "rivals" // (35/10 = 3)
npc5.relationship_string_attribute = "dislike" // (45/10 = 4)
npc6.relationship_string_attribute = "neutral" // (55/10 = 5)
npc7.relationship_string_attribute = "like" // (65/10 = 6)
npc8.relationship_string_attribute = "friends" // (75/10 = 7)
npc9.relationship_string_attribute = "affectionate" // (85/10 = 8)
npc10.relationship_string_attribute = "lovers" // (95/10 = 9)
npc11.relationship_string_attribute = "soul mates" // (100/10 = 10)
// and also this should remain unchanged, as:
player.relationship_string_attribute = "irresistable" // <---- no relationship (haha, pun/funny made) between these ----> (player.relationship_string_attribute = 100)
as if you got any questions about any of this, ASK AWAY!, as even if you really examine my code, it can still be very UN-intuitive for other people, in their efforts of understanding it (as others are not me and my thought process in the code's crafting/design/methodolgy, lol).

Anonynn
24 Jul 2016, 17:17You can shorten your code a lot by doing this:
if (player.relationshipscale > 0 and player.relationshipscale < 11) {
return ("hated")
Thanks! For the suggestion. I may have to use that when I fix everything up.
So I added the object type "npc". But what is the expression for applying it to the If Code?
Something like ... if (npc.type="stranger") {
}
?
bergedorfcacher
24 Jul 2016, 17:25Types work like this:
a) You define a type and define attributes with default values for it.
b) you assign the type to the appropriate object
So for example you can have an npc type with the attribute relationshipscale (integer wit default 0). If you have a character named Joe, assign the npc tpe to it. From now on you can use Joe.relationshipscale, for example
Joe.relationshipscale = Joe.relationshipscale + 10
or
if (Joe.relationshipscale > 50) ...
That's all the magic there is with types afaik.

Anonynn
24 Jul 2016, 19:06I think I understand how types work. Thanks though, because you reminded me of something I hadn't added to them! I still have a problem, for example...I have:
relationship.string.unknown
relationshipscale.integer.0
But I'm not sure how to set up the "NPC" type to apply to all NPC's. I tried...
changedrelationship.script.
if (goblinesque woman.relationshipscale = 0) {
return ("hostile")
}
if (goblinesque woman.relationshipscale >=1 and goblinesque woman.relationshipscale <=10) {
return ("hated")
}
if (goblinesque woman.relationshipscale >=11 and goblinesque woman.relationshipscale <=39) {
return ("stranger")
}
if (goblinesque woman.relationshipscale >=40 and goblinesque woman.relationshipscale <=59) {
return ("acq")
}
if (goblinesque woman.relationshipscale >=60 and goblinesque woman.relationshipscale <=79) {
return ("friend")
}
if (goblinesque woman.relationshipscale >=80 and goblinesque woman.relationshipscale <=99) {
return ("fwb")
}
if (goblinesque woman.relationshipscale >=100 and goblinesque woman.relationshipscale <=119) {
return ("lover")
}
if (goblinesque woman.relationshipscale = 120) {
return ("spouse")
}
But I realized that doing that will only apply to that one NPC. That's why I need to figure out how to apply that script to all NPC types.
hegemonkhan
24 Jul 2016, 19:13"So I added the object type "npc". But what is the expression for applying it to the If Code? (Anonynn)"
you can create/add it as whatever Attribute Type you want as your 'flag/indicator' Attribute, which then thus determines what type its Value/syntax needs to be, for examples:
(you may not want to use 'type' as the name/label, as 'type' is used for so much stuff/everything... lol. If you want to use 'type' in your names/labels, make it unique, to ensure you're not over-riding any of the built-in code that may use 'type' for its stuffs' names/labels)
various 'flag/indicator' Attributes:
String Attribute:
// 'creation' tag syntax: <attr name="type" type="string">npc</attr>
// scripting syntax 1: if (OBJECT_NAME.type = "npc") { /* scripting */ } // or the negation/opposite: if (not OBJECT_NAME.type = "npc") { /* scripting */ }
// scripting syntax 2: if (GetString (OBJECT_NAME, "type") = "npc") { /* scripting */ } // or the negation/opposite: if (not GetString (OBJECT_NAME, "type") = "npc") { /* scripting */ }
// scripting syntax 3: if (GetAttribute (OBJECT_NAME, "type") = "npc") { /* scripting */ } // or the negation/opposite: if (not GetAttribute (OBJECT_NAME, "type") = "npc") { /* scripting */ }
Boolean Attribute:
// 'creation' tag syntax: <attr name="type" type="boolean">true</attr> // or the negation/opposite: <attr name="type" type="boolean">false</attr>
// scripting syntax 1 (if TRUE): if (OBJECT_NAME.type) { /* scripting */ } // or the negation/opposite (if FALSE): if (not OBJECT_NAME.type) { /* scripting */ }
// scripting syntax 2 (IF TRUE): if (GetBoolean (OBJECT_NAME, "type")) { /* scripting */ } // or the negation/opposite (if FALSE): if (not GetBoolean (OBJECT_NAME, "type")) { /* scripting */ }
// scripting syntax 3 (if TRUE): if (GetAttribute (OBJECT_NAME, "type")) { /* scripting */ } // or the negation/opposite (if FALSE): if (not GetAttribute (OBJECT_NAME, "type")) { /* scripting */ }
Integer Attribute:
// 'creation' tag syntax: <attr name="type" type="int">0</attr>
// scripting syntax 1: if (OBJECT_NAME.type = 0) { /* scripting */ } // or the negation/opposite: if (not OBJECT_NAME.type = 0) { /* scripting */ }
// scripting syntax 2: if (GetInt (OBJECT_NAME, "type") = 0) { /* scripting */ } // or the negation/opposite: if (not GetInt (OBJECT_NAME, "type") = 0) { /* scripting */ }
// scripting syntax 3: if (GetAttribute (OBJECT_NAME, "type") = 0) { /* scripting */ } // or the negation/opposite: if (not GetAttribute (OBJECT_NAME, "type") = 0) { /* scripting */ }
Object Attribute:
// required Object (via 'creation' tag syntax for this example): <object name="npc"></object>
// 'creation' tag syntax: <attr name="type" type="object">npc</attr>
// scripting syntax 1: if (OBJECT_NAME.type = npc) { /* scripting */ } // or the negation/opposite: if (not OBJECT_NAME.type = npc) { /* scripting */ }
// scripting syntax 2: if (GetObject (OBJECT_NAME.type) = npc) { /* scripting */ } // or the negation/opposite: if (not GetObject (OBJECT_NAME.type) = npc) { /* scripting */ }
// scripting syntax 3: if (GetAttribute (OBJECT_NAME, "type") = npc) { /* scripting */ } // or the negation/opposite: if (not GetAttribute (OBJECT_NAME, "type") = npc) { /* scripting */ }
Inherited Attribute (Object Types / Types):
// needed Object Type (via 'creation' tag syntax for this example):
<type name="type">
// blah content (Attributes) or null (aka: having no content/Attributes; leave blank)
</type>
<object name="xxx">
<inherit name="type" />
</object>
scripting syntax 1 (if TRUE): if (DoesInherit (xxx, "type")) { /* scripting */ } // or the negation/opposite (if FALSE): if (not DoesInherit (xxx, "type")) { /* scripting */ }
hegemonkhan
24 Jul 2016, 19:24"But I'm not sure how to set up the "NPC" type to apply to all NPC's. I tried... (Anonynn)"
see my "big" post (it starts with: "there's countless ways of implementing/doing what you want") or look below:
you got to use a 'foreach' Script/Function along with the 'AllObjects()' Script/Function:
(for better efficiency, it would be good to put all of your 'npc' Objects into a 'npc' Object List Attribute, as that way you can 'foreach' through it, instead of the 'AllObjects()' Function that uses an Object List Attribute having ALL of the Objects in your game! iterating through all Objects in your game multiple times is the worst, compared to iterating through all Objects in your game once to add them into your 'npc' Object List Attribute so you don't have to do it manually yourself in in-code/GUI~Editor and then iterating through your smaller 'npc' Object List Attribute multiple times --- better, compared to merely iterating through your smaller 'npc' Object List Attribute multiple times --- best code efficiency wise but it means you got to manually put/write all of your npc Objects into your 'npc' Object List Attribute --- bad for YOU, lol)
// using a String attribute for your indicator/flag Attribute for this example:
<object name="npc1">
<attr name="type" type="string">npc</attr>
<attr name="relationshipscale" type="int">20</attr>
<attr name="relationship" type="string">unknown</attr>
</object>
<object name="npc2">
<attr name="type" type="string">npc</attr>
<attr name="relationshipscale" type="int">80</attr>
<attr name="relationship" type="string">unknown</attr>
</object>
foreach (object_variable, AllObjects()) {
if (GetAttribute (object_variable, "type") = "npc") {
if (object_variable.relationshipscale >= 90) {
object_variable.relationship = "lovers"
} else if (object_variable.relationshipscale >= 80) {
object_variable.relationship = "bffs"
}
// etc 'else ifs' and optional 'else'
}
}
hegemonkhan
24 Jul 2016, 19:36(sorry about the multiple posts)
here's using your code:
(changed/fixed it up a bit, to make it more efficient, as if I didn't do it... Jay+Pixie will, laughs. They don't like having/leaving it as inefficient code! Though I'm not sure if it's more efficient to go from max to min or from min to max... hmm...)
(unfortunately... I don't think there's another method, I think you have to use a Turnscript for doing this stuff. Well, there's the Turnscript's "evil cousin"... the Timer, but then you got to deal with its "evil" messiness, lol)
<turnscript name="global_turnscript">
<enabled />
<script>
foreach (object_variable, AllObjects()) {
if (GetAttribute (object_variable, "type") = "npc") { // if all of your Objects have the 'type' Attribute, than you can do this instead: if (object_variable.type = "npc") {
if (object_variable.relationshipscale < 1) {
object_variable.relationship = "hostile"
} else if (object_variable.relationshipscale < 11) {
object_variable.relationship = "hatred"
} else if (object_variable.relationshipscale < 40) {
object_variable.relationship = "stranger"
} else if (object_variable.relationshipscale < 60) {
object_variable.relationship = "acq"
} else if (object_variable.relationshipscale < 80) {
object_variable.relationship = "friend"
} else if (object_variable.relationshipscale < 100) {
object_variable.relationship = "fwb"
} else if (object_variable.relationshipscale < 120) {
object_variable.relationship = "lover"
} else {
object_variable.relationship = "spouse"
}
}
}
</script>
</turnscript>
bergedorfcacher
24 Jul 2016, 20:06If you want to handle all npc at the same time you can iterate as hegemonkhan has mentioned. If you just want one at a time, but the same behaviour for all without having to repeat the code, you can use a function (say: GetRelationshipText). That gets one parameter (calling it obj for now)
The function would contain code like this:
if (obj.relationshipscale = 0) {
return ("hostile")
If you need to call the function from a script of an object you can use 'this': GetRelationshipText(this)
Not entirely sure if this answers your question, but it was worth a try. :-)
hegemonkhan
24 Jul 2016, 20:11P.S.
with quest, using the concepts/designs of 'Get' and 'Set' (and returning Values with) Functions, isn't as neccessary as it is with the main programming languages, due to being able to globally (as they're not restricted/blocked/protected/"encapsulated=contained" in quest) access/use Attributes (Variables contained within OBJECTS/quest: Elements). They can be useful, but quest has a lot of its own (and tentatively better) methods/Functions that you can use instead.
hegemonkhan
24 Jul 2016, 20:24here's an excerpt from my 'guide on using lists' ( http://textadventures.co.uk/forum/samples/topic/5137/list-and-dictionary-extensive-guide-by-hk ---- you got to scroll down a long ways to the 'foreach and for' sections), that hopefully helps you understand how the 'foreach' Script/Function works :
game.team = split ("joe;jim;john", ";")
foreach (team_member, game.team) {
do (team_member,"run_laps_script_attribute")
// output result conceptually:
// joe.runs_laps_script_attribute -> joe runs laps
// jim.runs_laps_script_attribute -> jim runs laps
// john.runs_laps_script_attribute -> john runs laps
}
// and the exact same thing:
game.team = split ("joe;jim;john", ";")
foreach (x, game.team) {
do (x,"run_laps")
// output result conceptually:
// joe.runs_laps -> joe runs laps
// jim.runs_laps -> jim runs laps
// john.runs_laps -> john runs laps
}
// and the exact same thing:
game.team = split ("joe;jim;john", ";")
foreach (item, game.team) {
do (item,"run_laps")
// output result conceptually:
// joe.runs_laps -> joe runs laps
// jim.runs -> jim runs laps
// john.runs -> john runs laps
}
// and the exact same thing:
game.team = split ("joe;jim;john", ";")
foreach (blahblahblah, game.team) {
do (blahblahblah,"run_laps")
// output result conceptually:
// joe.runs_laps -> joe runs laps
// jim.runs -> jim runs laps
// john.runs -> john runs laps
}
using my first example in the above excerpt, let me add in some additional details/explanation/guidance with it:
game.team = split ("joe;jim;john", ";")
foreach (team_member, game.team) {
do (team_member,"run_laps_script_attribute")
// conceptually what my 'team_member' as the placeholder Variable does:
// team_member = joe
// team_member = jim
// team_member = john
// output result conceptually:
// (team_member = joe)---> team_member.runs_laps_script_attribute -> joe.runs_laps_script_attribute ---> joe runs laps
// (team_member = jim)---> team_member.runs_laps_script_attribute -> jim.runs_laps_script_attribute ---> jim runs laps
// (team_member = john)---> team_member.runs_laps_script_attribute -> john.runs_laps_script_attribute ---> john runs laps
}
and changing up the name/label for the placeholder Variable, to show that it doesn't matter what you name/label it as:
game.team = split ("joe;jim;john", ";")
foreach (abc, game.team) {
do (abc,"run_laps_script_attribute")
// conceptually what my 'abc' as the placeholder Variable does:
// abc = joe
// abc = jim
// abc = john
// output result conceptually:
// (abc = joe)---> abc.runs_laps_script_attribute -> joe.runs_laps_script_attribute ---> joe runs laps
// (abc = jim)---> abc.runs_laps_script_attribute -> jim.runs_laps_script_attribute ---> jim runs laps
// (abc = john)---> abc.runs_laps_script_attribute -> john.runs_laps_script_attribute ---> john runs laps
}

Anonynn
24 Jul 2016, 20:39Alrighty! Just checking if this will work :) I tried following everyone's examples lol.
So...
Type: NPC
relationship.string.unknown
relationshipscale.integer.0
Function
GetRelationship
foreach (object_variable, AllObjects()) {
if (GetAttribute (object_variable, "type") = "npc") {
if (object_variable.relationshipscale = 0) {
return ("hostile")
}
if (object_variable.relationshipscale >=1 and object_variable.relationshipscale <=10) {
return ("hated")
}
if (object_variable.relationshipscale >=11 and object_variable.relationshipscale <=39) {
return ("stranger")
}
if (object_variable.relationshipscale >=40 and object_variable.relationshipscale <=59) {
return ("acq")
}
if (object_variable.relationshipscale >=60 and object_variable.relationshipscale <=79) {
return ("friend")
}
if (object_variable.relationshipscale >=80 and object_variable.relationshipscale <=99) {
return ("fwb")
}
if (object_variable.relationshipscale >=100 and object_variable.relationshipscale <=119) {
return ("lover")
}
if (object_variable.relationshipscale = 120) {
return ("spouse")
}
}
}
Set Relationship
object_variable.relationshipscale = GetRelationship()
If this won't work, I can try some other alternatives that HK suggested. BTW, I appreciate you two weighing in on this and helping! :D I get confused sometimes.
hegemonkhan
24 Jul 2016, 23:07ah, from your post above, you're wanting to use the inherited Attribute (Object Type / Type) method, so your code needs to be changed slightly (as we got to use the 'DoesInherit(OBJECT_NAME, "OBJECT_TYPE_NAME")' Script/Function.
http://docs.textadventures.co.uk/quest/functions/doesinherit.html
http://docs.textadventures.co.uk/quest/tutorial/using_inherited_types.html
http://docs.textadventures.co.uk/quest/guides/using_types.html
and here's about a Function (and all of its options) and its syntaxes:
http://docs.textadventures.co.uk/quest/elements/function.html
Also, because we're acting upon multiple Objects, you can NOT use the/a Function's 'RETURN' functionality. This is refering to my re-naming/labeling of your Function of/from 'GetRelationship' to as now being 'SetRelationship' seen below in my example code
full (fixed up) code is below:
(I changed the OPERATORS again, as this design logic is more efficient than what yours was: it'll make your game faster/better performance as quest/computer is doing less actions/operations)
(also, there's a difference between using lots of 'ifs' vs 'else ifs', though it's a bit hard/long/difficult to explain about it. Using the 'else ifs' is better/more efficient. Just trust this code... it'll work... if I hadn't made any mistakes..., laughs)
(omg! I totally forgot in my previous codes to include the '' tags, MY BIG BAD, as this is NEEDED for when coding directly in-code for enabling the use of the lesser/great than/equal OPERATOR symbols! MY HUGE APOLOGIES!)
<type name="npc">
<attr name="relationship" type="string">unknown</attr>
<attr name="relationshipscale" type="int">0</attr>
</type>
// this is the Function that is acting upon multiple Objects (via using the 'foreach' Script/Function), so we can NOT use the 'RETURN' functionality for/with it:
<function name="SetRelationship">
<![CDATA[
foreach (object_variable, AllObjects()) {
if (DoesInherit (object_variable, "npc")) {
if (object_variable.relationshipscale < 1) {
object_variable.relationship = "hostile"
} else if (object_variable.relationshipscale < 11) {
object_variable.relationship = "hated"
} else if (object_variable.relationshipscale < 40) {
object_variable.relationship = "stranger"
} else if (object_variable.relationshipscale < 60) {
object_variable.relationship = "acq"
} else if (object_variable.relationshipscale < 80) {
object_variable.relationship = "friend"
} else if (object_variable.relationshipscale < 100) {
object_variable.relationship = "fwb"
} else if (object_variable.relationshipscale < 120) {
object_variable.relationship = "lover"
} else {
object_variable.relationship = "spouse"
}
}
}
]]>
</function>
// a Function to dynamically get your 'whatever/any' Object's 'relationship' Attribute's Value:
(this Function is acting upon a single Object, thus we now can set up and use the 'RETURN' functionality)
<function name="GetRelationship" parameters="object_parameter" type="string"> // the, type="xxx", part of this Function's (programming terminology) Header/Signature is the Type of Value that you're telling quest you'll be returning (so your Value must indeed match this, specified/des-sig-nated --- can't spell, type)
if (HasString (object_parameter, "relationship")) {
return (object_parameter.relationship)
} else {
msg ("The 'GetRelationship' Function failed as the inputed Object doesn't have the 'relationship' String Attribute existing/added to it")
}
</function>
// to call/use the 'GetRelationship' Function, an example:
string_variable = GetRelationship (npc1)
if (string_variable = "hostile") {
msg ("You fight with " + npc1.alias + ".")
} else {
msg ("You're not at a low enough relationship to get into a fight with " + npc1.alias + ".")
}
// example of needed, Objects, Inherited Attributes, and the Object Type, for the above use of the 'GetRelationship" Function:
<object name="npc1">
<inherit name="npc" /> // this adds these: '<attr name="relationshipscale" type="int">0</attr>' and '<attr name="relationship" type="string">unknown</attr>', from the 'npc' Object Type, to this (npc1) Object
</object>
<object name="npc2">
<inherit name="npc" /> // this adds these: '<attr name="relationshipscale" type="int">0</attr>' and '<attr name="relationship" type="string">unknown</attr>', from the 'npc' Object Type to this (npc2) Object
<attr name="relationshipscale" type="int">28</attr> // this over-rides your Inherited Attribute (<attr name="relationshipscale" type="int">0</attr>) from the 'npc' Object Type, for this (npc2) Object
</object>
<object name="npc3">
<inherit name="type" /> // this adds these: '<attr name="relationshipscale" type="int">0</attr>' and '<attr name="relationship" type="string">unknown</attr>', from the 'npc' Object Type to this (npc3) Object
<attr name="relationshipscale" type="int">63</attr> // this over-rides your Inherited Attribute (<attr name="relationshipscale" type="int">0</attr>) from the 'npc' Object Type, for this (npc3) Object
</object>
<type name="npc">
<attr name="relationshipscale" type="int">0</attr>
<attr name="relationship" type="string">unknown</attr>
</type>
// a Function to dynamically get your 'whatever/any' Object's 'relationshipscale' Attribute's Value:
(this Function is acting upon a single Object, thus we now can set up and use the 'RETURN' functionality)
<function name="GetRelationshipscale" parameters="object_parameter" type="int"> // the, type="xxx", part of this Function's (programming terminology) Header/Signature is the Type of Value that you're telling quest you'll be returning (so your Value must indeed match this, specified/des-sig-nated --- can't spell, type)
if (HasInt (object_parameter, "relationshipscale")) {
return (object_parameter.relationshipscale)
} else {
msg ("The 'GetRelationshipscale' Function failed as the inputed Object doesn't have the 'relationshipscale' Integer Attribute existing/added to it")
}
</function>
// to call/use the 'GetRelationshipscale' Function, an example:
<![CDATA[
integer_variable = GetRelationshipscale (npc1)
if (integer_variable <= 0) {
msg ("You fight with " + npc1.alias + ".")
} else if (integer_variable < 50) {
msg ("blah")
} else if (integer_variable < 100) {
msg ("blah")
} else {
msg (npc1.alias + "\'s relationshipscale is 100 or more with you!, thus " + npc1.alias + " is your spouse and vice versa!")
}
]]>
hegemonkhan
24 Jul 2016, 23:47P.S.
if my posts are confusing you, please let me know! So I can try to explain them more clearly and/or straighten their information out for you. As I posted a lot of posts... information overload! I'm likely overwhelming and thus confusing you, sighs.
also, let me try to explain the logic invovled with this code design of mine (as it is quite advanced logic+programming concepts):
if (object_variable.relationshipscale < 1) {
object_variable.relationship = "hostile"
} else if (object_variable.relationshipscale < 11) {
object_variable.relationship = "hated"
} else if (object_variable.relationshipscale < 40) {
object_variable.relationship = "stranger"
} else if (object_variable.relationshipscale < 60) {
object_variable.relationship = "acq"
} else if (object_variable.relationshipscale < 80) {
object_variable.relationship = "friend"
} else if (object_variable.relationshipscale < 100) {
object_variable.relationship = "fwb"
} else if (object_variable.relationshipscale < 120) {
object_variable.relationship = "lover"
} else {
object_variable.relationship = "spouse"
}
if ('whatever/any' Object's 'relationshipscale' Integer Attribute's Value is less than '1', then set 'whatever/any' Object's 'relationship' String Attribute's Value to 'hostile', and thus ALL the 'else ifs' and the 'else' below are completely ignored. BUT... If it's '1 or more', then goto the first 'else if' below:
else if ('whatever/any' Object's 'relationshipscale' Integer Attribute's Value is less than '11', then set 'whatever/any' Object's 'relationship' String Attribute's Value to 'hated', and thus ALL the 'else ifs' and the 'else' below are completely ignored. BUT... If it's '11 or more', then goto the first 'else if' below:
else if ('whatever/any' Object's 'relationshipscale' Integer Attribute's Value is less than '40', then set 'whatever/any' Object's 'relationship' String Attribute's Value to 'stranger', and thus ALL the 'else ifs' and the 'else' (burdening operatons) below are completely ignored! BUT... If it's '40 or more', then goto the first 'else if' below:
etc etc etc 'else ifs'....
else -> if it's '100 or more', then then set 'whatever/any' Object's 'relationship' String Attribute's Value to 'spouse'
number (tallying/adding/sum'ming) of operations (amount of work quest/computer has to do: more work = bad, less work = good):
1 (if VAR1 < 1) ---> 2 (set VAR2 = "hostile")
or
2 (else if VAR1 < 11) ---> 3 (set VAR2 = "hated")
or
3 (else if VAR1 < 40) ---> 4 (set VAR2 = "stranger")
or
4 (else if VAR1 < 60) -> 5 (set VAR2 = "acq")
or
5 (else if VAR1 < 80) -> 6 (set VAR2 = "friend")
or
6 (else if VAR1 < 100) -> 7 (set VAR2 = "fwb")
or
7 (else if VAR1 < 120) -> 8 (set VAR2 = "lover")
or
8 (set VAR2 = "spouse")
so with this code design your range of operations (work) is:
least of 2 to most of 8 operations (work)
quest/computer is only doing at most 8 operations/work (chores), and if super lucky, then only merely 2 operations/work (chores)! No one likes doing chores, hehe. So, the less the better!
now let's compare it to your code:
(this took me a long time to understand - took my taking and dropping out, cries/sobs/sighs, of my Assembly language and Computer Architecture school class --- as it was a bit too ahrd for me, to finally get/have this understanding, much to Jay's and Pixie's annoyance over my years here learning quest, laughs. So, this is really advanced stuff, I'm just trying to demonstrate the difference in better code design vs bad code design, in its effect upon speed/performance. I hope this isn't coming across badly, it's not my intent anyways, sighs. I too coded exactly like this myself, and had Jay and Pixie constantly trying to get through to me, what I'm trying to demonstrate to you here. I'm stubborn and stupid, which makes me a very slow learner, laughs)
if (object_variable.relationshipscale = 0) {
object_variable.relationship = "hostile"
}
if (object_variable.relationshipscale >= 1 and object_variable.relationshipscale <= 10) {
object_variable.relationship = "hated"
}
if (object_variable.relationshipscale >= 11 and object_variable.relationshipscale <= 39) {
object_variable.relationship = "stranger"
}
if (object_variable.relationshipscale >= 40 and object_variable.relationshipscale <= 59) {
object_variable.relationship = "acq"
}
if (object_variable.relationshipscale >= 60 and object_variable.relationshipscale <= 79) {
object_variable.relationship = "friend"
}
if (object_variable.relationshipscale >= 80 and object_variable.relationshipscale <= 99) {
object_variable.relationship = "fwb"
}
if (object_variable.relationshipscale >= 100 and object_variable.relationshipscale <= 119) {
object_variable.relationship = "lover"
}
if (object_variable.relationshipscale = 120) {
object_variable.relationship = "spouse"
}
the numbers/tallying/adding/sum'ming of operations:
...............
(A1) (if VAR1 = 0) ---> (B2) (set VAR2 = "hostile") -> goto the first 'and' below:
.............
and
...........
(A2 or B3) (if VAR1 > 1) ---> (A3 or B4) (if VAR1 < 10) ---> (A4 or B5) (set VAR2 = "hated") ---> goto the first 'and' below:
or
(A3 or B4) (if VAR1 = 1) ---> (A4 or B5) (if VAR1 < 10) ---> (A5 or B6) (set VAR2 = "hated") ---> goto the first 'and' below:
or
(A5 or B6) (if VAR1 = 10) ---> (A6 or B7) (set VAR2 = "hated") ---> goto the first 'and' below:
or
(A5 or B6) goto the first 'and' below:
or
(A4 or B5) goto the first 'and' below:
or
(A4 or B5) (if VAR = 1) ---> (A5 or B6) (set VAR2 = "hated") ---> goto the first 'and' below:
or
(A4 or B5) goto the first 'and' below:
..........
and
............
(A4 or B5, or, A5 or B6, or, A6 or B7) (if VAR1 > 11) ---> (A5 or B6, or, A6 or B7, or, A7 or B8) (if VAR1 < 39) ---> (A6 or B7, or, A7 or B8, or, A8 or B9) (set VAR2 = "stranger") ---> goto the first 'and' below:
or
(A5 or B6, or, A6 or B7, or, A7 or B8) (if VAR1 = 11) ---> (A6 or B7, or, A7 or B8, or, A8 or B9) (if VAR1 < 39) ---> (A7 or B8, or, A8 or B9, or, A9 or B10) (set VAR2 = "stranger") ---> goto the first 'and' below:
or
(A7 or B8, or, A8 or B9, or, A9 or B10) (if VAR1 = 39) ---> (A8 or B9, or, A9 or B10, or, A10 or B11) (set VAR2 = "stranger") ---> goto the first 'and' below:
or
(A7 or B8, or, A8 or B9, or, A9 or B10) goto the first 'and' below:
or
(A5 or B6, or, A6 or B7, or, A7 or B8) goto the first 'and' below:
.............
and
I GIVE UP, hopefully you can see why (I got A LOT MORE TO FIGURE OUT, AND IT'S JUST TOO HARD FOR MY BRAIN! LOL)
I'm not even done with all the operations for 'stranger', and I'm already at (using this simplistic example) a max of 10 operations (and my brain was exploding at trying to count/tally them already, laughs)! I now understand a bit of why Jay and Pixie cringed when my code looked just like yours (and some times it still does... HK looks away whisling innocently), laughs.
your code will end up doing many more (unneeded) operations/work. Someone (quest/computer) will be doing a lot more chores using your code than someone (quest/computer) using my code.

Anonynn
25 Jul 2016, 00:04Haha, it is a LITTLE confusing but I'll post what I have and we'll see if I understood or not :) I do appreciate it so far though! All of this is very helpful, although simplier is always better imo!
So I have 3 Functions:
Get Relationship
SetRelationshipscale
GetRelationshipscale
I also have a "type" called:
relationship
The type have these attributes:
relationship.string.unknown
relationshipscale.integer.0
The GetRelationship Function:
if (HasString (object_parameter, "relationship")) {
return (object_parameter.relationship)
}
The SetRelationshipscale Function:
foreach (object_variable, AllObjects()) {
if (DoesInherit (object_variable, "type")) {
if (object_variable.relationshipscale = 0) {
object_variable.relationship = "hostile"
}
else if (object_variable.relationshipscale =1 and object_variable.relationshipscale <=10) {
object_variable.relationship = "hated"
}
else if (object_variable.relationshipscale >=11 and object_variable.relationshipscale <=39) {
object_variable.relationship = "stranger"
}
else if (object_variable.relationshipscale >=40 and object_variable.relationshipscale <=59) {
object_variable.relationship = "acq"
}
else if (object_variable.relationshipscale >=60 and object_variable.relationshipscale <=79) {
object_variable.relationship = "friend"
}
else if (object_variable.relationshipscale >=80 and object_variable.relationshipscale <=99) {
object_variable.relationship = "fwb"
}
else if (object_variable.relationshipscale >=100 and object_variable.relationshipscale <=119) {
object_variable.relationship = "lover"
}
else {
object_variable.relationship = "spouse"
}
}
}
The GetRelationshipscale Function:
if (HasInt (object_parameter, "relationshipscale")) {
return (object_parameter.relationshipscale)
}
This is how I would set the Relationship Status and increase the Scale in-game:
object_parameter.relationship = "stranger"
object_parameter.relationshipscale = object_parameter.relationshipscale + 10
Is all of that correct so far? :) I feel like there should be a more simple way of doing all this! xD
hegemonkhan
25 Jul 2016, 03:05Your 'GetRelationship' function:
if (HasString (object_parameter, "relationship")) {
return (object_parameter.relationship)
}
is correct, so/as long as you set up the Function correctly, which would be:
<function name="GetRelationship" parameters="object_parameter" type="string">
if (HasString (object_parameter, "relationship")) {
return (object_parameter.relationship)
}
// you really should have an 'else' error-prompting 'msg' Script, to inform the user and/or yourself/co-testers (doing game testing), so you know you used an Object which doesn't have the 'relationship' String Attribute, which is the cause of the seeming (and/or worse: unknown/unaware of) Function "failure" (technically it's the 'false' result, not an actual failure/error of the function).
</function>
and if you correctly set up the call/usage of the function, for examples:
// example 1A: npc1.relationship = GetRelationship (npc2)
// example 1B:
string_variable = GetRelationship (npc2)
npc1.relationship = string_variable
// example 2A: if (GetRelationship (npc2) = npc3.relationship) { /* scripting */ }
// example 2B: if (GetRelationship (npc2) = GetRelationship (npc3)) { /* scripting */ }
<object name="npc1">
<inherit name="relationship" /> // sorry, I accidentally called this 'npc' in my last post's code example (oops!)
<attr name="relationshipscale" type="int">88</attr>
<attr name="relationship" type="string">fwb</attr>
</object>
<object name="npc2">
<inherit name="relationship" /> // sorry, I accidentally called this 'npc' in my last post's code example (oops!)
</object>
<object name="npc3">
<inherit name="relationship" /> // sorry, I accidentally called this 'npc' in my last post's code example (oops!)
</object>
<type name="relationship">
<attr name="relationship" type="string">unknown</attr>
<attr name="relationshipscale" type="int">0</attr>
</type>
WARNING: I don't think you can have 'relationship' be the name for both your String Attribute and your Object Type, or if you can... quest may do a popup menu asking which one you meant/want to be using... (usually the 'name' String Attribute is the ID Attribute, meaning that you can't have two or more of the same named/labeld 'name' String Attributes)
for your 'SetRelationshipscale' Function:
you have a typo, you need to add in the '>' on the '=1', it should look like this (the equals sign/symbol has to be on the right side of the other OPERATOR symbol): '>=1'
if you do: '=>', you'll get an error
also, if you got a space (whitespace) between the two OPERATORS, it'll likely cause an error too.
also, if you're writing/copying/pasting this code directly into the game code, you'll need it to look like this:
// inside of 'whatever' Element (Object's Verb / Object's Script Attribute, Function, Command, Turnscript, etc):
<![CDATA[
foreach (object_variable, AllObjects()) {
if (DoesInherit (object_variable, "type")) {
if (object_variable.relationshipscale = 0) {
object_variable.relationship = "hostile"
}
else if (object_variable.relationshipscale >= 1 and object_variable.relationshipscale <= 10) {
object_variable.relationship = "hated"
}
else if (object_variable.relationshipscale >= 11 and object_variable.relationshipscale <= 39) {
object_variable.relationship = "stranger"
}
else if (object_variable.relationshipscale >= 40 and object_variable.relationshipscale <= 59) {
object_variable.relationship = "acq"
}
else if (object_variable.relationshipscale >= 60 and object_variable.relationshipscale <= 79) {
object_variable.relationship = "friend"
}
else if (object_variable.relationshipscale >= 80 and object_variable.relationshipscale <= 99) {
object_variable.relationship = "fwb"
}
else if (object_variable.relationshipscale >= 100 and object_variable.relationshipscale <= 119) {
object_variable.relationship = "lover"
}
else {
object_variable.relationship = "spouse"
}
}
}
]]>
if you used the GUI~Editor's 'run as script -> add new script' options, then you don't need to include the '<!C[DATA[ ... ]]>' tags. Though, you can always check the game code, making sure that these tags are in there just to be safe (if the quest editor/play mode hasn't already failed to load/open/start/initialize), and if not, then put them in yourself.
you can do this:
object_parameter.relationship = "stranger"
object_parameter.relationshipscale = object_parameter.relationshipscale + 10
but you're manually having to correctly type in the correct Value (you have to be sure that you know what your 'relationshipscale' Value is, as adding 10 to it, depending on what the Value is, may not correspond to your, in this example, use of setting the 'relationship' to "stranger", right? What if your 'relationshipscale' Value was '80', would that correctly correspond with "stranger". No, it wouldn't. Also, this means you can't deal with in-playing-game changes/dynamic-ness of Attributes' Values.
to deal with in-playing-game changes/dynamic-ness of Attributes' Values, one way, would be to use the 'SetRelationshipscale' Function (as this uses/checks your 'relationshipscale' Integer Value, using your scripting that you already have in the Function doing the matching of it up to the correct 'relationship' String Value for you automatically, meaning it can handle changing/dynamic Attributes' Values during game play, but only if you ALSO HAVE TO put this into a scripting location that is constantly running/firing/executing on every internal turn, aka using a global Turnscript, or whenever any Object's Attribute's Values change, aka using the special 'changed' Script Attribute, but you don't want to do this, as you'd have to create/add them for every single Object and their every single Attribute invovled.... YUUUUCCKKKKK!!!!!!) and the function returns the correct 'relationship' String Value for you.
so....
just add in (where-ever you need/want it to occur) the script that changes the Integer Value, using your example:
object_parameter.relationshipscale = object_parameter.relationshipscale + 10
and if you have your 'GetRelationshipscale' Function within a global Turnscript, it'll automatically update all (specifed by, Object Type / Inherited Attribute, as we've set it up to do) Objects' 'relationship' String Attribute's Values for you!
yes... there can be a bit better ways of doing this (though not by too much), but they involve some really advanced/fancy/concise code, far beyond my ability, laughs. Even my one post with that Function using a lot of ArgumentParameter inputs is quite messy...
as far as I understand of the CS (Computer Science: Programming/Software Enginneering and Computer/Electronic/Circuitry Engineering) field:
stages of CS (Computer Science: massive field: programming/coding and computer electronics and their connection to each other, high level math and logic and theoretical level stuff too with them courses/classes/subjects, computer/circuitry architecture, computer/circuitry design, neuro science / man-machine / matrix / advanced terminator/ascension AI --- type of stuff, and etc etc etc):
lower division classes:
High Level Languages (more to the basic computer user's level, more user-friendly):
- "basic" scripting: ifs, loops, variables, functions, objects, procedural/sequential (function using) coding/design, recursion, etc...
- various languages (C++, Java, Python, JS: JavaScript, Ruby, C, C#, MS-DoS/computer Command Box/Shell languages, Perl, Lua/Lau - whatever meh, Fortron whatever meh, AppleScript, Apple: Swift, etc)
- object oriented design/coding (using Objects, duh, lol): Encapsulation (constructors, destructors, Objects/containment, Groups/Classes, etc), Inheritance (Groups/Classes, Interfaces, Objects, etc), and/or Polymorphism usages in/for code/program designs ("top/macro to down/micro" design)
- trees/structures/code design/organization/systems
Low Level Languages (nearer to the circuitry, less user-friendly)
- Assembly Languages (bit manipulation, addressing, boolean logic, bit logic, etc, encoding/decoding, threads/processii: directly working with/controlling individual cores/processors/cpus/computer chips, IO controlling, etc)
- Computer Architecture/Organization (circuitry, elontronic/circuitry/logic/computer enginneering, boolean logic / boolean gate logic, multiplexors, decoders, encoders, full adders, half adders, sequential circuits, buffers, inverters/negators, combinational circuits, etc etc etc)
Upper Division classes and beyond (graduate, bachelors, masters, ph. d: security/hacking/computer expert/consultant, software engineer/programmer, etc etc etc):
(or just ask Pixie, Jay, Pertex, Alex, etc actual/good programmers, about this stuff, lol)
- more computer architecture/organization
- ??? high level math, logic, theoretical, computer/engineering stuff, and etc stuff
- ??? high tech / futuristic stuff...
....
I'm still not really fully understanding that well of what CS field all entails, laughs, but I'm still just working on finishing up my lower division classes...
The Pixie
25 Jul 2016, 07:13Are you wanting a functions that takes the NPC as a parameter, so you can do something like:
msg("Your relationship with her is: " + GetRelationship(goblinesque woman) + ".")
The code in the function could look like this (give it a parameter npc
and a return type string
):
if (npc.relationshipscale <= 0) {
return ("hostile")
}
if (npc.relationshipscale <=10) {
return ("hated")
}
if (npc.relationshipscale <=39) {
return ("stranger")
}
if (npc.relationshipscale <=59) {
return ("acq")
}
if (npc.relationshipscale <=79) {
return ("friend")
}
if (npc.relationshipscale <=99) {
return ("fwb")
}
if (npc.relationshipscale <=119) {
return ("lover")
}
else {
return ("spouse")
}
Note that each test only needs to check the higher bound, as we know it cannot be below the lower bound at that point.
Or do you want the NPC to have an attribute that holds the relationship descriptor, and have that undated in a change script? You cannot have anything return from a change script or send it a parameter, so the code would look like this:
if (this.relationshipscale <= 0) {
this.relationshipdescriptor = "hostile"
}
if (this.relationshipscale <=10) {
this.relationshipdescriptor = "hated"
}
if (this.relationshipscale <=39) {
this.relationshipdescriptor = "stranger"
}
if (this.relationshipscale <=59) {
this.relationshipdescriptor = "acq"
}
if (this.relationshipscale <=79) {
this.relationshipdescriptor = "friend"
}
if (this.relationshipscale <=99) {
this.relationshipdescriptor = "fwb"
}
if (this.relationshipscale <=119) {
this.relationshipdescriptor = "lover"
}
else {
this.relationshipdescriptor = "spouse"
}
I would suggest doing this on one NPC and testing it works, and if it does, create an NPC type, and move it to there, setting all your NPCs to that type.

Anonynn
29 Jul 2016, 20:05Okay! So after talking with Pixie a little and messing with things. We came up with this solution, although it still doesn't quite work yet, probably because I'm not familiar with how to apply types and such to scripting. I know how to get things to affect player objects and commands to affect objects, but not how to apply types to scripting.
We came up with...
0 Functions
1 Type
Type: npc
relationshipscale.integer.0
changedrelationshipscale.script.
if (this.relationshipscale = 0) {
this.relationship = "hostile"
}
else if (this.relationshipscale >=1 and this.relationshipscale <=10) {
this.relationship = "hated"
}
else if (this.relationshipscale >=11 and this.relationshipscale <=39) {
this.relationship = "stranger"
}
else if (this.relationshipscale >=40 and this.relationshipscale <=59) {
this.relationship = "acq"
}
else if (this.relationshipscale >=60 and this.relationshipscale <=79) {
this.relationship = "friend"
}
else if (this.relationshipscale >=80 and this.relationshipscale <=99) {
this.relationship = "fwb"
}
else if (this.relationshipscale >=100 and this.relationshipscale <=119) {
this.relationship = "lover"
}
else {
this.relationship = "spouse"
}
So my only problem is basically how to assign these things to scripting, which I probably already know but since this is new my brain is trying to confuzzle me.
I know there is...
npccharacternamehere.relationshipscale = npccharacternamehere.relationshipscale + 10
which I can use to set the numbers of the scale, but is there a way to use the changed relationship attributes like...
if (DoesInherit (relationshipscale, "stranger")) {
}
Because all attempts so far leave errors that mention instances not set to object and variables. I don't think I need to do a stringlist that accounts for them all since they are part of the scale already, so I just wanted to know if this is all correct so far. Pix will be out of town for a while, so he/she won't be able to help ^_^ Let's all wish him/her a safe trip too!
UPDATE:
Got it to work! Thanks!