Questions tagged [moonsharp]

A Lua interpreter written entirely in C# for the .NET, Mono and Unity platforms.

17 questions
5
votes
1 answer

Passing a C# object into a lua function with moonsharp.

I'm having issues using Moonsharp in Unity3d. I'm trying to pass 'AppletMessage' objects: [MoonSharpUserData] public class AppletMessage { public string Name; public string[] Args; public AppletMessage(string _name, string[] _args) { …
T--
  • 53
  • 6
3
votes
1 answer

How to call & await async C# method from Lua / MoonSharp script?

I would like to call & await a C# async method from Lua / MoonSharp code. For example: 1). async void Test1() { await Something(); } 2). async Task Test2() { await Something(); } And then calling it from Lua - 1). does not await but…
badevilerror
  • 113
  • 6
2
votes
1 answer

Accessing data found in another object/script

In Tabletop Simulator, how can I exchange information between objects? Is there a way, for example, to create a global variable?
ikegami
  • 367,544
  • 15
  • 269
  • 518
2
votes
1 answer

Use object returned by Lua script

I have this lua script inside "Conversion.lua" file: local conversion = {} function conversion.mmToin( value ) return value * 0.0393701 end return conversion I need to use the function mmToin in C# code, contained inside the object…
S.Orioli
  • 443
  • 6
  • 21
2
votes
1 answer

Accessing a struct using MoonSharp Lua

I am having problems changing members of a struct, which is a member of a class via the Lua interpreter MoonSharp. My current test setup looks something like this: class VectorClass { public float X; public float Y; public Vector2(float…
2
votes
2 answers

How can I use MoonSharp to load a lua table?

After looking through various Lua interpreters for C#, it seems that only one is truly pure c# - MoonSharp. LuaInterpreter (defunct from 2009) which later became NLua depends on one of two other c# librariers KeraLua or another lib, and requires a…
Kraang Prime
  • 9,981
  • 10
  • 58
  • 124
2
votes
0 answers

Can Roslyn execute complex scripts?

We have a scenario where using a scripting language will enable us to avoid coding too many client-specific custom features in our software. We've identified an area where scripting might be helpful: Data Import: Here a file (text file, excel,…
Ivan-Mark Debono
  • 15,500
  • 29
  • 132
  • 263
1
vote
0 answers

How to call & await async C# method from Lua / MoonSharp script with arguments?

There is a pretty similar question asked here: How to call & await async C# method from Lua / MoonSharp script? But this doesn't account for arguments. I want this for example to run: private async Task GetNicknameAsync(ulong id) { …
Berry
  • 23
  • 7
1
vote
2 answers

How to use setmetatable to create a Lua wrapper class around a C# object

I'm creating some UI for a game I'm currently working on in C#, and want to expose everything down to Lua so that my artist can make small tweaks without needing to do anything in code. I'm using MoonSharp for integrating Lua scripts into my…
1
vote
1 answer

Looping a C# dictionary in Lua with MoonSharp

I would like to iterate through something like this: public readonly IDictionary Entities = new Dictionary(); In Lua, whilst using MoonSharp. From the docs, it appears that MoonSharp handles automatic conversion to a table…
Bab
  • 21
  • 2
1
vote
1 answer

Moonsharp pairs(...) raises exception "bad argument #1 to 'next' (table expected, got string)"

I don't get the point why this is happening. I am using Moonsharp to run LUA scripts in my application an I created a LUA function IN(v, ...) and I'd like to itterate over the ... parameter with pairs. IN('param1', 'param2', 'param1') -- expected…
greg-e
  • 374
  • 4
  • 18
1
vote
2 answers

Lua: Concise expression of table scope

I'm working on a game where a bunch of characters will be generated on the fly, based on some constraints defined either in the project or externally via mod files. I am using MoonSharp Lua (5.2) interpreter for interfacing with my C# code, and Lua…
TaylanK
  • 13
  • 3
0
votes
0 answers

How do I get a list of syntax errors from a Lua script using MoonSharp

I am trying to get a list of all the syntax errors in a Lua script, using MoonSharp. I have the following code, where the variable code is the Lua script: try { Script.RunString(code); return ""; } catch (SyntaxErrorException ex) { return…
EchoDevG
  • 3
  • 3
0
votes
1 answer

Is there a way to add time to a Wait class inside an If statement?

I started learning LUA a few days ago, started my own project inside Tabletop Simulator game, but I've hit a brick wall. I can't add time to a Wait class. This is an example of what I tried: function state_check() --This function checks if the…
0
votes
1 answer

lua error ends c# function and parent function execution

When i try to execute faulty lua code it does not only crash but completely ends the function execution that started the lua script. Some notes to read the following code: prs() is Debug.Log(). prs("script finished"); is never called. The Issue…
Codani
  • 13
  • 5
1
2