Liberty Unleashed

Scripting => Script Help => Topic started by: Jancis71 on November 16, 2010, 08:25:09 pm

Title: Need help with object loading script
Post by: Jancis71 on November 16, 2010, 08:25:09 pm
Code: [Select]
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.
Title: Re: Need help with object loading script
Post by: VRocker on November 16, 2010, 08:30:41 pm
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
Title: Re: Need help with object loading script
Post by: Jancis71 on November 17, 2010, 07:11:00 am
Problems is with angle setting.
When I try:
Code: [Select]
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.