Author Topic: GetResRef() Works for Areas?  (Read 464 times)

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
GetResRef() Works for Areas?
« on: September 12, 2011, 09:27:54 pm »


               So according to this: http://www.nwnlexico....getresref.html and the 1.69 updated version of the Lexicon, GetResRef returns a null string if used on area objects. However as a test I used code such as this GetResRef(GetArea(GetFirstPC())), and it did indeed return the resref of the area.

Can someone confirm that either the Lexicon wasn't updated if this was fixed at some point, the Lexicon is wrong about the function not returning area resrefs, or that this function will reliably return the resref of an area?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
GetResRef() Works for Areas?
« Reply #1 on: September 12, 2011, 11:10:43 pm »


               It looks like it returned a ResRef for me.  I however only tested it it SP.   I have no Idea if it would work with a Server.    

I still get a NULL string return for ResRef's of doors.
               
               

               
            

Legacy_Axe_Murderer

  • Full Member
  • ***
  • Posts: 199
  • Karma: +0/-0
GetResRef() Works for Areas?
« Reply #2 on: September 12, 2011, 11:17:40 pm »


               Lex is outdated on that one. For areas it used to return null but Bioware enhanced it to return the actual area resrefs in either 1.67 or 1.69 I forget which.
               
               

               
            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
GetResRef() Works for Areas?
« Reply #3 on: September 12, 2011, 11:23:54 pm »


               Excellent. Thanks Axe - and Lightfoot for the testing as well.
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
GetResRef() Works for Areas?
« Reply #4 on: September 12, 2011, 11:29:45 pm »


               I use that for my treasure maps where once the PC has found treasure in that area, a hidden chest, they can never find it again.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
GetResRef() Works for Areas?
« Reply #5 on: September 13, 2011, 12:06:47 am »


               btw still returns empty string for doors
               
               

               
            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
GetResRef() Works for Areas?
« Reply #6 on: September 13, 2011, 06:25:27 am »


               

ffbj wrote...

I use that for my treasure maps where once the PC has found treasure in that area, a hidden chest, they can never find it again.


One thing I use to love to do is script triggers to give treasure, not letting the PC"s just walk up to chest to take treasure.

This way the PC actually has to go "exploring areas" not relying on their vision or almighty Tab button to highlight stuff.

"You kicked over a dead log and found a hidden dagger!"  ':wizard:'
               
               

               


                     Modifié par _Guile, 13 septembre 2011 - 05:26 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
GetResRef() Works for Areas?
« Reply #7 on: September 14, 2011, 02:34:29 am »


               Well with my treasure map there is no chest unless you have the item. Once you get inside the trigger and use the map it will say something like, treasure located 10 paces in this direction, turning you in that direction. As you get closer, zeroing in on the chest, fewer paces are needed to locate it. Then within 2 meters the chest appears. Usually it takes 3 or 4 activations of the map to find it. If you already found a treasure in that area, the map message is 'your map is dark.' If there is a treasure in that area but you have not found it and have not entered the trigger yet it wil say 'your map flickers then goes dark.' This indicates a buried treasure chest in that area that you have not yet found. Lastly I also put a local on the area Treasure set to 1.  So if you activate the map with no local Treasure on the area you get the map is dark message.  So you won't waste your time looking for hidden treasure
in an area where no such hidden treasure exists.
               
               

               


                     Modifié par ffbj, 14 septembre 2011 - 01:37 .
                     
                  


            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
GetResRef() Works for Areas?
« Reply #8 on: September 14, 2011, 03:22:52 am »


               

ffbj wrote...

Well with my treasure map there is no chest unless you have the item. Once you get inside the trigger and use the map it will say something like, treasure located 10 paces in this direction, turning you in that direction. As you get closer, zeroing in on the chest, fewer paces are needed to locate it. Then within 2 meters the chest appears. Usually it takes 3 or 4 activations of the map to find it. If you already found a treasure in that area, the map message is 'your map is dark.' If there is a treasure in that area but you have not found it and have not entered the trigger yet it wil say 'your map flickers then goes dark.' This indicates a buried treasure chest in that area that you have not yet found. Lastly I also put a local on the area Treasure set to 1.  So if you activate the map with no local Treasure on the area you get the map is dark message.  So you won't waste your time looking for hidden treasure
in an area where no such hidden treasure exists.


Very crafty indeed, me likes.. '<img'>
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
GetResRef() Works for Areas?
« Reply #9 on: September 14, 2011, 10:59:07 am »


               I can confirm that GetResRef works for areas.
I use it for cataloging all my areas in the module.

eg- Loop through areas, and Get the resref  (resrefs are unique at mod Load for areas)
Then I store a Local Object on the module, called  "AREA_"+resref
The object being each area.

This allows me to use a function called


object GetAreaByResref(string sResref)
{
object oMod = GetModule();
return GetLocalObject(oMod,"AREA_"+sResref);
}

GetObjectByTag is not always useful for areas, because they can have duplicate tags.
However, ResRefs are 'required' by toolset to be unique.
Getting an area by resref, can be useful.

It should be noted, this only works for vanilla areas, that were added in toolset.
Areas made via nwnx_Areas will have duplicate resrefs, so they should not be added to the system via the SetLocalObject, as GetByResRef will simply mean that it returns the last duplicate area.