. . . Posted November 1, 2016 Share Posted November 1, 2016 (edited) Hello, I have a question . So, is it possible to have a simple piece of code that hides the minimap mod's minimap if it's enabled? Because on a certain event I want my character to not be able to use any kind of map & I already have which hides the default map. inst.components.playercontroller:EnableMapControls(false) If anyone knows how that would be great ! Thank you for reading my question have a wonderful day/night !!! Edited November 6, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/71318-how-to-hide-minimap-mods-map/ Share on other sites More sharing options...
Serpens Posted November 1, 2016 Share Posted November 1, 2016 hmm... did you look a beavermode from woodie? I think also the minimap is not working when he is beaver. Link to comment https://forums.kleientertainment.com/forums/topic/71318-how-to-hide-minimap-mods-map/#findComment-831827 Share on other sites More sharing options...
Leonardo Cox Posted November 1, 2016 Share Posted November 1, 2016 You might want to ask the creator of the minimap mod or look through his/her mod's code. Also theres a bit of code that allows you to check if the mod is enabled but I'm not sure what it is. Link to comment https://forums.kleientertainment.com/forums/topic/71318-how-to-hide-minimap-mods-map/#findComment-831844 Share on other sites More sharing options...
. . . Posted November 1, 2016 Author Share Posted November 1, 2016 (edited) Well maybe someone can help me with this because I really doubt the creator of the minimap mod will respond to me ... This's the entire code of the minimap mod in "minimapwidget.lua" Spoiler local Widget = require "widgets/widget" local Image = require "widgets/image" local ImageButton = require "widgets/imagebutton" local MiniMapWidget = Class(Widget, function(self, mapscale) Widget._ctor(self, "MiniMapWidget") self.owner = ThePlayer mapscale = mapscale or 1 self.minimap = TheWorld.minimap.MiniMap self.bg = self:AddChild(Image("images/hud.xml", "map.tex")) self.bg.inst.ImageWidget:SetBlendMode( BLENDMODE.Premultiplied ) self.img = self:AddChild(Image()) self.img.inst.ImageWidget:SetBlendMode( BLENDMODE.Additive ) self:UpdateTexture() local map_w, map_h = self.bg:GetSize() local map_w, map_h = map_w*mapscale, map_h*mapscale self.mapsize = {w=map_w, h=map_h} self.img:SetSize(map_w,map_h,0) self.bg:SetSize(map_w,map_h,0) self.bg:SetTint(1,1,1,0.75) self.bg:SetClickable(false) self.togglebutton = self:AddChild(ImageButton()) self.togglebutton:SetScale(.7,.7,.7) self.togglebutton:SetOnClick( function() self:ToggleOpen() end ) self.togglebutton:Hide() -- ups stuff, needs to be before SetOpen() self.ups = 0 -- 0 if disabled, otherwise delay till next update self.task_ups = nil -- the next update task self:SetOpen( true ) self.mapscreenzoom = 1 self.minimapzoom = 0 self.lastpos = nil self.uvscale = 1 --self.minimap:ResetOffset() self:StartUpdating() self:Show() end) function MiniMapWidget:ToggleOpen() self:SetOpen( not self:IsOpen() ) end function MiniMapWidget:SetOpen( state ) if state == nil then state = true end if state then self.open = true local newbuttonpos = Point(0, -self.mapsize.h/2, 0) self.togglebutton.o_pos = newbuttonpos self.togglebutton:SetPosition(newbuttonpos:Get()) self.togglebutton:SetText("Close Minimap") self.img:Show() self.bg:SetPosition( 0,0,0 ) self.bg:SetSize( self.mapsize.w, self.mapsize.h ) self:EnableMinimapUpdating() else self.open = false local newbuttonpos = Point(0, self.mapsize.h/2 - 20, 0) self.togglebutton.o_pos = newbuttonpos self.togglebutton:SetPosition(newbuttonpos:Get()) self.togglebutton:SetText("Open Minimap") self.img:Hide() self.bg:SetPosition( 0, self.mapsize.h/2 - 20, 0 ) self.bg:SetSize( self.mapsize.w, 5 ) self:DisableMinimapUpdating() end end function MiniMapWidget:IsOpen() return self.open end function MiniMapWidget:OnControl( control, down ) if MiniMapWidget._base.OnControl(self, control, down) then return true end if down and control == CONTROL_MAP_ZOOM_IN then self:OnZoomIn() return true elseif down and control == CONTROL_MAP_ZOOM_OUT then self:OnZoomOut() return true end end function MiniMapWidget:OnGainFocus() self.bg:SetTint(1,1,1,1) -- horrible way to stop camera zooming, but oh well self.camera_controllable_reset = TheCamera:IsControllable() TheCamera:SetControllable(false) if self:IsOpen() then self.togglebutton:Show() end end function MiniMapWidget:OnLoseFocus() self.bg:SetTint(1,1,1,0.75) -- reset to orig value TheCamera:SetControllable(self.camera_controllable_reset) if self:IsOpen() then self.togglebutton:Hide() end end function MiniMapWidget:SetTextureHandle(handle) self.img.inst.ImageWidget:SetTextureHandle( handle ) end function MiniMapWidget:OnZoomIn( ) if self.shown then if self.minimapzoom == 0 then self.uvscale = math.min(1.875, (2.0 + self.uvscale)/2) end self.img:SetUVScale(self.uvscale, self.uvscale) self.minimap:Zoom( -1 ) self.minimapzoom = math.max(0,self.minimapzoom-1) end end function MiniMapWidget:OnZoomOut( ) if self.shown then local dozoom = true if self.minimapzoom == 0 then if self.uvscale - 1 > 0.05 then self.uvscale = math.max(1, 2*self.uvscale - 2) dozoom = false else self.uvscale = 1 end self.img:SetUVScale(self.uvscale, self.uvscale) end if dozoom then self.minimap:Zoom( 1 ) self.minimapzoom = self.minimapzoom+1 end end end function MiniMapWidget:UpdateTexture() local handle = self.minimap:GetTextureHandle() self:SetTextureHandle( handle ) end function MiniMapWidget:OnUpdate(dt) if not self.shown then return end if not self.focus then return end if not self.img.focus then return end if TheInput:IsControlPressed(CONTROL_PRIMARY) then local pos = TheInput:GetScreenPosition() if self.lastpos then local scale = 1/(self.uvscale*self.uvscale) local dx = scale * ( pos.x - self.lastpos.x ) local dy = scale * ( pos.y - self.lastpos.y ) self.minimap:Offset( dx, dy ) end self.lastpos = pos else self.lastpos = nil end end function MiniMapWidget:Offset(dx,dy) self.minimap:Offset(dx,dy) end function MiniMapWidget:OnShow() if self:IsOpen() then self:EnableMinimapUpdating() end self.minimap:Zoom(-1000) self.minimap:Zoom(self.minimapzoom) self.minimap:ResetOffset() end function MiniMapWidget:OnHide() self:DisableMinimapUpdating() self.minimap:Zoom(-1000) self.minimap:Zoom(self.mapscreenzoom) end function MiniMapWidget:ToggleVisibility() if self:IsVisible() then self:Hide() else self:Show() end end function MiniMapWidget:IsMinimapUpdating() if self.ups > 0 then -- ups throttling enabled return self.task_ups ~= nil else -- ups throttling disabled return self.minimap:IsVisible() end end function MiniMapWidget:EnableMinimapUpdating() if self.ups > 0 then -- ups throttling enabled -- need to check this, function is called twice in succession on startup (on creation and when first shown) if self.task_ups ~= nil then self.task_ups:Cancel() self.task_ups = nil end self:ScheduleUpdate() else -- ups throttling disabled if not self.minimap:IsVisible() then self.minimap:ToggleVisibility() end end end function MiniMapWidget:DisableMinimapUpdating() if self.ups > 0 then -- ups throttling enabled if self.task_ups ~= nil then self.task_ups:Cancel() self.task_ups = nil end else -- ups throttling disabled if self.minimap:IsVisible() then self.minimap:ToggleVisibility() end end end -- schedule task starting minimap updating -- assumes ups throttling is enabled function MiniMapWidget:ScheduleUpdate() self.task_ups = self.inst:DoTaskInTime(self.ups, function() if not self.minimap:IsVisible() then self.minimap:ToggleVisibility() end self:StopUpdatingAndReschedule() end) end -- schedule task ending minimap updating -- assumes ups throttling is enabled function MiniMapWidget:StopUpdatingAndReschedule() self.task_ups = self.inst:DoTaskInTime(0, function() if self.minimap:IsVisible() then self.minimap:ToggleVisibility() end self:ScheduleUpdate() end) end function MiniMapWidget:SetUPS(ups) local wasenabled = self:IsMinimapUpdating() self:DisableMinimapUpdating() self.ups = ups if wasenabled then self:EnableMinimapUpdating() end end return MiniMapWidget but what I think might be able to hide the minimap is maybe this but I don't know how to do it? Maybe someone smarter knows ? function MiniMapWidget:ToggleVisibility() if self:IsVisible() then self:Hide() else self:Show() end end Edited November 2, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/71318-how-to-hide-minimap-mods-map/#findComment-832000 Share on other sites More sharing options...
. . . Posted November 2, 2016 Author Share Posted November 2, 2016 (edited) Well I tried something like inst.components.minimapwidget:Hide() inst.components.minimap:ToggleVisibility() but they didn't work, I have no idea what to do ... Edited November 2, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/71318-how-to-hide-minimap-mods-map/#findComment-832319 Share on other sites More sharing options...
. . . Posted November 6, 2016 Author Share Posted November 6, 2016 (edited) Well I guess nobody knows how to do this.. Edited November 6, 2016 by SuperDavid I asked for the impossible ;-; Link to comment https://forums.kleientertainment.com/forums/topic/71318-how-to-hide-minimap-mods-map/#findComment-834089 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now