Author Topic: Questions on Constants  (Read 527 times)

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Questions on Constants
« on: August 24, 2011, 05:22:00 pm »


               I was wondering if there is a Maximum # of Constants you can use in a module all together?

(I have about 300 so far, didn't want to overload my include & config scripts for this new forge)

Also, I was wondering if I set a constant like (ITEM_PROPERTY_KEEN  /or/  IP_CONST_ABILITY_WIS)  on a PC in a Variable (int) will it return the same value if checked later on through scripting?

Thanks for your help...
               
               

               


                     Modifié par _Guile, 24 août 2011 - 04:22 .
                     
                  


            

Legacy_CID-78

  • Sr. Member
  • ****
  • Posts: 261
  • Karma: +0/-0
Questions on Constants
« Reply #1 on: August 24, 2011, 05:39:52 pm »


               that depends on the compiler, my guess would be no aslong as you got plenty of RAM.

yes a local variable will return what it was set to.
               
               

               
            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Questions on Constants
« Reply #2 on: August 24, 2011, 06:35:44 pm »


               That was my next question CID, would 200+ Constant in an Include effect RAM on a Server?

I mean am I going to see HUGE Spikes in RAM if 10 players decided to Forge (at this moment)..???
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Questions on Constants
« Reply #3 on: August 24, 2011, 06:47:22 pm »


               Lightfoot8 touched on this subject quite a bit awhile back. If I can find the thread I'll post a link.
               
               

               
            

Legacy_CID-78

  • Sr. Member
  • ****
  • Posts: 261
  • Karma: +0/-0
Questions on Constants
« Reply #4 on: August 24, 2011, 07:18:41 pm »


               constants has no effect on a server, when the script has been comiled they are gone. and all your left with is the script size. which effect how much RAM the server needs to keep everything in memory.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Questions on Constants
« Reply #5 on: August 24, 2011, 10:09:46 pm »


               

GhostOfGod wrote...

Lightfoot8 touched on this subject quite a bit awhile back. If I can find the thread I'll post a link.


That was in the thread - I need to test each PC at the finish line (Neverwinter Nights 1 ...



_Guile wrote...

I was wondering if there is a Maximum # of Constants you can use in a module all together?

No there is no limit on the number of constants that can be used in a module.   But there is a limit of the number of constants that can be refferenced in a single script feed to the Standard script compiler. 

Keep in mind that only the compiler has any Idea what the Lable for the constant means.  The compiled only uses the value of the constant.   



 

Also, I was wondering if I set a constant like (ITEM_PROPERTY_KEEN  /or/  IP_CONST_ABILITY_WIS)  on a PC in a Variable (int) will it return the same value if checked later on through scripting?


Not sure what you are asking here.   But if you have:
const int ITEM_PROPERTY_KEEN  = 5;  
and you set the int through scripting to
SetLocalInt( oObject, "var", ITEM_PROPERTY_KEEN );
Then Yes the var on oObject will be equal to 5 untill you change it.   Just Keep In Mind that at Run Time the game has No Idea thet the constant 5 was ever known as ITEM_PROPERTY_KEEN.   

ITEM_PROPERTY_KEEN   Is just a Lable used for the number 5.  When a script is compiled the compiler makes several passes over the script getting it into a state where it can change it into a compiled code.  In one of thies passes it finds all of the instances of ITEM_PROPERTY_KEEN  and replaces it with 5.   at that point the compiler treats it as if you had typed 5 into your code rather then ITEM_PROPERTY_KEEN 
               
               

               


                     Modifié par Lightfoot8, 24 août 2011 - 09:10 .
                     
                  


            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Questions on Constants
« Reply #6 on: August 25, 2011, 09:07:46 pm »


               I found the answer to the second question, yes the constants will be recalled correctly if stored on a variable...

I had a lot of constants in 2 scripts (config & inc) and it didn't kick out any noticeable issues, either through the compiler or while in game, so I'm assuming the number for the max must be very high indeed (for one script that is)...