Switch Script Text Processor[SOLVED]

Anonynn
10 Jul 2016, 16:14

I was just wondering if a "Switch Script" could exist as a text processor. For example, something like (and forgive my logic lol),

{if switch.result="Blah":}

or

{if switch.GetHighestAtt()="Blah":}

((GetHighestAtt() is one of my functions))


bergedorfcacher
10 Jul 2016, 16:37

With switch, are you referring to http://docs.textadventures.co.uk/quest/scripts/switch.html ?

You already have 'if' in the text processor, I'm not sure how switch could work, would require pretty complicated syntax.

It would be nice if one could use any sort of boolean expression with that if. According to the documentation (and a quick test I did) that does not work currently. But I'm not sure how easy such a feature would be to implement. (And how important that is. You can easily solve the same problem with a script. If you need help with that, just let me know.)


Anonynn
10 Jul 2016, 17:44

Are you talking about...

{if player.blahblah=True:}? Cause that works just fine. You just have to capitalize it. For some reason, sometimes when you lower case the "true" it doesn't work. But I find all the capitalized "True" and "False" work perfectly.

Thanks for the "Switch" link. I'll check it out and see if it mentions the text processor.


hegemonkhan
11 Jul 2016, 00:13

you can't use 'switch' in the text processor, I'm pretty sure anyways. Also, the 'if' and 'switch' are exactly the same thing (in terms of functionality), and the 'if' is already programmed to work with the text processor commands. There's no 'else if' nor 'else' programmed into the text processor commands, so it's unlikely that 'switch' is programmed into the text processor commands, as it, on top of the 'switch' condition, requires the 'case' condition programming too, and lastly its 'default' ('else') condition. Text Processor Commands are limited in functionality, they only employ the 'if' and 'if not' conditions. There's no 'else if/case' nor 'else/default' conditions programmed in. To do 'else ifs', you simply do multiple 'if/if not' text processor commands.

what you can do instead is to have something like this, a conceptual example:

// storing your returned highest attribute from your 'get_highest_attribute' Function into an Attribute:
game.pov.highest_integer_attribute = get_highest_integer_attribute_function (game.pov)

// and then, you can use that Attribute in your text processor commands:
msg ("{if game.pov.highest_integer_attribute > 66: blah blah blah}{if game.pov.highest_integer_attribute > 33: blah blah blah}{if game.pov.highest_integer_attribute > 0: blah blah blah}")


P.S.

for Boolean Attributes, these are more efficient text processor commands to use:

{if OBJECT_NAME.BOOLEAN_ATTRIBUTE_NAME:blah blah blah} // if TRUE
{if not OBJECT_NAME.BOOLEAN_ATTRIBUTE_NAME:blah blah blah} // if FALSE

the:

{if OBJECT_NAME.ATTRIBUTE_NAME=WHATEVER_VALUE:blah blah blah}

should only be used for String Attributes, as String Attributes require it, lol. Boolean Attributes don't:

{if OBJECT_NAME.STRING_ATTRIBUTE_NAME=WHATEVER_VALUE:blah blah blah}


hegemonkhan
11 Jul 2016, 00:36

the alternative to using text processor commands, is to 'build up' a String Attribute through concatenation (this has the full utility/usefulness/powerfulness possible --- as opposed to the limited utility/usefulness/powerfulness of text processor commands), a lame quick example (you can do a lot more, aka: any/all, scripting than shown below):

npc_1.greeting_string_attribute = "Hi"
if (game.pov.alias = "HK") {
  npc_1.greeting_string_attribute = npc_1.greeting_string_attribute + ", HK. You're so awesome! Can I get your autograph?"
  if (game.pov.has_autograph) {
    npc_1.greeting_string_attribute = npc_1.greeting_string_attribute + " Thank you for the autograph! You're the best HK!"
  } else {
    npc_1.greeting_string_attribute = npc_1.greeting_string_attribute + ". No?! You're the worst, HK. You're not awesome, you're awful!"
  }
} else if (game.pov.alias = "Anonynn") {
  npc_1.greeting_string_attribute = npc_1.greeting_string_attribute + ", Anonynn. How are you doing?"
} else if (game.pov.alias = "Bergedorfcacher") {
  npc_1.greeting_string_attribute = npc_1.greeting_string_attribute + ", Bergedorfcacher. How are you doing?"
}
msg (npc_1.greeting_string_attribute)

Anonynn
11 Jul 2016, 18:07

Appreciate it, HK! :D


Anonynn
11 Jul 2016, 18:07

PS! How is YOUR game coming along >:D? Have you started work on it yet?


hegemonkhan
11 Jul 2016, 21:00

still slowly working on the character creation stuff, struggling with both the coding aspect of it as well as with game design ideas of it, sighs. Still working on character (life taxonomy: life, domain, kingdom, phylum, order, family, tribe, genus, species, race, etc) heirarchy, and I need to figure out a better way to do the coding, as I have massive code redundency that is using up a lot more lines than it should be using up, sighs.

I think I need to transfer over from using Functions, to using Objects and Delegates, in order to create a better code design... I should probably ask Jay and/or Pixie about this stuff, if it'll be able to achieve my needs, as if it doesn't than I'd be wasting a huge amount of time, lol.