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

hud_get_flags and hud_set_flags #78

Merged
merged 1 commit into from
Apr 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ function Player:do_reset()
self._inv = InvRef()
self._inv:set_size("main", 32)
self._object:set_properties(table.copy(default_player_properties))
self._hud_flags = { hotbar = true, healthbar = true, crosshair = true,
wielditem = true, breathbar = true, minimap = false, minimap_radar = false }
end

--
Expand Down Expand Up @@ -469,6 +471,15 @@ function Player:get_inventory_formspec() return "" end
function Player:set_formspec_prepend(formspec) end
function Player:get_formspec_prepend(formspec) return "" end

function Player:hud_get_flags() return self._hud_flags end
function Player:set_hud_flags(new_flags)
for flag, value in pairs(new_flags) do
if nil ~= self._hud_flags[flag] then
self._hud_flags[flag] = not not value
end
end
end

function Player:__index(key)
local result = rawget(Player, key)
if not result then
Expand Down