Author Topic: Need help with object loading script  (Read 1961 times)

Jancis71

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Need help with object loading script
« 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.

VRocker

  • Liberty Unleashed Developer
  • Administrator
  • Full Member
  • ******
  • Posts: 342
  • Karma: +43/-15
    • View Profile
    • Madnight Software
Re: Need help with object loading script
« Reply #1 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


Jancis71

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Need help with object loading script
« Reply #2 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.
« Last Edit: November 17, 2010, 03:19:13 pm by Jancis71 »

 

© Liberty Unleashed Team.