Friday, March 2, 2007


This is just a quick note to mention that I've added:
object IntToObject( int nInt );


int ObjectToInt( object oObj );

scripting functions for 1.06.


Senalaya said...

Hello Rich,

while you are at it, what about an StringToObj()?
There is already the ObjectToString() function for the other direction and being able to revert that is quite a nice feature for the NWNX folks, to reference back to runtime objects from SQL data.

abraxas77 said...

If I've been following everything correctly, that won't really be necessary. Patch 1.05's NWNx4 hooks should allow you to pass native types like integer and float.

Rich Taylor said...

I'll toss in a StringToObject(). It'll only take a sec to put in anyway. Only makes sense to be able to convert between the various native types when possible. :)

kivinen said...

How about adding IntToBinaryString, FloatToBinaryString, BinaryStringToInt, BinaryStringToFloat functions also, i.e. functions that would encode / decode int / float as 4 bytes of binary string.

That would be useful when emulating arrays i.e. making int array using:

int GetIntArrayItem(string sArray, int nIndex)
return BinaryStringToInt(GetSubString(sArray, nIndex * 4, 4));

string SetIntArrayItem(string sArray, int nIndex, int nValue)
return GetStringLeft(sArray, nIndex * 4) + IntToBinaryString(nValue) + GetSubString(sArray, nIndex * 4 + 4, -1);

Rich Taylor said...

I'll give that idea some more thought. I think it would be worth it.

Anonymous said...

How I love it !
This is the key to have simple et quick object lists.

creatures groups etc...

thanx for that!

Grinning Fool said...

Re: IntToObject/ObjectToInt: can object ids be reused in a session? Let's say I crate a placeable that's assigned object id 1001; if I destroy it, can 1001 be used again?

Re: *ToBinary... that would be very useful for implementing pseudo-arrays in a reasonably efficient manner.

Rich Taylor said...

No, the object ID will not be reused by something created down the line after the placeable got destroyed.

Grinning Fool said...

Cool -- though now I'm perversely curious as to what happens if I make a mod that creates and destroys 2,147,483,648 objects in a single session... :)

Rich Taylor said...

Badness. :)