Skip to content

Commit

Permalink
Added configuration for the interval.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertZenz committed Jan 2, 2016
1 parent 448526c commit 75e199a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ The system can be configured by adding settings to `minetest.conf` file.
# If the system should be active or not, defaults to true.
sneakcam_activate = true

# The interval in which the system runs, in seconds, defaults to 0.066.
sneakcam_interval = 0.066

# The offset by which the viewpoing is lowered, defaults to 1.65.
sneakcam_offset = 1.65

Expand Down
9 changes: 8 additions & 1 deletion mods/sneak_cam/sneakcam.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ sneakcam = {
--- If the system is active/has been activated.
active = false,

--- The interval in which the system updates, defaults to 0.066.
interval = settings.get_number("sneakcam_interval", 0.066),

--- The offset by which the camera is lowered if the player is sneaking.
-- The value is read from the configuration file, the name of the value
-- is sneakcam_offset, defaults to 1.65.
Expand All @@ -55,7 +58,11 @@ end
-- invocations have no effect.
function sneakcam.activate_internal()
if not sneakcam.active then
minetest.register_globalstep(sneakcam.update_player_cams)
scheduler.schedule(
"sneakcam",
sneakcam.interval,
sneakcam.update_player_cams,
scheduler.OVERSHOOT_POLICY_RUN_ONCE)

sneakcam.active = true
end
Expand Down

0 comments on commit 75e199a

Please sign in to comment.