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

Add stormworks addon lua #106

Merged
merged 2 commits into from
Jan 4, 2024
Merged

Conversation

Ierdna100
Copy link
Contributor

Added support for Stormworks addon Lua. Contains definition for the server class, custom math class and others. Currently lacking server callbacks due to LuaLS not supporting them.

Related issue: #105

@carsakiller carsakiller added the New Addon Related to adding a new addon label Jan 4, 2024
@carsakiller
Copy link
Collaborator

I was in the process of adding the Stormworks addon API myself about a year ago. Kind of glad I didn't because of the required work to keep it up to date. I have rewritten the addon API definitions about 3 times over the last few years, the API, like the game, is very volatile, I wish you luck with keeping it up to date 🙂.

There is also some basic support for global callbacks using an alias, although not ideal:

---@meta

---@alias stormworks.callbacks.onVehicleSpawn fun(vehicle_id: integer, owner: integer)
---@type stormworks.callbacks.onVehicleSpawn
function onVehicleSpawn(vehicle_id, owner) end

@carsakiller carsakiller merged commit 6bb0fe3 into LuaLS:main Jan 4, 2024
2 checks passed
@Ierdna100
Copy link
Contributor Author

I'll see then about adding callbacks, thanks!

@checkraisefold
Copy link
Contributor

I'll see then about adding callbacks, thanks!

We use aliases for hooks over at RosaServer; you can check out how a full implementation with a lot of callbacks would look like here:
https://github.com/jpxs-intl/RosaServerCore/blob/master/.meta/template/hook_meta.lua

They're also fully typed in our hook adding functions, which gets messy but is actually extremely useful to avoid having to go read our wiki page since the anonymous function w/parameters is just autocompleted by the LSP:
https://github.com/jpxs-intl/RosaServerCore/blob/master/main/plugins.lua#L90
https://github.com/jpxs-intl/RosaServerCore/blob/master/main/hook.lua#L116

This might be a helpful example!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Addon Related to adding a new addon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants