Davaris Posted January 22, 2010 Share Posted January 22, 2010 I'm going through the Getting_Started_With_Lua.pdf and I just got up to the AddHook part and I can't get the DrawOverlay hook to work. Can anyone see what I am dong wrong? require("scripts/constants/keycodes") require("scripts/hooks") --Register abstract path RegisterAbstractPath("") --Set graphics mode if Graphics(1024,768)==0 then Notify("Failed to set graphics mode.",1) return end world=CreateWorld() if world==nil then Notify("Failed to initialize engine.",1) return end gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),1+2+4+8) camera=CreateCamera() camera:SetPosition(Vec3(0,0,-2)) light=CreateSpotLight(10) light:SetRotation(Vec3(45,55,0)) light:SetPosition(Vec3(5,5,-5)) material=LoadMaterial("abstract::cobblestones.mat") mesh=CreateCube() mesh:Paint(material) ground=CreateCube() ground:SetScale(Vec3(10.0,1.0,10.0)) ground:SetPosition(Vec3(0.0,-2.0,0.0)) ground:Paint(material) light=CreateDirectionalLight() light:SetRotation(Vec3(45,45,45)) function DrawOverlay() DrawText("DrawOverlay",0,50) SetBlend(1) SetColor(Vec4(1,0,0,0.25)) DrawRect(100,100,GraphicsWidth()-200,GraphicsHeight()-200) SetColor(Vec4(1,1,1,1)) SetBlend(0) end AddHook("Flip",DrawOverlay) while AppTerminate()==0 do if KeyHit(KEY_ESCAPE)==1 then break end mesh:Turn(Vec3(AppSpeed()*0.5,AppSpeed()*0.5,AppSpeed()*0.5)) UpdateAppTime() world:Update(AppSpeed()) SetBuffer(gbuffer) world:Render() SetBuffer(BackBuffer()) world:RenderLights(gbuffer) DrawText(UPS(),0,0) Flip(0) end Quote Win 7 Pro 64 bit AMD Phenom II X3 720 2.8GHz GeForce 9800 GTX/9800 GTX+ 4 GB RAM Link to comment Share on other sites More sharing options...
macklebee Posted January 22, 2010 Share Posted January 22, 2010 your code works fine for me when ran directly from the script editor and when dragged onto the engine.exe... what exactly are you having troubles with? Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Marleys Ghost Posted January 22, 2010 Share Posted January 22, 2010 yeah works fine for me too. Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
Davaris Posted January 22, 2010 Author Share Posted January 22, 2010 On mine it isn't showing the transparent red rectangle. In the example just before it uses: function FlipHook() SetBlend(1) SetColor(Vec4(1,0,0,0.25)) DrawRect(100,100,GraphicsWidth()-200,GraphicsHeight()-200) SetColor(Vec4(1,1,1,1)) SetBlend(0) end and it works in that the red rectangle is visible. On the one I posted above, it doesn't work, even when I copied it to my SDK directory which is updated. So if it works for you guys it might be a bug. Quote Win 7 Pro 64 bit AMD Phenom II X3 720 2.8GHz GeForce 9800 GTX/9800 GTX+ 4 GB RAM Link to comment Share on other sites More sharing options...
Marleys Ghost Posted January 22, 2010 Share Posted January 22, 2010 and it works in that the red rectangle is visible. On the one I posted above, it doesn't work, even when I copied it to my SDK directory which is updated. So if it works for you guys it might be a bug. I'd have thought it would be a bug if it had not worked for us, what are your system specs? Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
gordonramp Posted January 22, 2010 Share Posted January 22, 2010 Your script works both ways for me. Quote AMD Athlon x2 7750 2.7ghz, 6gb ddr2 ram, Galaxy9800GT 1gig ddr2 video card, Windows 7,64. Link to comment Share on other sites More sharing options...
Davaris Posted January 22, 2010 Author Share Posted January 22, 2010 Win 7 Pro 64 bit AMD Phenom II X3 720 2.8GHz GeForce 9800 GTX/9800 GTX+ 4 GB RAM Quote Win 7 Pro 64 bit AMD Phenom II X3 720 2.8GHz GeForce 9800 GTX/9800 GTX+ 4 GB RAM Link to comment Share on other sites More sharing options...
macklebee Posted January 22, 2010 Share Posted January 22, 2010 seems you are not doing something right because i dont see how this could be a bug... where is the lua file? wherever it is put it in the main SDK directory. Now drag it and drop it on the engine.exe. should work fine. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Davaris Posted January 22, 2010 Author Share Posted January 22, 2010 I just fixed it. I altered the compatibility mode to WinXP SP3 and now it works! The SDK was in the Program Files (x86) directory, so I don't know why it did not properly. Quote Win 7 Pro 64 bit AMD Phenom II X3 720 2.8GHz GeForce 9800 GTX/9800 GTX+ 4 GB RAM Link to comment Share on other sites More sharing options...
Marleys Ghost Posted January 22, 2010 Share Posted January 22, 2010 I just fixed it. I altered the compatibility mode to WinXP SP3 and now it works! Ok .. everyone stand down from Bug alert Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
macklebee Posted January 22, 2010 Share Posted January 22, 2010 I just fixed it. I altered the compatibility mode to WinXP SP3 and now it works! weird... do you have to do that for any other scripts? Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Davaris Posted January 22, 2010 Author Share Posted January 22, 2010 I haven't been able to get the burning barrel to show fire or smoke, or the windmill to spin, so I'll have try them out with a compatibility change as well. Quote Win 7 Pro 64 bit AMD Phenom II X3 720 2.8GHz GeForce 9800 GTX/9800 GTX+ 4 GB RAM Link to comment Share on other sites More sharing options...
Davaris Posted January 22, 2010 Author Share Posted January 22, 2010 Just tried it and the Windmill still doesn't spin and the fire barrel behavior is unchanged: there is light and sound, but no visible particles for the fire or smoke. I don't know if Josh has updated those scripts though. Quote Win 7 Pro 64 bit AMD Phenom II X3 720 2.8GHz GeForce 9800 GTX/9800 GTX+ 4 GB RAM Link to comment Share on other sites More sharing options...
Canardia Posted January 22, 2010 Share Posted January 22, 2010 Josh hasn't updated the Windmill Lua script to work with the engine, but you can find here the updated Windmill Lua script: http://leadwerks.com/werkspace/index.php?/tracker/issue-49-windmill-script-is-not-updated/ Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
macklebee Posted January 22, 2010 Share Posted January 22, 2010 the firepit = fire barrel? if so, that one is updated and works just fine for me... does it work in the editor for you? the windmill isn't updated (actually i think lumooja did it?)... and i dont think its actually even in the latest download since we went to singlestate lua... perhaps you should try a clean download of the SDK? Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Marleys Ghost Posted January 22, 2010 Share Posted January 22, 2010 i dont think its actually even in the latest download No its not, after I did a full fresh install it was not there. Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
Davaris Posted January 22, 2010 Author Share Posted January 22, 2010 the firepit = fire barrel? if so, that one is updated and works just fine for me... does it work in the editor for you? It works perfectly in the editor for some reason. Quote Win 7 Pro 64 bit AMD Phenom II X3 720 2.8GHz GeForce 9800 GTX/9800 GTX+ 4 GB RAM Link to comment Share on other sites More sharing options...
macklebee Posted January 22, 2010 Share Posted January 22, 2010 It works perfectly in the editor for some reason. where else are you trying to run it? via bmax or c++ and loaded into a scene? or just with a lua game script? give an example of the code where it doesn't work... Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
macklebee Posted January 22, 2010 Share Posted January 22, 2010 ok... i didnt expect your entire code what i am not seeing is the anything that integrates the lua to c++.. arent you missing this code somewhere: //Set Lua variable BP L=GetLuaState(); lua_pushobject(L,framework); lua_setglobal(L,"fw"); lua_pop(L,1); and off hand i dont see the framework being initialized... unless of course thats all being handled in gamelib? Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
macklebee Posted January 22, 2010 Share Posted January 22, 2010 you need to have some reference to "fw" because the firepit uses framework worlds for the emitters Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Davaris Posted January 22, 2010 Author Share Posted January 22, 2010 I think it is initialized in GameLib. BTW I just deleted that post because it was freezing my browser. Sorry about that. Quote Win 7 Pro 64 bit AMD Phenom II X3 720 2.8GHz GeForce 9800 GTX/9800 GTX+ 4 GB RAM Link to comment Share on other sites More sharing options...
Josh Posted January 22, 2010 Share Posted January 22, 2010 Yep, this is talked about in the end of the big Lua tutorial. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Davaris Posted January 22, 2010 Author Share Posted January 22, 2010 In GameLib this function is called: void TGame::Initialize(int sx0, int sy0, int fullscreen) { scene.Initialize(sx0,sy0,fullscreen); scene.game=this; gamelib_callback=this; luat.Create(); // create the LuaTools object luat.SetScriptObject("fw",scene.framewerk); // set the Lua variable fw Quote Win 7 Pro 64 bit AMD Phenom II X3 720 2.8GHz GeForce 9800 GTX/9800 GTX+ 4 GB RAM Link to comment Share on other sites More sharing options...
macklebee Posted January 22, 2010 Share Posted January 22, 2010 and where is this? //Set Lua variable BP L=GetLuaState(); lua_pushobject(L,framework); lua_setglobal(L,"fw"); lua_pop(L,1); Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Davaris Posted January 22, 2010 Author Share Posted January 22, 2010 and where is this? //Set Lua variable BP L=GetLuaState(); lua_pushobject(L,framework); lua_setglobal(L,"fw"); lua_pop(L,1); I think this is it: void LuaTools::SetScriptObject( const std::string& name, BP o ) { int size = GetStackSize(); PushObject( o ); SetGlobal( name ); SetStackSize( size ); } Quote Win 7 Pro 64 bit AMD Phenom II X3 720 2.8GHz GeForce 9800 GTX/9800 GTX+ 4 GB RAM 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.