Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
minetest_game
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
minetest_game
Commits
08c60cfc
Commit
08c60cfc
authored
7 years ago
by
paramat
Committed by
paramat
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Binoculars: Only set property if necessary to reduce mesh reloading
parent
9596d00a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mods/binoculars/init.lua
+12
-8
12 additions, 8 deletions
mods/binoculars/init.lua
with
12 additions
and
8 deletions
mods/binoculars/init.lua
+
12
−
8
View file @
08c60cfc
...
...
@@ -3,7 +3,12 @@
binoculars
=
{}
-- Cache creative mode setting
-- Detect creative mod
local
creative_mod
=
minetest
.
get_modpath
(
"creative"
)
-- Cache creative mode setting as fallback if creative mod not present
local
creative_mode_cache
=
minetest
.
settings
:
get_bool
(
"creative_mode"
)
...
...
@@ -13,14 +18,13 @@ local creative_mode_cache = minetest.settings:get_bool("creative_mode")
function
binoculars
.
update_player_property
(
player
)
local
creative_enabled
=
(
creative
and
creative
.
is_enabled_for
(
player
:
get_player_name
()))
or
(
creative
_mod
and
creative
.
is_enabled_for
(
player
:
get_player_name
()))
or
creative_mode_cache
if
creative_enabled
or
player
:
get_inventory
():
contains_item
(
"main"
,
"binoculars:binoculars"
)
then
player
:
set_properties
({
can_zoom
=
true
})
else
player
:
set_properties
({
can_zoom
=
false
})
-- Only set property if necessary to avoid player mesh reload
local
new_can_zoom
=
creative_enabled
or
player
:
get_inventory
():
contains_item
(
"main"
,
"binoculars:binoculars"
)
if
player
:
get_properties
().
can_zoom
~=
new_can_zoom
then
player
:
set_properties
({
can_zoom
=
new_can_zoom
})
end
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment