Jump to content

Slimwaffle

Members
  • Posts

    245
  • Joined

  • Last visited

Everything posted by Slimwaffle

  1. I am having trouble with some code and could use some help. I want to say table index = to choice box selected. mitem.icount is the table and GameMenu.materials is the choice box. This was the code I used but it keep showing a nil value. mitem.icount = GameMenu.materials:GetSelectedItem() Its for a trash materials button. I want to be able to say table index is = to table index -1 then return the value.
  2. I was wondering if someone could please help. How do I add an if condition to say "if choice box text = to an item in mitem{}, then the current selected table index[] is__" So that later on in my code I can say if trash button is pressed selected index is = to selected index -1 --Material Item List mitem ={} mitem[0] = "Wood" mitem[1] = "Steel" mitem[2] = "Concrete" mitem[3] = "Rubber" mitem.icount = {} mitem.icount[0] = 100 mitem.icount[1] = 200 mitem.icount[2] = 300 mitem.icount[3] = 400 for i=0, #mitem do local selected=false GameMenu.materials:AddItem( mitem .." = "..mitem.icount) end GameMenu.trashmat = Widget:Button("Trash",250,y,72,30,ipanel) y=y+sep
  3. I am working on an inventory script. I have the thing pretty much working the way I want. I just want it to sort alphabetically using in pairs. How can I adjust the code below to still do the same things but also sort alphabetically? --Material Item List mitem ={} mitem[0] = "Wood" mitem[1] = "Steel" mitem[2] = "Concrete" mitem[3] = "Rubber" for i=0, #mitem do local selected=false GameMenu.materials:AddItem( mitem) end GameMenu.usematerial = Widget:Button("Trash",250,y,72,30,ipanel) y=y+sep
  4. I am so happy I got this working I am going to share it with you guys. These scripts will allow you to move items around in game. Enjoy The first script is here; --Generic Item Script function Script:Start() self.entity:SetKeyValue("type","item") pos = self.entity:GetPosition() end function Script:UpdateWorld() end Now the Second Script to actually move the item; --Script to move Item Script.camPick = false Script.radius = 1 function Script:Start() self.player = self.entity:GetParent() self.camera = self.player.script.camera end function Script:UpdateWorld() local pickInfo = PickInfo() local mouse = window:GetMousePosition() if self.camera:Pick(mouse.x, mouse.y, pickInfo, self.radius, true,2) then if pickInfo.entity:GetKeyValue("type") == "item" then self.camPick = true end else self.camPick = false end local pickInfo = PickInfo() local mouse = window:GetMousePosition() if self.camera:Pick(mouse.x, mouse.y, pickInfo, self.radius, true,2) then pickInfo.entity:SetPickMode(Entity.PolygonPick) dist = self.camera:GetDistance(pickInfo.entity,false) if dist >= 20 then self.camPick = false end if self.camPick == true then if pickInfo.entity:GetKeyValue("type") == "item" then if window:KeyDown(Key.Q) then --UnProject mouse coordinates from screen space to world space and position the box there local p = window:GetMousePosition() p.z = 3 --distance in front of the camera to project to p = self.camera:UnProject(p) pickInfo.entity:SetPosition(p) end end end end end
  5. 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.
  6. So I would add something to say if Time is paused mouse does nothing?
  7. But the issue I'm pretty sure is the mouse is still being used by the first person player controller
  8. Its there so the game pauses while you are going through your inventory screen
  9. 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
  10. Thanks mate. That worked perfectly.
  11. So I have been looking into a save and load function. So far everything I have seen uses tables. I noticed in alot of the code there is an update world function. Is there some kind of way. To save the entire world state (So absolutely everything is included) and then update it back to the world state when using a load function?
  12. I was wondering if anyone could help me with a glitch I am experiencing with the gui. So I wanted to load a background image on the main menu.The problem is that it loads buggy then you click and it loads perfectly. The code I used looked like this; --GUI local gui = GUI:Create(context) gui:Hide() gui:SetScale(scale) local widget gui:GetBase():SetScript("Scripts/GUI/Panel.lua") gui:GetBase():SetObject("backgroundcolor",Vec4(0,0,0,1)) --This part is my code local image = gui:LoadImage("Frame/Walkabout.tex") local imagePanel = Widget:Panel(0,0,1920,1080, gui:GetBase()) imagePanel:SetImage(image) --Ends here GameMenu.gui=gui GameMenu.context = context How do I get this to load properly the first time without having to click?
  13. I searched everywhere. There is no reference to name. I think I am going to have to add something in myself. I think maybe along the lines of on weapon pick up if weapon file is = "path to mp4.pfb" then name of next index = "mp4" Not sure if that will work. Seems a bit tedious. Would saving all the file paths (For each item) and the equivalent name (for each item) to a table and then search matching string in table and returning name value work better?
  14. This is what I came up with that compiles without error. But its not printing a name value to screen. wep = self.weapons[self.currentweaponindex].entity:GetKeyValue("Name") context:SetBlendMode(1) context:SetColor(0,1,1,255) context:DrawText("Weapon = " ..wep , 20,(context:GetHeight() - 80))
  15. At the moment its just the default weapon autopistol and the ones from the fps pack. I want to print to screen above my ammo the name of the weapon currently being held So yeah mostly prefabs
  16. I was wondering how I would go about getting weapon name to print to screen? I checked all the code and can't find a reference to name anywhere. The closest I found was weapon file. Which prints the weapon file path to screen but does not change when swapping weapons.
  17. I fixed everything. Poly count is my only issue now. Thanks for the help guys.
  18. I was able to get body and hair to separate properly. Because fuse puts body on one layer and everything else on a second layer when creating textures. I would add hair export. remove hair. So only hair was on second layer. And import skinned FBX to leadwerks. Then apply hair textures to blank material generated for hair. And repeat the process for each item (top, pants and so on). This worked great for hair. But now my problem is clothing items aren't texturing properly. Is there a way to combine surfaces in model editor into a single surface. So that I can do hair and clothes on a single texture? bandicam 2018-06-29 11-28-51-069.mp4
  19. yeah I followed this to fix the animations. The only issue now is that importing a skinned character generates blank materials that appear all black.
  20. And importing skinned FBX is worse because the textures just go black inside the engine.
  21. Ok I fixed the issue. I needed to make the shaders for the material animated. Apply to the character. (This removes animations) then reapply animations and save. Now my only Issue is the texture. Under closer inspection. I have discovered that. Fuse is creating the character and clothes on what I think on different layers. Because substance painter when the model is imported shows them on separate layers. But leadwerks is converting the model from obj all on one layer. Which makes the texture wrap over the clothes and hair.
  22. Update - I don't get FPS lag anymore. And everything works fine. My only issue now. Is that when I generate material from tex and apply to character. It makes the character T pose. But from the shadows you can still see the animation playing. Without texture though this worked perfectly just from copying all the settings from crawler into new character.
  23. This is just test scene while I am still building things and figuring out the engine. Eventually the project will be a sandbox level
  24. Even if I delete them all. And only place in the custom one on its own. I still get the same issue
  25. turns out poly count is fine. Here is the attached project. I am getting all kinds of random errors e.g model T posing and not animating when textured. And no matter what massive reduction in fps. The model I am using now is in a folder called mixamo. Waffles.zip
×
×
  • Create New...