0

I've recently added NLUA support to my application, with the goal of allowing easy editing of functionality. Perhaps a quick explanation.

I'm making a simple game, in the style of DarkSigns and other "hacking" simulators. I wanted to allow for scripting to be used for both myself and my players. I decided to use NLUA to provide this. The base application is written in c# using WPF and caliburn.micro.

SO i have a simulated console which is actually a textbox for input and a listview for the console ouput, I have a command structure that allows for commands to be typed in and run, including the "connect" command to access a (ingame) IP address, this includes a port which is tied to a script. So connecting to 1.2.3.4 port 25 will run the "port25.lua" script.

All that works fine, however i realized that i have no way to direct input into these scripts, any LUA that calls io.read() won't actually wait for input and so fails.

So i'm looking at how to solve this, unfortunalty NLUA documentation seems to be pretty thin on the ground, I'm aware this is made more complex by the fact I'm not using an actual console and just simulating one.

Would what i want even be possible? If so how could I redirect NLUA io.read()to my textbox (if possible) or is there another solution?

Or would moving away from NLUA into another scripting addition be a better solution?

Thanks for your time.

9
  • You can pass parameters to LUA. So you can read the inputs from c# and then pass to LUA. See : lua.org/pil/25.3.html. Commented Dec 9, 2016 at 10:22
  • stackoverflow.com/a/1815193/2858170 Commented Dec 9, 2016 at 10:31
  • Piglet, I'm sorry that doesn't really help. I'm aware of io.read however as i mentioned it doesn't work when using it in the situation i described Commented Dec 9, 2016 at 10:37
  • If you have made custom console, you should not expect that Lua can work with it. Write your own functions in C# to read and write your console and expose them to Lua. Commented Dec 9, 2016 at 11:41
  • 1
    I don't consider using blocking Lua scripts as a good idea. It would be better to call Lua scripts as a short response to some events (for example, when a key was entered by a user). Think in "event-driven" style. Commented Dec 9, 2016 at 16:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.