Community Forum

getChildAt - Bug?

Forum Overview >> Scripting

Created09.11.2012 21:39

Rafft Nix (Unknown) 09.11.2012 21:59

I think I found a bug of the getChildAt function.

This is my sourceCode:

local root = Utils.loadSharedI3DFile(filename, g_modsDirectory.."/Modname/");

for a=1, getNumOfChildren(root) do
local nodeId = getChildAt(root, a-1);

This works six times, but if a = 7, this error report is in the log file:
Error: getChildAt index out of range

I tried many different versions of it, with other i3d files and different loops, but it did not work. Of cause I made sure that there are more than seven transform groups and the i3d file is successfully loaded.

Has someone an idea why this doesnt work seven times?

sincerely, rafftnix

Marcus H (Xentro) 10.11.2012 10:14
I did test this and its working just fine for me.

I used this when testing
local root = Utils.loadSharedI3DFile("hall01.i3d", g_modsDirectory.."/placeableHalls/");
print("getNumOfChildren: " .. getNumOfChildren(root));
for a = 1, getNumOfChildren(root) do
local nodeId = getChildAt(root, a - 1);
print("nodeName: " .. getName(nodeId) .. " " .. a)

C:/Users/Marcus/Documents/My Games/FarmingSimulator2013/mods/placeableHalls/hall01.i3d (0.40mb in 9.31 ms)
getNumOfChildren: 21
nodeName: hall01 1
nodeName: transform 2
nodeName: transform 3
nodeName: transform 4
nodeName: transform 5
nodeName: transform 6
nodeName: transform 7
nodeName: transform 8
nodeName: transform 9
nodeName: transform 10
nodeName: transform 11
nodeName: transform 12
nodeName: hall01 13
nodeName: hall01 14
nodeName: hall01 15
nodeName: hall01 16
nodeName: hall01 17
nodeName: hall01 18
nodeName: camera 19
nodeName: camera 20
nodeName: hall01 21

but once I changed a-1 to 22 then I got this error
Error: getChildAt index out of range
but the error in it self is pretty obvious.

Just thought I share what I did and maybe you get some hints from it.. who knows.

Rafft Nix (Unknown) 18.11.2012 11:29
Thank you. I found the problem myself, there was something wrong with the i3d files I used.

Note: Log in to post. Create a new account here.