This is where fixed bugs can be seen. Please do not post new bugs into this forum, it is purely to see what has been fixed and most topics will be locked.

sky.setTable Not Working

sky.setTable Not Working

Postby Shando » 04 May 2015, 04:50

Hi All,

I just tried one of my old AI Scenes (that used to work OK) and it failed to run properly.

I tracked the problem down to the "sky.setTable" function, which appears to be broken now.

Regards

Shando
Ryzen 7 4800H 16GB GTX1650 Win 11 64
Love, Hope, Strength http://www.lovehopestrength.co.uk
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: sky.setTable Not Working

Postby SolarPortal » 04 May 2015, 10:06

oh, not good. Will have a check on it in spare moments :)
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: sky.setTable Not Working

Postby SolarPortal » 04 May 2015, 10:52

Just tested this and it seems to be working.
Here is the code i was using.

Microscript 1 - Entity 1:
Code: Select all
myArray = {name="bob",age=83,location="UK"}

obj = 0;
function onInit(objID)
   obj = objID;
   sky.printTable(myArray);
   sky.setTable("tempTable", myArray)
end


Microscript 2 - Entity 2:
Code: Select all
obj = 0;
function onInit(objID)
   obj = objID;
end

function onKeyDown( key )
   if(key=="1")then
      myTable = sky.getTable("tempTable");
      
      sky.printTable(myTable);
      
      sky.lprint("name"..myTable.name);
      sky.lprint("age"..myTable.age);
      sky.lprint("location"..myTable.location);
   end
end


Everything prints as expected, perhaps there is an error in your table :)
I am using a string and integer in the table just to check types.

Q) Does this work for you?
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: sky.setTable Not Working

Postby Shando » 05 May 2015, 04:49

Hi SP,

This is some of my code, which doesn't seem to work:

SceneScript:

Code: Select all
sky.include "blackboard.lua";

obj = 0;
simulationTime = 0;

function onInit(objID)
   -- Set up the Blackboard
sky.lprint ( "SS - 8" );
   bb_Initialise ( );
sky.lprint ( "SS - 9" );

   obj = objID;
   sky.print("Scene Script Active");

   -- Set up Simulation Time Counter
   sky.setVar ( "simtime", simulationTime );
sky.lprint ( "SS - 17" );
end


blackboard.lua:

Code: Select all
local bb = { };

function bb_Initialise ( )
   bb_Clear ( );
end

function bb_Clear ( )
   local tmpBB = { }
   local tblTmp = { id = 0, values = { typ = "Dummy", val = 0 } };

   table.insert ( tmpBB, tblTmp );
sky.printTable ( tmpBB );
   sky.setTable ( "gbb", tmpBB );
sky.lprint ( "116" );
end


microscript:

Code: Select all
sky.include "blackboard.lua";

rayID = 0;

function postInit ( objID )
   local tblTmp = { };

   bb_Set ( objID, "target", tblTmp );
sky.lprint ( "15" );
   bb_Set ( objID, "targetid", -1 );
   bb_Set ( objID, "team", 1 );

   myActions = act_actions ( objID );
   myLogic = decisionTree ( objID );

   aiInit ( objID );
   aiWander ( );
   aiObstacleAvoid ( );

   rayID = physics.createRay ( );
end


The output I get in the console is:

Code: Select all
INFO: UI Document - Loaded
SS - 8


--------------------TABLE CONTENTS-------------------
Table (Top.1) Pairs - Key: id    Value: 0
Table (Top.1.values) Pairs - Key: val    Value: 0
Table (Top.1.values) Pairs - Key: typ    Value: Dummy


15


So, it's printing the initial table from "blackboard.lua", but then not printing the "116" immediately after the "sky.setTable" call?

I'll try your simple code and see if that works for me.

Regards

Shando

EDIT: Your example works correctly for me, so now I'm totally confused, as my code did used to work, and I haven't changed anything??
Last edited by Shando on 05 May 2015, 04:54, edited 1 time in total.
Reason: Added EDIT
Ryzen 7 4800H 16GB GTX1650 Win 11 64
Love, Hope, Strength http://www.lovehopestrength.co.uk
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: sky.setTable Not Working

Postby SolarPortal » 05 May 2015, 09:47

i have had a look and the problem is definitely inside the the "Blackboard.lua" file.

if you pass the "tblTmp" through the print and setTable, it works fine. But passing "tmpBB" stops it from working.
i copied and converted an in lua table printing function from online and it prints this for "tmpBB".

Code: Select all
table: 3CCC0500 {
  [id] => 0
  [values] => table: 3CCC0500 {
                [val] => 0
                [typ] => "Dummy"
              }
}


i also color coded the trace strings for easy viewing. If it works, a text line should go green lol, otherwise all lines are red.

table.insert() creates an index as a key. I think for the settable to work it needs to be a string.
In the print above, you can see the inserted table is placed under [1]. I think this was the limitation of our setTable and printTable.

In the next code example, i have changed "tmpBB" with "tblTmp" in the print, printTable and the setTable. When testing, It should work for you. Changing them back though won't work because of the table.insert();

Code: Select all
local bb = { };

function bb_Initialise ( )
   bb_Clear ( );
end

function bb_Clear ( )
sky.lprint ( "#&127,127,255:BlackBoard Clearing ... storing array..." );
   local tmpBB = { }
   local tblTmp = { id = 0, values = { typ = "Dummy", val = 0 } };
   --local tblTmp = { id = "hello" };

sky.lprint ( "#&255,127,127:table inserting..." );
   table.insert ( tmpBB, tblTmp );
sky.lprint ( "#&255,127,127:printing table" );
   
   print_r(tblTmp);
   
   sky.printTable ( tblTmp );
sky.lprint ( "#&255,127,127:setting table on global" );
   sky.setTable ( "gbb", tblTmp );
sky.lprint ( "#&127,255,127:everything good to go!" );
   
end

function print_r ( t ) 
    local print_r_cache={}
    local function sub_print_r(t,indent)
        if (print_r_cache[tostring(t)]) then
            sky.lprint(indent.."*"..tostring(t))
        else
            print_r_cache[tostring(t)]=true
            if (type(t)=="table") then
                for pos,val in pairs(t) do
                    if (type(val)=="table") then
                        sky.lprint(indent.."["..pos.."] => "..tostring(t).." {")
                        sub_print_r(val,indent..string.rep(" ",string.len(pos)+8))
                        sky.lprint(indent..string.rep(" ",string.len(pos)+6).."}")
                    elseif (type(val)=="string") then
                        sky.lprint(indent.."["..pos..'] => "'..val..'"')
                    else
                        sky.lprint(indent.."["..pos.."] => "..tostring(val))
                    end
                end
            else
                sky.lprint(indent..tostring(t))
            end
        end
    end
    if (type(t)=="table") then
        sky.lprint(tostring(t).." {")
        sub_print_r(t,"  ")
        sky.lprint("}")
    else
        sub_print_r(t,"  ")
    end
    sky.lprint()
end


Perhaps there is a work around for now. :)
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: sky.setTable Not Working

Postby Shando » 05 May 2015, 12:04

Hi SP,

OK, I'll give it a go, and see if I can get it working.

Thanks

Shando
Ryzen 7 4800H 16GB GTX1650 Win 11 64
Love, Hope, Strength http://www.lovehopestrength.co.uk
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer


Return to Fixed Bugs

Who is online

Users browsing this forum: No registered users and 3 guests