IntToObject
This is just a quick note to mention that I've added:
object IntToObject( int nInt );
and
int ObjectToInt( object oObj );
scripting functions for 1.06.
Technical Info for NWN2. All information in these posts is free to take and distribute.
This is just a quick note to mention that I've added:
object IntToObject( int nInt );
and
int ObjectToInt( object oObj );
scripting functions for 1.06.
10 comments:
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.
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.
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. :)
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);
}
kivinen:
I'll give that idea some more thought. I think it would be worth it.
How I love it !
This is the key to have simple et quick object lists.
creatures groups etc...
thanx for that!
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.
No, the object ID will not be reused by something created down the line after the placeable got destroyed.
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... :)
Badness. :)
Post a Comment