Liberty Unleashed
Scripting => Script Help => Topic started by: Jancis71 on November 16, 2010, 08:25:09 pm
-
function LoadObjects()
{
local a = 1, b = MAX_OBJECTS, text;
while ( a < b )
{
text = ReadIniString( "data/Objects.ini", "Objects", a.tostring() );
if(text)
{
// ID=ModelID PositionX PositionY PositionZ AngleX AngleY AngleZ
local text2, modelid, posx, posy, posz, anglex, angley, anglez;
text2 = split( text, " " );
modelid = text2[0].tointeger();
posx = text2[1].tofloat();
posy = text2[2].tofloat();
posz = text2[3].tofloat();
anglex = text2[4].tofloat();
angley = text2[5].tofloat();
anglez = text2[6].tofloat();
local object;
object = CreateObject( modelid, Vector(posx,posy,posz ) );
object.Angle = Vector( anglex, angley, anglez );
}
a ++;
}
}
I don't know why, but this function isnt working correctly. And server script returns error: 'self' isn't instance of Object.
-
Hmmm, just looked at the code for this in the server. It will say 'self' is not an instance of Object when the pointer to object is invalid, which means the CreateObject failed.
Not sure why it would fail with those params though, even if its an invalid model it should still return a pointer.
Try CreateObject( modelid, posx, posy, posz ); see if that helps
-
Problems is with angle setting.
When I try:
function LoadObjects()
{
local a = 1, b = MAX_OBJECTS, text;
while ( a < b )
{
text = ReadIniString( "data/Objects.ini", "Objects", a.tostring() );
if(text)
{
// ID=ModelID PositionX PositionY PositionZ AngleX AngleY AngleZ
local text2, modelid, posx, posy, posz, anglex, angley, anglez;
text2 = split( text, " " );
modelid = text2[0].tointeger();
posx = text2[1].tofloat();
posy = text2[2].tofloat();
posz = text2[3].tofloat();
anglex = text2[4].tofloat();
angley = text2[5].tofloat();
anglez = text2[6].tofloat();
CreateObject( modelid, Vector(posx,posy,posz ) );
a.Angle = Vector( anglex, angley, anglez );
}
a ++;
}
}
it still fails with error: trying to set 'integer' in a.Angle line
looks like scripting related bug. Script creates object in position, with 0 angle and don't load any other functions after this.