cassius Posted August 7, 2017 Share Posted August 7, 2017 I added this code to main lua and got error message on first line which read '=' expected near ' ' anyone help? local sound = Sound:Load("Sound/Music/gametune.wav") source = Source:Create() source:SetSound(sound) sound:Release() source:SetLoopMode(true) source:Play() Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
Rick Posted August 7, 2017 Share Posted August 7, 2017 Can you show your entire main.lua? Quote Link to comment Share on other sites More sharing options...
cassius Posted August 7, 2017 Author Share Posted August 7, 2017 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="shoot" --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 --Load a sound local sound = Sound:Load("Sound/Music/gametune.wav") source = Source:Create() source:SetSound(sound) sound:Release() source:SetLoopMode(true) source:Play() --Create a world world=World:Create() local gamemenu = BuildMenu(context) --Load a map local mapfile = System:GetProperty("map") if mapfile~="" then if Map:Load(mapfile)==false then return end prevmapname = FileSystem:StripAll(changemapname) --Send analytics event Analytics:SendProgressEvent("Start",prevmapname) gamemenu.newbutton:SetText("RESUME GAME") window:HideMouse() else gamemenu:Show() end 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 Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
AggrorJorn Posted August 7, 2017 Share Posted August 7, 2017 Can you add the code via a code tag? It is really difficult to read this way. Not sure if it is the issue but you can make 'source' a local value. local source = Source:Create() Quote Link to comment Share on other sites More sharing options...
cassius Posted August 7, 2017 Author Share Posted August 7, 2017 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="shoot" --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 --Load a sound local sound = Sound:Load("Sound/Music/gametune.wav") source = Source:Create() source:SetSound(sound) sound:Release() source:SetLoopMode(true) source:Play() --Create a world world=World:Create() local gamemenu = BuildMenu(context) --Load a map local mapfile = System:GetProperty("map") if mapfile~="" then if Map:Load(mapfile)==false then return end prevmapname = FileSystem:StripAll(changemapname) --Send analytics event Analytics:SendProgressEvent("Start",prevmapname) gamemenu.newbutton:SetText("RESUME GAME") window:HideMouse() else gamemenu:Show() end 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 Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
AggrorJorn Posted August 7, 2017 Share Posted August 7, 2017 If your remove your sound code, does the error still appear? Your main menu seems fine further. Any chance you modified the menu.lua? Quote Link to comment Share on other sites More sharing options...
cassius Posted August 7, 2017 Author Share Posted August 7, 2017 Game runs fine with sound code removed. I have not touched menu. lua. I got the sound code directly from api reference, its not my code. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
cassius Posted August 7, 2017 Author Share Posted August 7, 2017 Got it working. I copied some sound code from a c+= project of mine inoi main.lua and translated it to lua code and it worked. I left out sorce release line as that was not in my c++ code. Thanks for answers. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ 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.