armylad2011 Posted March 11, 2015 Share Posted March 11, 2015 can someone please help me i made a inventory for my game but when you place items in the inventory the image does not show i have gone over and over cant cant find the error. can anyone do me a working inventory script please :-) would appreciate it. 1 Quote Link to comment Share on other sites More sharing options...
Genebris Posted March 12, 2015 Share Posted March 12, 2015 Make a table and write your items in it like this: self.inventory[#self.inventory+1]={} self.inventory[#self.inventory].name="Sword" self.inventory[#self.inventory].amount=3 This will add 3 swords into your inventory. Then in PostRender you check if inventory menu is opened, and if it is you loop through inventory and draw items icons: for i=1, #self.inventory do context:DrawImage(Texture:Load("folderWithIcons/"..self.inventory[i].name), 100, 100+i*50) context:DrawText(self.inventory[i].amount, 120, 100+i*50) end Quote Link to comment Share on other sites More sharing options...
armylad2011 Posted March 12, 2015 Author Share Posted March 12, 2015 hi there thanx for the script but i have tried to sort mine out lol i have restarted it all again when im on the final bit putting the item into my inventory nothing happens. i have looked in the output and it says "we got the inventory Item B we place the bottle in the inventory bottle Loading shader "E:/leadwerks/MyGame/Shaders/Model/default.shader..... process complete." Quote Link to comment Share on other sites More sharing options...
Thirsty Panther Posted March 12, 2015 Share Posted March 12, 2015 Are you using Aggrors scripts from his video? If not this may help. Maybe post your script so we can have a look. Quote Link to comment Share on other sites More sharing options...
armylad2011 Posted March 12, 2015 Author Share Posted March 12, 2015 yh im using same one Quote Link to comment Share on other sites More sharing options...
armylad2011 Posted March 12, 2015 Author Share Posted March 12, 2015 here are my scripts Quote Link to comment Share on other sites More sharing options...
Jazz Posted March 13, 2015 Share Posted March 13, 2015 In function AddItemToInventory you forgot self.items=item before the return. Quote --- Scott Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060 Link to comment Share on other sites More sharing options...
Thirsty Panther Posted March 13, 2015 Share Posted March 13, 2015 Aggror has all the scripts he uses for project Saturn on his website. Saves time on typos. http://www.aggror.com Quote Link to comment Share on other sites More sharing options...
armylad2011 Posted March 13, 2015 Author Share Posted March 13, 2015 i just added the self.items before the return and still the same lol i also downloaded the script and used that so i know they wouldn't be any typo but for some reason its not drawing my bottle icon ? im finding it hard as im not used to Lua or c++ in the past i used a built in interface GML i think it was called it was set out different to what im used to so finding errors is abit difficult for me lol sorry to be a big pain for you guys lol Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 13, 2015 Share Posted March 13, 2015 Replace the PostRender function with the script below. Tell us what the output is and whether your see something on screen. function Script:PostRender(context) for i = 1, self.itemSlots, 1 do context:SetColor(1,1,1) local x = self.screenWidth - self.itemSize.x local y = (i * self.itemSize.y) + (i * self.offset) context:DrawRect(x,y, self.itemSize.x, self.itemSize.y) local currentItem = self.items if currentItem ~= nil and currentItem.texture ~= nil then System:Print("going to draw a texture. i="..i..) context:SetBlendMode(Blend.Alpha) context:DrawImage(currentItem.texture, 0, 40 * i, 40, 40) context:SetBlendMode(Blend.Solid) end end end Quote Link to comment Share on other sites More sharing options...
armylad2011 Posted March 13, 2015 Author Share Posted March 13, 2015 in the system:print i have a error where you have ..1..) unexpected symbol as in the picture i sent and then in second picture i removed the symbol and got this reading from the output shown in the picture below Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 13, 2015 Share Posted March 13, 2015 and are the inventory items drawn on the screen once you picked something up? Quote Link to comment Share on other sites More sharing options...
armylad2011 Posted March 13, 2015 Author Share Posted March 13, 2015 no just the 4 white boxes Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 13, 2015 Share Posted March 13, 2015 Can you post an ingame screenshot? It looks like the textures are missing, but I wonder why it isn't causing errors. Can you do a quick test by putting this line right after the PostRender function (assuming the location of the texture is correct): context:DrawImage(Texture:Load("Materials/items/bottleicon.tex", 0,0, 100, 100) Quote Link to comment Share on other sites More sharing options...
armylad2011 Posted March 13, 2015 Author Share Posted March 13, 2015 iput theline of code in but not sureif i have it in the right place this error came up in the first picture in the second picture i removed thatcode and done a in gameplay screen shot Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 13, 2015 Share Posted March 13, 2015 The position and scale needs to be added: context:DrawImage(Texture:Load("Materials/items/bottleicon.tex"), 0,0, 100, 100) Quote Link to comment Share on other sites More sharing options...
armylad2011 Posted March 13, 2015 Author Share Posted March 13, 2015 this error came up Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 13, 2015 Share Posted March 13, 2015 Have you looked in the command reference? http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/texture/textureload-r341 You are missing a ')' after the texture path. Quote Link to comment Share on other sites More sharing options...
armylad2011 Posted March 13, 2015 Author Share Posted March 13, 2015 yes i have a picture drawn haha what do i do now ? its in the top left it already draws it when you start the game i also was putting ")" when you said but it was saying error soio kept starting the game and it finally came on so i there a glitch in the system ? Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 13, 2015 Share Posted March 13, 2015 It was a simple test to check if the texture location was correct, and yes is was supposed to be drawn there. Lets try out severall drawImage commands. Replace the if statement with the following: if currentItem ~= nil and currentItem.texture ~= nil then context:SetBlendMode(Blend.Alpha) context:DrawImage(Texture:Load("Materials/items/bottleicon.tex"), x, y, self.itemSize.x, self.itemSize.y) context:DrawImage(currentItem.texture, 0, 0, self.itemSize.x, self.itemSize.y) context:DrawImage(currentItem.texture, x, y, 80, 80) context:SetBlendMode(Blend.Solid) end Quote Link to comment Share on other sites More sharing options...
armylad2011 Posted March 13, 2015 Author Share Posted March 13, 2015 nothing has changed Quote Link to comment Share on other sites More sharing options...
armylad2011 Posted March 14, 2015 Author Share Posted March 14, 2015 hi i was making a turret and made a new pivot for my player chest and the line of code you gave me for the draw image for my inventory have came up like this in the picture. i was wondering if my inventory wasn't a parent ? Quote Link to comment Share on other sites More sharing options...
armylad2011 Posted March 14, 2015 Author Share Posted March 14, 2015 its all working fine now thanx for the help everyone :-) Quote Link to comment Share on other sites More sharing options...
TheBestdev Posted February 26, 2020 Share Posted February 26, 2020 hi, i am new on this forum. Can you help me to make my game? I need a scripteur (LUA) and one buildeur?? Thanks for answering 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.