Change string attribute?


I got a few attributes that equal to text strings and want to change them in the middle of a script to change them so they return a different text string. It is a basic dialogue script which works like this:

First, we have the talk to womanscript:

msg ("Hello, how are you?<br>")
Woman.answer1 = "Fine, and you?"
Woman.answer2 = "Well, it's been a horrible day!"
Woman.answer3 = "Meeeeh, could be better."
Woman.answer4 = "Doing good, I guess."
msg (<b>1- #Woman.answer1#<br>2- #Woman.answer2#<br>3- #Woman.answer3#<br>4- #Woman.answer4#</b>)
get input {
  if (result = "1") {
    ZZZ.Dialogueprint = Woman.answer1
    msg ("I'm fine too, thanks!")
  else if (result = "2") {
    ZZZ.Dialogueprint = Woman.answer2
    msg ("Oh! I'm sorry about that.")
  else if (result = "3") {
    ZZZ.Dialogueprint = Woman.answer3
    msg ("At least it cannot be worse!")
  else if (result = "4") {
    ZZZ.Dialogueprint = Woman.answer4
    msg ("Me too!")
  else {
    msg ("If you can read this, you have just found a bug and should tell the dev about it.")

Then the Dialogue function that simply prints what the player says:

ZZZ.Dialogue = StartNewOutputSection ()
msg ("{ZZZ.Dialogueprint}")
EndOutputSection (ZZZ.Dialogue)
JS.eval ("$('."+PCSystem_Login.title+"').css('text-align', 'right').css('font-weight', 'bold');")

That's basically it. The point is that when it comes the the Woman.answer1 = "Fine, and you?" and the other three, the string is not changed. What am I doing wrong?

Btw: I'm running the desktop version, so the .answerx attributes are set beforehand.

The Pixie

I am not sure what the problem is, but have a couple of suggestions that might make the code simpler. Firstly, use ShowMenu, which does what you are trying to do with get input, but will be more reliable (what if the player types "5"?).

Secondly, send the result as a parameter to your Dialogue function, rather than setting it as an attribute.


it might have something to do with the 'StartNewOutputSection()/EndOutputSection()' stuff (I wasn't even aware this stuff existed, lol).

All Attributes can be set, re-set, changed, altered, manipulated, and etc through scripting:

player. strength = 100
// quest is able to parse the Value as to what type of Value it is, to what Type of Attribute it is/needs to be (so our 'player.strength' Attribute is an 'int/integer' Attribute, as it's Value, 100, is an Integer/int Value
msg (player.strength)
// outputs: 100

but, now let's have it be different:

player.strength = 50
msg (player.strength)
// outputs: 50

we can do this with all of the Attribute Types:

orc.dead = false
msg (orc.dead)
// outputs: false
orc.dead = true
msg (orc.dead)
// outputs: true

player.alias = "HK"
msg (player.alias)
// outputs: HK
player.alias = "Groctel"
msg (player.alias)
// outputs: Groctel

etc etc etc

and for Strings, we can do concatenation too:

game.x = "mama"
msg (game.x)
outputs: mama
game.x = game.x + "mia"
msg (game.x)
outputs: mamamia


you can take a look at some of this code for examples/ideas at what some things you can do:

if you want to use a numbering input system, look into using Dictionary Attributes (a 'Dictionary' is just an 'input--->output' Function, or if you rather think of them this way, as a 'conversion' Function)

for example:

<object name="global_data_object">
  <attr name="color_list" type="simplestringlist">red; blue; yellow</attr>
  <attr name="color_dict" type="simplestringdictionary">1 = red; 2 = blue; 3 = yellow</attr> // (number to color only)
  // <attr name="color_dict" type="simplestringdictionary">red = 1; blue = 2; yellow = 3</attr> // (color to number only)
  // if you want to be able to go both ways (number to color or color to number), then you need to do this:
  // (remember, the value to the left of the '=' sign is the input value, and the value to the right of the '=' sign is the output value)
  // <attr name="color_dict" type="simplestringdictionary">1 = red; red = 1; 2 = blue; blue = 2; 3 = yellow; yellow = 3</attr>

// scripting:

msg ("Choose a color (Type in the number of your choice)")
DisplayList (global_data_object.color_list)
// the 'DisplayList' outputs for you (you can also manually code in such displayment too instead of using this built-in Function):
// 1. red
// 2. blue
// 3. yellow
get input {
  if (IsInt (result) and ToInt (result) > 0 and ToInt (result) <= ListCount (global_data_object.color_list) {
    player.color_selection = StringDictionaryItem (global_data_object.color_dictionary, result)
    // if you inputted '1', then: player.color_selection = "red"
    // if you inputted '2', then: player.color_selection = "blue"
    // if you inputted '3', then: player.color_selection = "yellow"
  } else {
    msg (Wrong input, try again")
    wait {
      // loop/call/do/invoke Script Attribute/Function/scripting again

Pixie ingeniously uses both way String Dictionary Attributes to handle RPG's 'elemental damages' (especially the handling of opposing elemental damage, ie your water damage spell used on a fire elemental monster, doing extra damage to it), as you can't do this (pseudocode):

if (monster.elemental:fire = spell.elemental:water or monster.elemental:water = spellelemental:fire), then = - spell.damage * 2 // (or 1.5 or whatever, meh)

as, if (fire = water ---> FALSE), this may seem like you can use this design, but not so, as it allows for any other elemental to be used for extra damage, and not specifically opposing elementals only.

but Pixie's ingenious-ness realized you can do this:

if (monster.elemental:fire = StringDictionaryItem (input: spell.elemental:water): outputs: fire)

which now works, as indeed, if (fire = water ---> fire, --->, fire = fire, --->, TRUE), and they're indeed opposite elementals, so it is correctly doing the extra damage.

and indeed works only for opposing elementals, as can be seen:

if (fire = air ---> earth, --->, fire = earth, --->, FALSE), and they're NOT opposite elementals, so it is correctly NOT doing the extra damage.
if (fire = fire ---> water, --->, fire = water, --->, FALSE), and they're NOT opposite elementals, so it is correctly NOT doing the extra damage.
if (fire = earth ---> air, --->, fire = air, --->, FALSE), and they're NOT opposite elementals, so it is correctly NOT doing the extra damage.

Log in to post a reply.