Author Topic: Script won't find gems - what's wrong?  (Read 422 times)

Legacy_Iapetus303

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Script won't find gems - what's wrong?
« on: February 28, 2014, 11:15:17 pm »


               

I'm creating a new crafting system. The idea is you go through a series of menus, selecting what weapon you want to create and what metal to use, etc, and at the end, it spawns the chosen item, adds various properties depending on what material you used, and gives it an appropriate name and description.  The material options all have a "text appears when" condition so you only get that option when you have the right materials in your inventory.


 


This all works as expected.


 


 


However, I decided to an some extra options for cosmetic enhancements.  E.g. if you have a ruby in your inventory, you can choose to give it a ruby-studded hilt, and the description will contain a line saying "The hilt contains a large <name of gem>".


 


But this isn't working, in two ways.


 


Problem 1:


First of all, my scripts for checking that you have the right gem aren't working.


Example:



   Spoiler
   


This was created using the wizard, and is identical to the scripts used for checking if you have (e.g.) an iron bar (apart from the item tag of course).  But when I use it as the "text appears when" condition for a PC speech option, that option doesn't appear.


 


 


Problem 2:


Secondly, I'm using this code to get the name of the gem to add to the description:



sDesc = sDesc + "  The hilt contains a large " + GetName(GetItemPossessedBy(oPC,sGem));

where sDesc is the string I create my descripion from, and sGem is the gem tag.


 


The final description should end up: "This is a <metal> <weapon> created by <player name>.  The hilt contains a large <gem name>.  <default description>."


 


But the gem name gets left blank.  I know that sGem is being correctly read, as when I change the code to add that to the description instead, it works.  (As does my code to check if you sGem is a light gem, and if so add an the appropriatly coloured light property).


 


 


Problem 3:


Not something that doesn't work, rather something I'd like to do if possible but can't see how:


Is it possible to increase the gold value of an item?


(I want to GetGoldPieceValue the gem, and then add that to the value of the item being created).


 


 


 


PS: one final question:


What is the difference between GetItemPossessedBy and HasItem?


Is it just that HasItem is quicker to type?



               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Script won't find gems - what's wrong?
« Reply #1 on: February 28, 2014, 11:32:31 pm »


               The Tag for the standard ruby in nwn is NW_IT_GEM006. nw_it_gem006 is the resref.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Script won't find gems - what's wrong?
« Reply #2 on: March 01, 2014, 03:14:18 am »


               


PS: one final question:


What is the difference between GetItemPossessedBy and HasItem?


Is it just that HasItem is quicker to type?




Yes its just quicker to type (well, not considering the need of that include '<img'> ). Still I suggest to get used to typing the GetItemPossessedBy(oPC,tag)!=OBJECT_INVALID rather as "quick-type" function like this are maybe usefull and its something I was starting with when I learned how to script in nwn, but becomes obsolete and superfluous when you get closer to the identifier limit (number of constant and functions you can have in a single script).



               
               

               
            

Legacy_Iapetus303

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Script won't find gems - what's wrong?
« Reply #3 on: March 02, 2014, 07:29:35 pm »


               


The Tag for the standard ruby in nwn is NW_IT_GEM006. nw_it_gem006 is the resref.




So it's case-sensetive then?  Or is there another difference I'm not seeing?


               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Script won't find gems - what's wrong?
« Reply #4 on: March 02, 2014, 10:22:59 pm »


               

So it's case-sensetive then? 



Yes.