将Lua函数转换为C#

问题描述 投票:0回答:1

我一直在努力地思考如何创建这个函数调用,我在用Lua编写代码时没有问题,但是我正在将内容转换为C#,以离开Lua并转向新的东西。非常感谢我能提供的任何帮助,我已经附上了有效的Lua代码,并且就我在C#中获得的代码而言,我还对我不知道的部分代码添加了注释。 >

Lua代码:

Progress({
    name = "unique_action_name",
    duration = 1000,
    label = 'Doing Something',
    useWhileDead = true,
    canCancel = true,
    controlDisables = {
        disableMovement = true,
        disableCarMovement = true,
        disableMouse = false,
        disableCombat = true,
    },
    animation = {
        animDict = "missheistdockssetup1clipboard@base",
        anim = "base",
        flags = 49,
    },
    prop = {
        model = "p_amb_clipboard_01",
        bone = 18905,
        coords = { x = 0.10, y = 0.02, z = 0.08 },
        rotation = { x = -80.0, y = 0.0, z = 0.0 },
    },
    propTwo = {
        model = "prop_pencil_01",
        bone = 58866,
        coords = { x = 0.12, y = 0.0, z = 0.001 },
        rotation = { x = -150.0, y = 0.0, z = 0.0 },
    },
}, function(cancelled)
    if not cancelled then
        -- Do Something If Action Wasn't Cancelled
    else
        -- Do Something If Action Was Cancelled
    end
end)

到目前为止,我已经有了C#代码

Progress(new {
    name = "unique_action_name",
    duration = 1000,
    label = "Doing Something",
    useWhileDead = true,
    canCancel = true,
    controlDisables = new {
        disableMovement = true,
        disableCarMovement = true,
        disableMouse = false,
        disableCombat = true,
    },
    animation = new {
        animDict = "missheistdockssetup1clipboard@base",
        anim = "base",
        flags = 49,
    },
    prop = new {
        model = "p_amb_clipboard_01",
        bone = 18905,
        coords = new { x = 0.10, y = 0.02, z = 0.08 },
        rotation = new { x = -80.0, y = 0.0, z = 0.0 },
    },
    propTwo = new {
        model = "prop_pencil_01",
        bone = 58866,
        coords = new { x = 0.12, y = 0.0, z = 0.001 },
        rotation = new { x = -150.0, y = 0.0, z = 0.0 },
    },
}, function(cancelled) { // < This part here is the question that rises for me, no clue how to call this in C#

    if (!cancelled)
        //Do Something If Action Wasn't Cancelled
    else
        // Do Something If Action Was Cancelled
});

我一直在努力地思考如何创建这个函数调用,我在用Lua编写代码时没有问题,但是我正在将内容转换为C#,以离开Lua并转向新的东西。很多...

c# lua
1个回答
0
投票

在上述注释的帮助下解决了,我非常感谢您的所有帮助!

© www.soinside.com 2019 - 2024. All rights reserved.