Can the text processor set flags?

I know you can now use the text processor to evaluate lots more things(Which has been a blast working with) but could I also use it to set flag/attributes, for example if a random scene taken from a string list had happened I'd like for a flag to be set for something following up later but not directly connected

Ie, get a random string about a raccoon being seen running away, setting a flag for you to find stolen items in the Raccoons stash later if you find the right tree trunk


You could do that in a function, and use eval to call the function. Have the function return something, if only "".


hmm that might work, though still in my infancy of working with making new functions, Also since i'm using it with a little idea i worked on earlier (A list randomly but not repeatedly working) I suppose i could set the flag to be applied if the list no longer has the entry that passed.

-That didn't work, think its time I actually work to learn about functions rather than jury rigging something


An attempt to make a function,
Figured I would simplify my attempt to see if i can get it working in principle, the logic i'm trying to work is to check weather a string list contains a string, if not a flag would be set (The actual string i'm using is much much more complex)

//{color:green: A large  skunk scurries into the bushes} is what i want to check to see if the string list still contains
//player.N1 is the string list
//if its found to contain the string  nothing happens, if not would set the flag.
If  ListContains (player.N1, {color:green: A large  skunk scurries into the bushes}) {
if () {
}
else {
  msg ("test pass Set flag") 
 } 

where am i going wrong?


(filler for getting my edited post updated/posted)
(again, filler for getting my edited post updated/posted)


@ Talon:

You can use Commands with text processor commands, which the Pixie+Jay created a cool 'level up' functionality in their 'level lib' library file, which increases/decreases (sets/re-sets) Attributes as you click on the text processor command's Command-hyperlink. As far as I know, this is the only way to adjust/set/re-set Attributes within a text processor command.

here's Pixie+Jay 'level lib' library file: https://textadventures.co.uk/forum/samples/topic/4057/letting-the-player-set-attributes
(it's really hard to get the syntax correct, took me a long time to figure it out, and I still have to reference this library file to get it right every time I try to do this type of coding, it's not easy. So, ask for help, and I or Pixie or whoever, will help you with it)

You can always use normal scripting to do this type of stuff, and then if you also still want, you can then use the text processor command of the new set/re-set Attribute (through using the normal scripting).


@ Talon:

see if this works ... (the 'CDATA' tags probably aren't needed, and they might cause errors as well, so try removing them if you get errors / if it doesn't work, and see if it then works without the 'cdata' tags)

<game name="example_game">
  <attr name="test_flag" type="boolean">false</attr>
  <attr name="start" type="script">
    <![CDATA[
      example_dynamic_function (player.N1, "{color:green: A large skunk scurries into the bushes}", game, "test_flag", true)
      on ready {
        msg ("testing: is the 'game.test_flag' Attribute's Value = 'true', ???")
        msg ("testing continued: and its value is: " + this.test_flag)
      }
    ]]>
  </attr>
</game>

<object name="player">
  <attr name="N1" type="stringlist">
    <value>
      <![CDATA[
        {color:green: A large skunk scurries into the bushes}
      ]]>
    </value>
    <value>BLAH_1</value>
    <value>BLAH_2</value>
  </attr>
</object>

<function name="example_dynamic_function" parameters="name_of_object_dot_name_of_list_attribute_stringlist_parameter, list_item_check_string_parameter, name_of_object_object_parameter, name_of_attribute_string_parameter, set_value_parameter">
  if (not ListContains (name_of_object_dot_name_of_list_attribute_stringlist_parameter, list_item_check_string_parameter)) {
    set (name_of_object_object_parameter, name_of_attribute_string_parameter, set_value_parameter)
  }
</function>

ask if you need help with how to transfer/use/put this code into your game's code and/or a new game's code, and/or ask if you got any questions about anything, and/or need anything explained, and/or need help with anything.

(let me know if this works or not, if not, we'll see if we can work on figuring out how to get it to work, or maybe Pixie or who-ever will already post a solution and/or inform us that it's not possible to do --- this is unlikely, quest is very powerful)


Your code:

//{color:green: A large  skunk scurries into the bushes} is what i want to check to see if the string list still contains
//player.N1 is the string list
//if its found to contain the string  nothing happens, if not would set the flag.
If  ListContains (player.N1, {color:green: A large  skunk scurries into the bushes}) {
if () {
}
else {
  msg ("test pass Set flag") 
 } 

A slight variation of HK's code (with your stuff plugged in):

This is to be plugged into Code View only, not a text input field. I put it on the room description in this example.

if (ListContains (player.N1, "{color:green: A large  skunk scurries into the bushes}")) {
  msg ("test pass Set flag")
}
else {
  msg ("{color:green: A large  skunk scurries into the bushes}")
  list add (player.N1, "{color:green: A large  skunk scurries into the bushes}")
}

You are in a room.
A large skunk scurries into the bushes

> look
You are in a room.
test pass Set flag

> l
You are in a room.
test pass Set flag


image


Here's the code view of the entire (very small) example game:

<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="n1">
    <gameid>53a13aa2-091c-45e9-b0fe-ce8851db218f</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <description type="script">
      if (ListContains (player.N1, "{color:green: A large  skunk scurries into the bushes}")) {
        msg ("test pass Set flag")
      }
      else {
        msg ("{color:green: A large  skunk scurries into the bushes}")
        list add (player.N1, "{color:green: A large  skunk scurries into the bushes}")
      }
    </description>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
      <N1 type="stringlist" />
    </object>
  </object>
</asl>

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums