variant constants

Blitz3D Forums/Blitz3D Beginners Area/variant constants

Mordunns system is more like binary flags , so looks like this in int form.

Const ITEM_HEAD =  1		; generally caps & helms
Const ITEM_NECK =  2		; generally amulets/necklaces
Const ITEM_BACK =  4		; generally cloaks
Const ITEM_QUVR =  8
Const ITEM_LHAND = 16		; generally shields
Const ITEM_RHAND = 32		; generally weapons
Const ITEM_BHAND = 64		; generally gauntlets & 
const 
gloves
etc..


This flag is basically 2^( Item property ) so that you can store and access multiple properties for each object. You would assign this property to the item rather than item0 = 1, item 1 = 2 , item 2 = 4 etc.. I think you misunderstand it's usage.

So, for example if you have a sword which you can hold in your Left Hand and Right Hand you would set the item property flag to 96 ( 32 + 64 )

When checking which slots this item can be placed ...

Flag = 32+64

if Flag and ITEM_LHAND
  { this item can be held in the left hand }
endif

if Flag and ITEM_RHAND
  { this item can be held in the right hand }
endif


Both conditions will return true so the system knows it can be placed in either slot.

Another example, level ambience :

;level ambience
;time of day
Const LA_DAY = 1
Const LA_NIGHT = 2
;weather
Const LA_MILD = 4
Const LA_SUN = 8
Const LA_RAIN = 16
Const LA_FOG = 32
Const LA_WIND = 64
Const LA_THUNDER = 128


So to set a the ambience to night + raining + thunder ..

global LA_FLAG = LA_NIGHT + LA_RAIN + LA_THUNDER


To access the individual properties ..
If ( LA_FLAG and LA_NIGHT )
   ;turn the lights out
endif

if ( LA_FLAG and LA_RAIN )
   ;make it rain
endif


Not much of an explanation but hopefully it'll help slightly.

Stevie