ainslec / adventuron-issue-tracker

Adventuron Issues Tracker
4 stars 0 forks source link

[BUG/FEATURE?] s1_has_trait needs disambiguate_s1 even when s1 is already correct. #427

Closed nww02 closed 3 years ago

nww02 commented 3 years ago

I was just testing s1_has_trait and found that for all intents and purposes the parser knows s1() and gets everything right. However, for some reason s1_has_trait can't "lock on" to the subject unless you run disambiguate_s1() first.

In the following code, you can check to see if the object has the single trait with two commands "AMBIG thing" which will interrogate the thing without disambiguating it first, and "DISAM thing" which will disambiguate it first.. As you can see from the print, the parser knows darn well which object it is (there's only one anyway!), and can print its description just fine... But s1_has_trait() fails unless disambiguate is run first.

image

######################################
#  Adventuron Game File                                       #
######################################

start_at = my_location

locations {

   my_location : location "You are in a room." ;

}

on_command {
   :match "ambig _"
   {
      :set_false "disambiguate";
      :gosub "do_test";
   }
   :match "disam _"
   {
      :set_true "disambiguate";
      :gosub "do_test";
   }

}

subroutines {
   do_test : subroutine {

      :if (disambiguate){
         :disambiguate_s1 category = "universal" ; 
      }
      :if (s1_has_trait "t_1")
      {
         :print {("The '"+d(s1())+"' has the trait.")};
      }
      :else
      {
         :print {("The '"+d(s1())+"' does not have the trait.")};
      }

   }
}

traits {

   t_1 : trait;

}

objects {

   thing : object "trait testing thing"  at = "my_location" traits = "t_1";

}

booleans {
   disambiguate : boolean;
}

If this is "just a thing" that you need to do in order to use s1(), that should probably be documented, but it's curious that everything else seems to work, just not that.

ainslec commented 3 years ago

Press F5 and give it another go.