-
Posts
43 -
Joined
-
Last visited
Profile Information
-
Location
Newburgh, Ellon, AberdeenShire, UK
Sargeant12344's Achievements
Newbie (1/14)
1
Reputation
-
NM, I had a platform without any mass.
-
I was doing some edits to the pause menu to make it pop up once the player starts the game-and it does. Unfortunately I can't seem to it so once the player clicks on Resume the script goes back to normal. Heres a copy of my most succesful attempt --The Hankinator's UI library --For this script to work, you need to modify your Main.lua to --only call Time:Update() and world:Update() when paused is false. --Take a look at the Main.lua in the example's directory import "Addons/THUI/THUI.lua" Script.startPause = true function Script:Start() --Autoscale version ---[[ self.group = THUI:CreateGroup("pause2", self, THUI.AUTOSCALE, nil, nil, 1023, 767) self.group.update = THUI:Callback(self.UpdateUI, self, nil) local title_font = Font:Load("Fonts/arial.ttf", THUI:Rel2AbsY(32, 767)) local title = THUI.Label:Create(512, 50, 0, 0, "Parkour Game", THUI.CENTER, THUI.MIDDLE) title.font = title_font local width = 200 local button1 = THUI.Button:Create(512, 300, width, 50, "Play", THUI.CENTER, THUI.MIDDLE) button1.click = THUI:Callback(self.ResumeButtonclicked, self) local exitbutton = THUI.Button:Create(512, 400, width, 50, "Exit", THUI.CENTER, THUI.MIDDLE) exitbutton.click = THUI:Callback(self.ExitButtonclicked, self) self.group:Add(title) self.group:Add(button1) self.group:Add(exitbutton) --]] --Anchored version --[[ self.group = THUI:CreateGroup("pause_menu", self, THUI.ANCHOR, THUI.LEFT, THUI.MIDDLE, 200, 200) local title_font = Font:Load("Fonts/arial.ttf", THUI:Rel2AbsY(32, 767)) local title = THUI.Label:Create(100, 0, 0, 0, "Paused!", THUI.CENTER, THUI.TOP) title.font = title_font local button1 = THUI.Button:Create(0, 50, 200, 50, "Resume") button1.click = THUI:Callback(self.ResumeButtonclicked, self) local exitbutton = THUI.Button:Create(0, 150, 200, 50, "Exit") exitbutton.click = THUI:Callback(self.ExitButtonclicked, self) self.group:Add(title) self.group:Add(button1) self.group:Add(exitbutton) --]] --Absolute version --[[ self.group = THUI:CreateGroup("pause_menu", self, THUI.ABSOLUTE) local title_font = Font:Load("Fonts/arial.ttf", THUI:Rel2AbsY(32, 767)) local title = THUI.Label:Create(400, 200, 0, 0, "Paused!", THUI.CENTER, THUI.TOP) title.font = title_font local button1 = THUI.Button:Create(300, 250, 200, 50, "Resume") button1.click = THUI:Callback(self.ResumeButtonclicked, self) local exitbutton = THUI.Button:Create(300, 350, 200, 50, "Exit") exitbutton.click = THUI:Callback(self.ExitButtonclicked, self) self.group:Add(title) self.group:Add(button1) self.group:Add(exitbutton) --]] end function Script:ResumeButtonclicked(button) if self.startPause==true then self.startPause = false end self:HideMenu() end function Script:ExitButtonclicked(button) exit_game = true end function Script:UpdateWorld() if window:KeyHit(Key.Escape) or self.startPause == true then if not paused then self:ShowMenu() end end end function Script:UpdateUI(group, arg) if window:KeyHit(Key.Escape) then if paused then self:HideMenu() end end end function Script:ShowMenu() paused = true Time:Pause() THUI:Activate("pause2") end function Script:HideMenu() paused = false Time:Resume() THUI:Deactivate() --FPSPlayer.lua measures the distance from the middle of the screen to figure out how much --the player is trying to look so we need to reset it when the user is done with the UI local context = Context:GetCurrent() Window:GetCurrent():SetMousePosition(Math:Round(context:GetWidth()/2), Math:Round(context:GetHeight()/2)) end
-
How to close the game once the lvl is complete
Sargeant12344 replied to Sargeant12344's topic in Programming
Okay Thanks for all the help! -
I would say ,from a gameplay perspective, 8 would be the best
-
Title
-
Okay Thanks!
-
I'm trying to make a heart flatlining sound and edited my respawn trigger and FPS Player Script, however when I try to test the script, no sound plays. Rather than post the whole FPS Player script I only posted the used bits. --Load shared sounds self.sound={}--table to store sound in self.sound.flashlight=Sound:Load("Sound/Player/flashlight_02_on.wav") self.sound.damage={} self.sound.damage[1]=Sound:Load("Sound/Impact/body_punch_03.wav") self.sound.damage[2]=Sound:Load("Sound/Impact/body_punch_04.wav") self.sound.pickupweapon=Sound:Load("Sound/Player/pickupammo.wav") self.sound.footsteps={} self.sound.footsteps.concrete={} self.sound.footsteps.concrete.step={} self.sound.footsteps.concrete.step[1] = Sound:Load("Sound/Footsteps/Concrete/step1.wav") self.sound.footsteps.concrete.step[2] = Sound:Load("Sound/Footsteps/Concrete/step2.wav") self.sound.footsteps.concrete.step[3] = Sound:Load("Sound/Footsteps/Concrete/step3.wav") self.sound.footsteps.concrete.step[4] = Sound:Load("Sound/Footsteps/Concrete/step4.wav") self.sound.footsteps.concrete.jump = Sound:Load("Sound/Footsteps/Concrete/jump.wav") self.sound.music={} self.sound.music = Sound:Load("Sound/Music/Heart") self.bloodoverlay={} self.entity:SetPickMode(0) Script.heartFlatlining = false function Script:HeartFlatlining() if script.heartFlatlining == true then self.sound.damage[math.random(#self.sound.damage)]:Play() end end Script.respawnPoint = "" --entity "Respawn point" function Script:Collision(entity, position, normal, speed) if(entity:GetKeyValue("name") == "Player") then spawnPos = self.respawnPoint:GetPosition() entity:SetPosition(spawnPos) spawnRot = self.respawnPoint:GetRotation() entity.script.camRotation = spawnRot entity.script.heartFlatlining = true else entity:Release() end end Thanks
-
Okay Thanks for all the help, 1440p is not supported by my monitor (I was thinking that you could downscale a high res image in Leadwerks) .
-
Okay Thanks. However, when I try to set the resolution to 2560*1440 an error message pops up stating "Script Error attempt to index global 'window (a nil value) Line 13 Any help?
-
I recently changed the screen resolution in Main.lua and set it to fullscreen, I was however wonder if someone were to play it on a lower res monitor, would the game be distorted in any way? Heres my main.lua. import "Addons/THUI/THUI.lua" --Initialize Steamworks (optional) Steamworks:Initialize() --Set the application title title="MyGame" --Create a window local windowstyle = window.Titlebar if System:GetProperty("fullscreen")=="1" then windowstyle=windowstyle+window.FullScreen end window=Window:Create(title,0,0,System:GetProperty("screenwidth","1920"),System:GetProperty("screenheight","1080"),windowstyle+window.FullScreen) window:HideMouse() --Create the graphics context context=Context:Create(window,0) if context==nil then return end THUI:Initialize() --Create a world world=World:Create() world:SetLightQuality((System:GetProperty("lightquality","1"))) --Load a map local mapfile = System:GetProperty("map","Maps/start.map") if Map:Load(mapfile)==false then return end paused = false exit_game = false while not exit_game do --If window has been closed, end the program if window:Closed() then break end --Handle map change if changemapname~=nil then --Clear all entities world:Clear() --Load the next map Time:Pause() if Map:Load("Maps/"..changemapname..".map")==false then return end Time:Resume() changemapname = nil end if not paused then --Update the app timing Time:Update() --Update the world world:Update() end --Render the world world:Render() THUI:Update() --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 context:Sync(true) end
-
Thanks, it now works! Sorry for being a bit dim.
-
Sorry, posted the backup script by accident.This is the real one that I have been using (The Example one). import "Addons/THUI/THUI.lua" --Initialize Steamworks (optional) Steamworks:Initialize() --Set the application title title="MyGame" --Create a window local windowstyle = window.Titlebar if System:GetProperty("fullscreen")=="1" then windowstyle=windowstyle+window.FullScreen end window=Window:Create(title,0,0,System:GetProperty("screenwidth","1024"),System:GetProperty("screenheight","768"),windowstyle) window:HideMouse() --Create the graphics context context=Context:Create(window,0) if context==nil then return end THUI:Initialize() --Create a world world=World:Create() world:SetLightQuality((System:GetProperty("lightquality","1"))) --Load a map local mapfile = System:GetProperty("map","Maps/start.map") if Map:Load(mapfile)==false then return end paused = false exit_game = false while not exit_game do --If window has been closed, end the program if window:Closed() then break end --Handle map change if changemapname~=nil then --Clear all entities world:Clear() --Load the next map Time:Pause() if Map:Load("Maps/"..changemapname..".map")==false then return end Time:Resume() changemapname = nil end if not paused then --Update the app timing Time:Update() --Update the world world:Update() end --Render the world world:Render() THUI:Update() --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 context:Sync(true) end import "Addons/THUI/THUI.lua" function Script:Start() --Autoscale version ---[[ self.group = THUI:CreateGroup("pause_menu", self, THUI.AUTOSCALE, nil, nil, 1023, 767) self.group.update = THUI:Callback(self.UpdateUI, self, nil) local title_font = Font:Load("Fonts/arial.ttf", THUI:Rel2AbsY(32, 767)) local title = THUI.Label:Create(512, 50, 0, 0, "Paused!", THUI.CENTER, THUI.MIDDLE) title.font = title_font local width = 200 local button1 = THUI.Button:Create(512, 300, width, 50, "Resume", THUI.CENTER, THUI.MIDDLE) button1.click = THUI:Callback(self.ResumeButtonclicked, self) local exitbutton = THUI.Button:Create(512, 400, width, 50, "Exit", THUI.CENTER, THUI.MIDDLE) exitbutton.click = THUI:Callback(self.ExitButtonclicked, self) self.group:Add(title) self.group:Add(button1) self.group:Add(exitbutton) --]] --Anchored version --[[ self.group = THUI:CreateGroup("pause_menu", self, THUI.ANCHOR, THUI.LEFT, THUI.MIDDLE, 200, 200) local title_font = Font:Load("Fonts/arial.ttf", THUI:Rel2AbsY(32, 767)) local title = THUI.Label:Create(100, 0, 0, 0, "Paused!", THUI.CENTER, THUI.TOP) title.font = title_font local button1 = THUI.Button:Create(0, 50, 200, 50, "Resume") button1.click = THUI:Callback(self.ResumeButtonclicked, self) local exitbutton = THUI.Button:Create(0, 150, 200, 50, "Exit") exitbutton.click = THUI:Callback(self.ExitButtonclicked, self) self.group:Add(title) self.group:Add(button1) self.group:Add(exitbutton) --]] --Absolute version --[[ self.group = THUI:CreateGroup("pause_menu", self, THUI.ABSOLUTE) local title_font = Font:Load("Fonts/arial.ttf", THUI:Rel2AbsY(32, 767)) local title = THUI.Label:Create(400, 200, 0, 0, "Paused!", THUI.CENTER, THUI.TOP) title.font = title_font local button1 = THUI.Button:Create(300, 250, 200, 50, "Resume") button1.click = THUI:Callback(self.ResumeButtonclicked, self) local exitbutton = THUI.Button:Create(300, 350, 200, 50, "Exit") exitbutton.click = THUI:Callback(self.ExitButtonclicked, self) self.group:Add(title) self.group:Add(button1) self.group:Add(exitbutton) --]] end function Script:ResumeButtonclicked(button) self:HideMenu() end function Script:ExitButtonclicked(button) exit_game = true end function Script:UpdateWorld() if window:KeyHit(Key.Escape) then if not paused then self:ShowMenu() end end end function Script:UpdateUI(group, arg) if window:KeyHit(Key.Escape) then if paused then self:HideMenu() end end end function Script:ShowMenu() paused = true Time:Pause() THUI:Activate("pause_menu") end function Script:HideMenu() paused = false Time:Resume() THUI:Deactivate() --FPSPlayer.lua measures the distance from the middle of the screen to figure out how much --the player is trying to look so we need to reset it when the user is done with the UI local context = Context:GetCurrent() Window:GetCurrent():SetMousePosition(Math:Round(context:GetWidth()/2), Math:Round(context:GetHeight()/2)) end
-
--Initialize Steamworks (optional) Steamworks:Initialize() --Set the application title title="Game" --Create a window local windowstyle = window.Titlebar if System:GetProperty("fullscreen")=="1" then windowstyle=windowstyle+window.FullScreen end window=Window:Create(title,0,0,System:GetProperty("screenwidth","1024"),System:GetProperty("screenheight","768"),windowstyle) window:HideMouse() --Create the graphics context context=Context:Create(window,0) if context==nil then return end --Create a world world=World:Create() world:SetLightQuality((System:GetProperty("lightquality","1"))) --Load a map local mapfile = System:GetProperty("map","Maps/start.map") if Map:Load(mapfile)==false then return end while window:KeyDown(Key.Escape)==false do --If window has been closed, end the program if window:Closed() then break end --Handle map change if changemapname~=nil then --Clear all entities world:Clear() --Load the next map Time:Pause() if Map:Load("Maps/"..changemapname..".map")==false then return end Time:Resume() changemapname = nil end --Update the app timing Time:Update() --Update the world world:Update() --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 context:Sync(true) end Here it is
-
I'm just not sure where I am going wrong, I have tried to replace the normal main.lua with the example one. I also have tried following the instructions on this page in an attempt to try and make a simple GUI Menu. When I press the esc key, nothing happens. Any help?
-
Not sure what I am doing wrong. I apply both the example Main and the example Pause to separate Pivots. When I try to run the game, an endless series of blacks screens open up. Any help?