Search the Community
Showing results for tags 'Project saturn'.
-
Removing items from Inventory after Use (Project Saturn scripts)
intog posted a topic in Programming
Hi everyone, I'm new here and somewhat new to programming (other than Actionscript 8 years ago and OpenSCAD modeling recently) I followed through Jorn's Project Saturn videos and now I'm wondering how I can finish the inventory scripts on my own. Jorn left off with an open function for using the item, but didn't go into how to remove the item after it's used. I'm guessing I need to remove that item's table from the inventory table but am a little lost on doing that and also since there are 3 scripts working together for the inventory, I'm not sure where this function would reside. Here is my bottle.lua script that I modified slightly to make it reusable for other items: Edit: Nevermind I fixed it on my own by adding a new variable to the table using the code in red: --this was the Bottle.lua script-- Script.InvIcon = "" -- path "Icon" "Tex file (*tex) :tex" Script.collectOnce = true -- bool "Collect once?" Script.reuseItem = true -- bool "Reuse Item?" Script.itemName = "Item" --string "Item Name" Script.useOnce = true -- bool "Use Once?" function Script:Use(player) -- allows hand use local playerInventory = player.script:GetInventory() -- reference player inventory if playerInventory == nil then error("no inventory") end System:Print("we got inventory") if not playerInventory:IsFull() then -- if inventory is NOT full, then: System:Print("we place the " ..self.itemName.. " into the inventory") local item = self:CreateInventoryItem() playerInventory:AddItemToInventory(item) if self.collectOnce then self.entity:Release() end end end function Script:CreateInventoryItem() item = InventoryItem:Create() item.name = self.itemName item.texture = Texture:Load(self.InvIcon) item.useOnce = self.useOnce item.UseInventoryItem = function() System:Print("You used the " .. self.itemName .. "!") end return item end Then I updated the use function in Inventory.lua (from the videos): if self.items.useOnce then self.items = nil end Thanks for your help! -
Terrain tutorials There are 2 new video tutorials on how to use the terrain editor. Sculpting terrain: Terrain painting: Tutorials: Project Saturn It has been a while since I made a tutorial for Project Saturn, but that will change in the near future. Since there are so many new members using Leadwerks I am going to make some free time for some new tutorials. In the past 3 months there were only a handful of viewers and that didn't quite way up to time spend on making the tutorials. That said I also upgraded from a parttime to a full time job which obviously really cuts in to my Game dev time. The first new video tutorials are already here: 21: 22: 23: Lua beginner tutorials I am also going to make some tutorials for the absolute beginners. For those that have very little to no experience, theses lessons should be very useful. Although these are Lua tutorials in general, they will be aimed towards usage in Leadwerks. FlowGUI I took the plunge in to selling my own Lua GUI library for Leadwerks: FlowGUI. Selling scripts/code for Leadwerks is something I wanted to do for years but I never really had the guts to actually try it. Now that I have made an initial release via webdownload, I am glad I did. I am happy with the amount of licenses sold so far, which makes it also a lot more fun to work on upcoming features such as inventories. I also hope that by providing extra downloadable content for Leadwerks, we will attract more people, were Leadwerks on itself will only benefit from. Last but not least it might also inspire other developers/artists to start selling their own work as well. Maybe when payed items are added to the workshop, this will really kick off. Jorn 'Aggror'
- 2 comments
-
- 9
-
- Project saturn
- tutorials
-
(and 2 more)
Tagged with: