Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Auto committed Oct 14, 2023
1 parent 3eca33e commit 9cd1bdf
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 10 deletions.
73 changes: 69 additions & 4 deletions docs/game_data/spel2.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/src/includes/_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -2623,8 +2623,8 @@ Type | Name | Description
---- | ---- | -----------
float | [x](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=x) |
float | [y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=y) |
array<float, 38> | [left_channel](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=left_channel) |
array<float, 38> | [right_channel](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=right_channel) |
array<float, 38> | [left_channel](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=left_channel) | Use [VANILLA_SOUND_PARAM](#VANILLA_SOUND_PARAM) as index, warning: special case with first index at 0, loop using pairs will get you all results but the key/index will be wrong, ipairs will have correct key/index but will skip the first element
array<float, 38> | [right_channel](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=right_channel) | Use [VANILLA_SOUND_PARAM](#VANILLA_SOUND_PARAM) as index warning: special case with first index at 0, loop using pairs will get you all results but the key/index will be wrong, ipairs will have correct key/index but will skip the first element
bool | [start_over](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=start_over) | when false, current track starts from the beginning, is immediately set back to true
bool | [playing](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=playing) | set to false to turn off

Expand Down
11 changes: 7 additions & 4 deletions src/game_api/script/usertypes/sound_lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,21 @@ void register_usertypes(sol::state& lua, SoundManager* sound_manager)
"set_parameter",
&PlayingSound::set_parameter);

auto left_channel = sol::property([&lua](SoundMeta* sm)
{ return ZeroIndexArray<float>(sm->left_channel); });
auto right_channel = sol::property([](SoundMeta* sm)
{ return ZeroIndexArray<float>(sm->right_channel); });

lua.new_usertype<SoundMeta>(
"SoundMeta",
"x",
&SoundMeta::x,
"y",
&SoundMeta::y,
"left_channel",
sol::property([&lua](SoundMeta* sm) // -> std::array<float, 38>
{ return ZeroIndexArray<float>(sm->left_channel) /**/; }),
left_channel,
"right_channel",
sol::property([](SoundMeta* sm) // -> std::array<float, 38>
{ return ZeroIndexArray<float>(sm->right_channel) /**/; }),
right_channel,
"start_over",
&SoundMeta::start_over,
"playing",
Expand Down

0 comments on commit 9cd1bdf

Please sign in to comment.