Page 1 of 1

bug in parameters?

Posted: Thu Apr 19, 2007 4:01 pm
by zandor70
I have a very strange problem:

I have a script:

Code: Select all

	  loc := TargetCoordinates(who);
      print("x trasmitted="+loc.x); //DEBUG
      npc := CreateNpcTemplate(template, loc.x, loc.y, loc.z, who.realm, Struct { "facing" := who.facing } );
And a function:

Code: Select all

function CreateNpcTemplate(template, x, y, z, realm := _DEFAULT_REALM, props := 0, cprops := 0)
  print("x received="+x); //DEBUG
I have tryed to change name function.

Now this is strange error shown from output of the 2 print:

Code: Select all

x trasmitted=5576
x received=struct{ objtype = 0, realm = "britannia", x = 5576, y = 1253, z = 0 }
It is a VERY strange problem... I pass Cint, loc.x but function receive entire loc struct.... why? How is this possibile?

I have tryed to read also template, y, z and the other parameters... error is only on x parameter....

Only if I use as function:

Code: Select all

function CreateNpcTemplate(template, x, y, z, realm := _DEFAULT_REALM, props := 0, cprops := 0)
  if (x.x)
    x := x.x;
  endif
  print("x received="+x); //DEBUG
then "x_received" is ok....

I have tryed with polcore 097 RC2 RC2.1 and RC3

I have done this try:
Modified function:

Code: Select all

function CreateNpcTemplate(template, temp, x, y, z, realm := _DEFAULT_REALM, props := 0, cprops := 0)
  print("temp received="+temp); //DEBUG
  print("x received="+x); //DEBUG
And function:

Code: Select all

	  loc := TargetCoordinates(who);
      //print("x trasmitted="+loc.x); //DEBUG
      npc := CreateNpcTemplate(template, loc.x, loc.x, loc.y, loc.z, who.realm, Struct { "facing" := who.facing } );
And now print() output is:

Code: Select all

temp received=struct{ objtype = 0, realm = "britannia", x = 5576, y = 1250, z =
0 }
x received=5576
so it is not a x member TargetCoordinates() related problem, but it seem a problem in a specific number of parameter:
the second parameter always report enture struct: first parameter see loc.x like "loc", while second parameter see "loc.x" like "loc.x"

Now I have tryed:

Code: Select all

function CreateNpcTemplate(x, template, y, z, realm := _DEFAULT_REALM, props := 0, cprops := 0)
  print("x received="+x); //DEBUG

	  loc := TargetCoordinates(who);
      print("x trasmitted="+loc.x); //DEBUG
      npc := CreateNpcTemplate(loc.x, template, loc.y, loc.z, who.realm, Struct { "facing" := who.facing } );
And print report is now:

Code: Select all

x trasmitted=5575
x received=<uninitialized object>
Please reply me why I an thinking to be crazy....

Posted: Sat Apr 21, 2007 4:25 am
by MuadDib
First off, calling line builds the struct incorrectly. Look into fixing that first and see if it still does it.