Zero One
5170       And as we fall the spirit carries on, That a hero'll come and save us all, As we call the ones we left below, We all dream of the day we rise above
Level: 129
   

Posts: 4566/5173
EXP: 24573391 For next: 476263
Since: 05-24-10
From: Delta Quadrant
Since last post: 1.6 years Last activity: 131 days
|
| Posted on 09-14-13 04:25:10 AM (last edited by Zero One at 09-14-13 01:10:01 PM) |
Link | Quote
| |
I'm using LuaInterface to allow me to call Lua scripts in a C# program. I have a Lua script that contains the following code:
teststring = "PRIVMSG #```` : SUCCESS!"
return teststring
and in C#, I'm trying to add the output to a Queue<string> by doing:
sendQueue.Enqueue(lua.DoFile(script)[0].ToString());
The Lua script returns an Object[] and the zeroth index is meant to contain a string. However, the Lua script only ever returns 'nil', instead of teststring. Any one have any ideas as to how I can fix this?
EDIT: Solution found!
var output = lua.DoFile(script).First().ToString();
Console.WriteLine(output);
sendQueue.Enqueue(output);
No idea why it works, just that it does.
____________________ This is a Heisenberg post. I know I posted this really fast, but I don't know where...
My YouTube Channel and Triggernometry Class!
Crossover - The Comic!
My Livestream. Check it! And now, check out my Twitch!
3DS Code: 2879-0110-5138
|
|
|
Sukasa

Level: 123
   
Posts: 4191/4326
EXP: 20936850 For next: 294416
Since: 07-07-07
Since last post: 1.1 years Last activity: 1.1 years
|
|
What does the documentation for First() say?
____________________
| | | |
|
Zero One
5170       And as we fall the spirit carries on, That a hero'll come and save us all, As we call the ones we left below, We all dream of the day we rise above
Level: 129
   

Posts: 4568/5173
EXP: 24573391 For next: 476263
Since: 05-24-10
From: Delta Quadrant
Since last post: 1.6 years Last activity: 131 days
|
|
|