PDA

View Full Version : Sending table from Girder - Strange results



theguywiththefunnyhair
November 27th, 2006, 12:30 PM
Hi,

I've struck a problem that i cant explain and cannot fix. I'm using a function in girder to send a table to NR's Lua environment. I have 2 methods of building the table before sending it but in the end (before sending) they both produce the same result. When i send the tables to NR the tables built using the first method are fine but using the second are a bit screwy.

I have captured these tables in Girder before sending and the there is no problem at all at that end so i think (guess) the problem lies with NR.

the function i use to send the tables is this
local function SendAMG2NRLua(sendto,tosend)
if AMGINFO.location == location then
print("sending ",tosend," to ", sendto)
NetRemote.SetVariable("AMG."..sendto, tosend)
end
end

This code is called twice each time the script runs, once to send the album list and once to send the track list. The main difference between the method that works and the method that doesnt is the function would be repeated faster for the one that deosnt, i was thinking this may be a factor.


I am attaching images of the results i get.

Thanks

Dan

Ben S
November 27th, 2006, 04:18 PM
I'm going to let Rob deal with this one, Dan. Sounds like a potential Lua issue (as you mentioned).

Rob H
November 27th, 2006, 11:35 PM
Are you absolutely sure that the tables are identical?

Can you use table.equal on them to check (this will only work if you have no functions or userdata in the table)?

It's possible that with the second method that NR is still in the middle of processing the first table when it receives the second table's data. I'm not entirely sure what happens when NR gets a second RunLua command while it's already processing one - @Ben, does it queue the second one until the first one has returned?

theguywiththefunnyhair
November 28th, 2006, 01:35 AM
Hi Rob,
Looks like you were right. The tables were not identical, as i said the tables were built by two methods, 1 worked and the other did not. The second method of building the tables involved reading it from a text file, i used

for recs in infofile:lines() do
temptable[recno] = {}
_,_,
temptable[recno].found1,
temptable[recno].found2,
temptable[recno].found3 = string.find(recs,"^(.-)|(.-)|(.-)$")
recno = recno + 1
end
to create

The problem was the lines of the text file finished with \r\n, so it was capturing a control character at the end of the string. It was when NetRemote.SendVariable() sent this character things went a little haywire.

So i changed the search string to
string.find(recs,"^(.-)|(.-)|(.-)%c$")
and now all is well.

Thanks

Dan

Rob H
November 28th, 2006, 02:14 AM
Great, glad to hear it :)