Defranco Posted September 7, 2014 Share Posted September 7, 2014 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 Quote Link to comment Share on other sites More sharing options...
nick.ace Posted September 8, 2014 Share Posted September 8, 2014 Nothing wrong with that way that I can see. That's pretty much how I do it at least. Quote Link to comment Share on other sites More sharing options...
Thirsty Panther Posted September 8, 2014 Share Posted September 8, 2014 Check out Aggrors latest LUA tutorials #16 & #17. He goes thru setting up an inventory. Slightly different to yours but the scripts and explanations should be helpful. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.