Jump to content

Mouse error


Slimwaffle
 Share

Recommended Posts

I am trying to design an inventory system using the gui widgets. The mouse locks to crosshair position when it shouldn't. And I was wondering how I fix it. I want to be able to freely move the mouse around and click on buttons. The same way I can in the main menu when I press escape.

<My Code>


function Script:Start()
    
    
    local Inventory={}
    local scale = 1

    --Inventory GUI
    Inventorygui = GUI:Create(context)
    Inventorygui:Hide()
    Inventorygui:SetScale(scale)
    local widget
    
    Inventorygui:GetBase():SetScript("Scripts/GUI/Panel.lua")
    Inventorygui:GetBase():SetObject("backgroundcolor",Vec4(0,0,0,1))
    
    local image = Inventorygui:LoadImage("Bag/bag.tex")
    local imagePanel = Widget:Panel(0,0,1920,1080, Inventorygui:GetBase())
    imagePanel:SetImage(image)
    imagePanel:Redraw()

    Inventory.gui=gui
    Inventory.context = context
    
    --Create a link button
    Inventory.newbutton = Widget:Button("Resume Game",100,Inventorygui:GetBase():GetSize().y/2-60,300,20,Inventorygui:GetBase())
    Inventory.newbutton:SetString("style","Link")
    Inventory.newbutton:SetAlignment(1,0,0,0)

    Inventory.options = Widget:Button("Inventory",100,Inventorygui:GetBase():GetSize().y/2-10,300,20,Inventorygui:GetBase())
    Inventory.options:SetString("style","Link")
    Inventory.options:SetAlignment(1,0,0,0)

    optionspanel = Widget:Panel(Inventorygui:GetBase():GetClientSize().x/2-250,Inventorygui:GetBase():GetClientSize().y/2-300,500,600,Inventorygui:GetBase())
    optionspanel:SetAlignment(0,0,0,0)
    Inventory.optionspanel=optionspanel
    
    indent=8
    
    --Create a panel
    widget = Widget:Tabber(indent,indent,optionspanel:GetClientSize().x-indent*2,optionspanel:GetClientSize().y-indent*2,optionspanel)
    widget:AddItem("Inventory",true)
    optionspanel:SetObject("backgroundcolor",Vec4(0.15,0.15,0.15,1))
    
    Inventory.tabber = widget

    local indent = 12
    panel = Widget:Panel(indent,indent,widget:GetClientSize().x-indent*2,widget:GetClientSize().y-indent*2-30,widget)
    panel:SetBool("border",true)
    
    Inventory.panel={}
    Inventory.panel.general=panel

    Inventory.applyoptions = Widget:Button("Use",widget:GetClientSize().x-72*2-4-indent,widget:GetClientSize().y-28-5,72,28,widget)
    
    local y=20
    local sep=40
    optionspanel:Hide()
end
function Script:UpdateWorld()
if window:KeyHit(Key.I) then
Inventorygui:Show()
Time:Pause()
window:ShowMouse()
end
end

 

Link to comment
Share on other sites

Yeah I tried that by using a variable called pause assigning it a value of 0. Then putting everything inside the update-world function on the fps controller in an if statement (so if paused = 0 it would update). And making the inventory on open pass a value of 1 to stop update. But it did nothing. 

So I went the easy way and just added in an inventory section into the already existing menu script. Because for some reason the menu script already does what I want.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...