Jump to content

Slimwaffle

Members
  • Posts

    245
  • Joined

  • Last visited

Everything posted by Slimwaffle

  1. Thank you soo much mate. After looking this over I was able to rewrite my own code and get this working perfectly.
  2. So I am wanting to know how I go about showing different panels based on the item selected in the tabber widget. So basically if I select the buildings2 tab it shows a different panel that is blank. Because right now it shows the same panel regardless of what I choose. I will post the code I have. --Create a Crafting panel (CRAFTING SCREEN) widget = Widget:Tabber(indent,indent,craftingpanel:GetClientSize().x-indent*2,craftingpanel:GetClientSize().y-indent*2,craftingpanel) widget:AddItem("Buildings1",false) widget:AddItem("Buildings2",false) craftingpanel:SetObject("backgroundcolor",Vec4(0.15,0.15,0.15,1)) GameMenu.tabber = widget local indent = 12 cpanel = Widget:Panel(indent,indent,widget:GetClientSize().x-indent*2,widget:GetClientSize().y-indent*2-30,widget) cpanel:SetBool("border",false) cpanel2 = Widget:Panel(indent,indent,widget:GetClientSize().x-indent*2,widget:GetClientSize().y-indent*2-30,widget) cpanel2:SetBool("border",false) cpanel2:Hide() GameMenu.cpanel={} GameMenu.cpanel.general=ipanel GameMenu.closecrafting = Widget:Button("Close",widget:GetClientSize().x-72-indent,widget:GetClientSize().y-28-5,72,28,widget) local y=20 local sep=40 --CRAFTING TAB START Widget:Label("Wood Buildings",20,y,200,16,cpanel) y=y+16 GameMenu.wbase = Widget:Button("Foundation",10,y,80,30,cpanel) GameMenu.wwall = Widget:Button("Wall",100,y,80,30,cpanel) GameMenu.wroof = Widget:Button("Roof",190,y,80,30,cpanel) GameMenu.wdoorway = Widget:Button("Doorway",280,y,80,30,cpanel) GameMenu.wwindow = Widget:Button("Window",370,y,80,30,cpanel) y=y+sep
  3. One that I think would be a great one to implement. Is a global save and load script. That works similar to WorldUpdate(). To basically get the entire world state on save and then return it when loaded. And thanks heaps mate. I will definitely get use out of it. I will most likely continue to use it on new projects until a better system is implemented straight into the engine.
  4. I have this working perfectly now. Soo Frigging Happy Thanks so much guys. Now It is setting a unique name each time it calls the save function. Here is what the code looks like in case anyone is wanting to do more with these scripts. You Just need to create a global called count1 somewhere with a value of 0. function Script:SaveData() count1 = (count1 + 1) txt1 = (tostring(count1)) System:Print(txt1) prefab = self.entity:GetKeyValue("prefab") self.entity:SetKeyValue("name", txt1) name = self.entity:GetKeyValue("name") pos = self.entity:GetPosition() rot = self.entity:GetRotation() local entityTable ={} entityTable.name = name entityTable.posx = pos.x entityTable.posy = pos.y entityTable.posz = pos.z entityTable.rotx = rot.x entityTable.roty = rot.y entityTable.rotz = rot.z entityTable.prefab = prefab System:Print(name..' Saved') return entityTable end function Script:LoadData(data) r1 = data.rotx r2 = data.roty r3 = data.rotz p1 = data.posx p2 = data.posy p3 = data.posz self.entity:SetRotation(r1,r2,r3) self.entity:SetPosition(p1,p2,p3) System:Print('Entity Loaded') end
  5. Yeah breaking them up was the easiest option. Right now I am trying to figure out how to use ToString() properly. because txt1 = count1:tostring() That didn't work. With count1 being my global number.
  6. So I fixed pos and rot using this set up. I still have yet to try the name thing. function Script:SaveData() prefab = self.entity:GetKeyValue("prefab") name = self.entity:GetKeyValue("name") pos = self.entity:GetPosition() rot = self.entity:GetRotation() local entityTable ={} entityTable.name = name entityTable.posx = pos.x entityTable.posy = pos.y entityTable.posz = pos.z entityTable.rotx = rot.x entityTable.roty = rot.y entityTable.rotz = rot.z entityTable.prefab = prefab System:Print("Object"..name.. "At" ..rot.x) return entityTable end function Script:LoadData(data) r1 = data.rotx r2 = data.roty r3 = data.rotz p1 = data.posx p2 = data.posy p3 = data.posz self.entity:SetRotation(r1,r2,r3) self.entity:SetPosition(p1,p2,p3) System:Print('Entity Loaded') end
  7. I adjusted the code to look like yours above. And rot and pos keep throwing nil values.
  8. 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)
  9. 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.
  10. 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
  11. 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.
  12. 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.
  13. 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.
  14. Thank you soo much mate. This works perfectly now. Can I use this same system if I want an intro video?
  15. 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
  16. Thanks heaps I will give that a try
  17. 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.
  18. Ok cool thanks heaps. That clears things up nicely.
  19. 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.
  20. 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.
  21. 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.
  22. 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.
  23. 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
  24. I am trying to design my inventory so everything is shown on the choice box
  25. 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)
×
×
  • Create New...