Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LUA Scripting Language #506

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft

LUA Scripting Language #506

wants to merge 12 commits into from

Conversation

Wincent01
Copy link
Member

This LUA scripting implementation uses the sol header only C++ wrapper for the native LUA libraries.

The API does not follow the original LU scripting themes. Each instance of a script is in its own LUA-State, and has 'self' as a global. There are hooks to all the implemented CppScript methods, as well as a subset of the entity functionallity. Has to be expanded upon.

An admin can use /lua load <path-to-file.lua> to load a LUA file relative to the binary.

This is local work which has been sitting for awhile; thought someone might like to take a look at it.

Examples:

-- test.lua
-- To run: /lua load test.lua
local ENEMY_LOT = 14000
local OFFSET_X = 0
local OFFSET_Y = 5
local OFFSET_Z = 0

function init()
    local enemy = spawn{
        lot=ENEMY_LOT,
        position=self:GetPosition() + Vector3.new(OFFSET_X, OFFSET_Y, OFFSET_Z),
        rotation=self:GetRotation(),
    }

    addCallbackTimer(1, function()
        enemy:SetAIDisabled(true)
    end)

    enemy:SetVar("offsetX", OFFSET_X)
    enemy:SetVar("offsetY", OFFSET_Y)
    enemy:SetVar("offsetZ", OFFSET_Z)
    enemy:SetVar("spawner", self)

    enemy:SetFaction(-1)
    enemy:SetIsImmune(true)
    enemy:SetIsSmashable(false)

    enemy:LoadScript("test2.lua")
end

init()
-- test2.lua
function attackAOE()
    -- TODO!
end

function attack()
    attackAOE()
    
    self:PlayAnimation("attack2")
    self:Serialize()

    addCallbackTimer(10, attack)
end

attack()

This LUA scripting implementation uses the sol header only C++ wrapper for the native LUA libraries.

The API does not follow the original LU scripting. Each instance of a script is in its own LUA-State, and has 'self' as a global. There are hooks to all the implemented CppScript methods, as well as a subset of the entity functionallity. Has to be expanded upon.

This is local work which has been sitting for awhile; thought someone might like to take a look at it.
@Wincent01 Wincent01 added enhancement New feature or request A-scripts Related to dScripts labels Apr 13, 2022
@Wincent01 Wincent01 self-assigned this Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-scripts Related to dScripts enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants