Expose structs to Lua and write Lua type annotations #28

Merged
SeanOMik merged 15 commits from feat/lua-type-defs into main 2024-10-19 15:17:00 +00:00
3 changed files with 5 additions and 21 deletions
Showing only changes of commit 77ec620adb - Show all commits

View File

@ -16,33 +16,26 @@ pub const ACTLBL_LOOK_ROLL: &str = "LookRoll";
#[derive(Clone, Component, Reflect)]
pub struct FreeFlyCamera {
pub speed: f32,
pub modifier_speed_factor: f32,
pub look_speed: f32,
pub mouse_sensitivity: f32,
pub look_with_keys: bool,
}
impl Default for FreeFlyCamera {
fn default() -> Self {
Self {
speed: 4.0,
modifier_speed_factor: 0.25,
look_speed: 0.5,
mouse_sensitivity: 0.9,
look_with_keys: false,
}
}
}
impl FreeFlyCamera {
#[allow(dead_code)]
pub fn new(speed: f32, modifier_speed_factor: f32, look_speed: f32, mouse_sensitivity: f32, look_with_keys: bool) -> Self {
pub fn new(speed: f32, look_speed: f32, mouse_sensitivity: f32) -> Self {
Self {
speed,
modifier_speed_factor,
look_speed,
mouse_sensitivity,
look_with_keys,
}
}
}

View File

@ -5,20 +5,13 @@ FreeFlyCamera = {
---Movement speed of the camera.
---@type number
speed = nil,
---The modifier speed factor.
---
---This isn't currently used, but it would be a factor applied to `speed`
---when the modifer key is pressed. For example: a slow or sprint mode.
---
---@type number
modifier_speed_factor = nil,
---The speed that the camera rotates, i.e., looks.
---The speed of the camera rotation.
---@type number
look_speed = nil,
---The sensitivity of the mouse when looking.
---
---This is additional to `look_speed`, but onyl applied to mouse movement.
---
---@type number
mouse_sensitivity = nil,
---Enable looking with arrow keys
---@type boolean
look_with_keys = nil,
}

View File

@ -9,9 +9,7 @@ to_lua_convert!(
reflect=component,
fields={
speed: f32,
modifier_speed_factor: f32,
look_speed: f32,
mouse_sensitivity: f32,
look_with_keys: bool,
}
);