Jump to content

Creating a inventory toggle script (sort of like flashlight on/off)


Defranco
 Share

Recommended Posts

I'm playing around and still learning lua;

 

Am I on the right track in thinking that something along the lines of the below script could be used to toggle open/close an inventory?

 

A player would press the key " i " in game and it would open/close the inventory.

 

 

 

 

--Toggle the inventory on and off

if window:KeyHit(Key.i) then

self.sound.inventory:Play()

if self.inventory:Hidden() then

self.inventory:Show()

else

self.inventory:Hide()

end

end

 

 

-- then, in the function script start area... a sound would play when toggleing the inventory on or off.

 

self.sound.inventory=Sound:Load("Sound/Player/inventory_toggle.wav")

 

 

 

 

-- then at the top for scripts;

 

Script.inventoryon = false --bool "Inventory on"

 

 

 

-- then I would need to define what the inventoryon is? ??? -- this is what im working on now, trying to attach it to my inventory.lua script where it has the dimensions/color, etc.

 

 

self.inventory =

if self.inventoryon==false then

self.inventory:Hide()

end

 

 

 

Let me know if I have the right sort of idea... I'm trying, hehe

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...