Jump to content

Slimwaffle

Members
  • Posts

    245
  • Joined

  • Last visited

Everything posted by Slimwaffle

  1. OMG thank you soo much guys. Absolute lifesavers. This has helped me greatly. Getting a working save and load is the last Major thing I have left on this project. And I will let you guys know how I go with the prefix thing. I am thinking something along the lines of adding a count variable to the world loop and changing the name of each item in the save using the loop. So for example; first time it loops it finds entity with name Wood Roof and saves it as Wood Roof 1, second time it loops finds another Wood Roof Entity and saves it as Wood Roof 2 and continues on until the loop is finished. Or even making a global variable called count1 that increases each time the code for crafting creates an object and then resetting entity name to (name + count1)
  2. Is it possible to write a C++ script and use that if the entire rest of my game is lua. Because I have seen a tutorial that does exactly what I want using c++. So the only thing that would be c++ is the save and load features.
  3. So I grabbed a savegame script from workshop that was an old one from Rick. I have been trying to get it to work within my game. But I am having issues. If the save script finds entities of the same name it only saves one entity and ignores the remaining. And for some reason it is setting the position of all saved entities to the one location. I really need help on this one guys. I will post the 3 scripts here and a video showing what happens. I need each entity regardless of if it has the same name to save and load to its own unique position and rotation. And the video in Ricks link for the script is dead. I can't figure out a solution for the naming issue. As for the everything to one location I was thinking some kind of pick might work. GenericItem.lua SaveGame.lua TableSaveLoad.lua Save Error.mp4
  4. Thanks mate. So I am making a crafting game and basically everything in game has a generic item.lua script that interacts with my other scripts and allows objects to be moved/rotated and scrapped and stores how much of each material is added to your inventory for each object.
  5. This was a very helpful video. But doesn't address my issue. Because vegetation painter only recognises unscripted .mdl files and I want to use scripted .pfb files. Is there an option for an object brush maybe? Where I can place scripted and saved .pfb files with out having to place every single one by hand. Because using the prefix Vegetation_ did nothing.
  6. Hi guys. I was just wondering if there is a way to load prefabs into the vegetation painter? Due to the nature of the game I am creating I need to be able to attach scripts to the trees and rocks and so on. But placing each rock and tree by hand can be tedious on a massive map.
  7. Thank you soo much mate. This works perfectly now. Can I use this same system if I want an intro video?
  8. Was wondering if anyone could help me figure out why my Splash Screen is not printing to screen. The system output is telling me the texture file is loading but nothing displays. But yet my line of code that reads Time:Delay is executing fine. There is just no splash screen displaying. Here is my code below; import("Scripts/Menu.lua") --Initialize Steamworks (optional) Steamworks:Initialize() --Initialize analytics (optional). Create an account at www.gameamalytics.com to get your game keys --[[if DEBUG==false then Analytics:SetKeys("GAME_KEY_xxxxxxxxx", "SECRET_KEY_xxxxxxxxx") Analytics:Enable() end]] --Set the application title title="Outback Survival" --Create a window local windowstyle = 0 local winwidth local winheight local gfxmode = System:GetGraphicsMode(System:CountGraphicsModes()-1) if System:GetProperty("devmode")=="1" then gfxmode.x = math.min(1280,gfxmode.x) gfxmode.y = Math:Round(gfxmode.x * 9 / 16) windowstyle = Window.Titlebar else gfxmode.x = System:GetProperty("screenwidth",gfxmode.x) gfxmode.y = System:GetProperty("screenheight",gfxmode.y) windowstyle = Window.Fullscreen end window=Window:Create(title,0,0,gfxmode.x,gfxmode.y,windowstyle) --Create the graphics context context=Context:Create(window,0) if context==nil then return end -- Code For Splash Screen Splash = {} Splash[1] = Texture:Load("Splash Screen/Leadwerks Splash.tex") trigger = 1 if trigger > 0 then context:SetBlendMode(Blend.Alpha) context:DrawImage(Splash[1], 20, (context:GetHeight() - 60), 30, 30) Time:Delay(5000) trigger = 0 end --Create a world world=World:Create() local gamemenu = BuildMenu(context) --Load a map gamemenu:Show() while window:Closed()==false do if gamemenu:Update()==false then return end --Handle map change if changemapname~=nil then --Pause the clock Time:Pause() --Pause garbage collection System:GCSuspend() --Clear all entities world:Clear() --Send analytics event Analytics:SendProgressEvent("Complete",prevmapname) --Load the next map if Map:Load("Maps/"..changemapname..".map")==false then return end prevmapname = changemapname --Send analytics event Analytics:SendProgressEvent("Start",prevmapname) --Resume garbage collection System:GCResume() --Resume the clock Time:Resume() changemapname = nil end if gamemenu:Hidden() then --Update the app timing Time:Update() --Update the world world:Update() end --Render the world world:Render() --Render statistics context:SetBlendMode(Blend.Alpha) if DEBUG then context:SetColor(1,0,0,1) context:DrawText("Debug Mode",2,2) context:SetColor(1,1,1,1) context:DrawStats(2,22) context:SetBlendMode(Blend.Solid) else --Toggle statistics on and off if (window:KeyHit(Key.F11)) then showstats = not showstats end if showstats then context:SetColor(1,1,1,1) context:DrawText("FPS: "..Math:Round(Time:UPS()),2,2) end end --Refresh the screen if VSyncMode==nil then VSyncMode=true end context:Sync(VSyncMode) end
  9. Thanks heaps I will give that a try
  10. Hi. I just have a question about metallic textures and shaders. I have been using substance painter for texturing my models. And so far it has been working out amazing. But I have noticed when I try to import metallic textures into leadwerks there is no gloss. They just show a basic grey colour. I did a little research and discovered it might be to do with the shader of the material I generate. So what shader am I supposed to use? Because I tested all the default shaders and none work.
  11. Ok cool thanks heaps. That clears things up nicely.
  12. Ok I got Rick's Save and Load from Workshop. I got it working now by Disabling Sandbox. Because with Sandbox enabled you can't write to file. I don't even know what Sandbox is. Can someone please explain this to me? Because I am intending to release on steam and the only information I found said steam won't let you use a game with sandbox disabled.
  13. I am working on a survival crafting game. I found a script that saves tables and stuff to be loaded later. But because the game is crafting and the player creates entities. I was wondering if there is a way to save the current state of the world in a map file? The reason I ask is because I can see in the API the option to load map files but not to save them. I mean I am open to suggestions at this stage on how to save all the entities and locations of entities all at once. Any help would be greatly appreciated.
  14. You guys can pretty much ignore this post now. I fixed this by removing the calls to values in the start function of generic item.lua. And then putting all the add to table commands in move item and calling each value using pickInfo.
  15. thanks heaps. I got this working perfectly. My materials list for inventory is working great. I did post another thread though. Because I am having an issue with the scrap button. Where I can't call self (in the code for scrap function it returns nill) and values on my generic item script aren't storing to each entity and they are changing each time I add a model into the scene and using the value of the last placed model.
  16. I am working on a scrap button for my game. I really need help with a problem. I attach my generic item script to my two crates. and my move item script to my player. Then in the scene for testing purposes I designate the small crate to give 4 brick and the large crate to give 30. But something is going wrong and it will give me the same amount both times. I want this to act independently. And I really need help. Because I don't want to have to create a new script for every single item I ever add to the game over its lifespan. I will attach a video and both my scripts so everyone can understand better. ItemMove.lua Error.mp4 GenericItem.lua
  17. I am trying to design my inventory so everything is shown on the choice box
  18. I figured this out it was actually easier then I thought. Now my issue is getting the choice box to redraw the text. Using the redraw command is not working and using SetText doesn't work either. But here is the code I used to fix it. i = GameMenu.materials:GetSelectedItem() mitem.icount = mitem.icount -1 System:Print(mitem) System:Print(mitem.icount)
  19. 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.
  20. 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
  21. 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
  22. 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
  23. 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.
  24. So I would add something to say if Time is paused mouse does nothing?
  25. But the issue I'm pretty sure is the mouse is still being used by the first person player controller
×
×
  • Create New...