Rekindled Phoenix Posted August 9, 2011 Share Posted August 9, 2011 As the title says, is it possible to add a Flip Hook inside the Script Editor that is NOT in the Sandbox? If so, could you post sample code? Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 9, 2011 Share Posted August 9, 2011 not sure if i understand the question... are you asking how to add a fliphook in a standalone lua program? 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...
Rekindled Phoenix Posted August 9, 2011 Author Share Posted August 9, 2011 Yes . Using the standalone Script Editor l want to be able to add a Fliphook. Seems i can only do this in the editor when overriding an object script. What gives? Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 9, 2011 Share Posted August 9, 2011 i assume its for doing 2d draw commands? you can do them three ways... 1) just set the FlipHook function in the initial part of the program function FlipHook() --or this works automatically without needing hooks.lua SetBlend(1) SetColor(Vec4(1,0,0,0.25)) DrawText("hello",50,300) SetColor(Vec4(1,1,1,1)) SetBlend(0) end 2) set a function with the hook command via "scripts/hooks" lua script function DrawStuff() SetBlend(1) SetColor(Vec4(0,1,1,1)) DrawText("hello",0,300) SetColor(Vec4(1,1,1,1)) SetBlend(0) end AddHook("Flip", DrawStuff) 3) and of course right before the Flip in the main loop note that the FlipHook function doesnt play well with the AddHook's function in the standalone for some reason... require("scripts/constants/engine_const") require("scripts/hooks") RegisterAbstractPath("") Graphics(800,600) fw=CreateFramework() fw.main.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)) --add your own via hooks.lua function DrawStuff() SetBlend(1) SetColor(Vec4(0,1,1,1)) DrawText("hello",0,300) SetColor(Vec4(1,1,1,1)) SetBlend(0) end AddHook("Flip", DrawStuff) --[[function FlipHook() --or this works automatically without needing hooks.lua SetBlend(1) SetColor(Vec4(1,0,0,0.25)) DrawText("hello",50,300) SetColor(Vec4(1,1,1,1)) SetBlend(0) end]] while AppTerminate()==0 do if KeyHit(KEY_ESCAPE)==1 then break end mesh:Turn(Vec3(AppSpeed()*0.5,AppSpeed()*0.5,AppSpeed()*0.5)) fw:Update() fw:Render() -- or just add the 2d drawcommands here SetBlend(1) SetColor(Vec4(0,0,1,1)) DrawText("something",100,300) SetColor(Vec4(1,1,1,1)) SetBlend(0) Flip(0) end 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...
Rekindled Phoenix Posted August 9, 2011 Author Share Posted August 9, 2011 Thank you for the detailed response. Seems that my assumptions are correct in that the standalone script editor doesnt like add hook. Should this be reported as a bug? I will be able to test this further tonight. Thanks for your help macklebe Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 9, 2011 Share Posted August 9, 2011 Addhook in the standalone script or a object script works fine if there is no FlipHook() function in the standalone... but yeah the two together in the standalone do not play well together or a fliphook with an addhook in an object script... but to get around it you can just use an Addhook function in the standalone as well and it works with object scripts that have addhooks 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...
Rekindled Phoenix Posted August 10, 2011 Author Share Posted August 10, 2011 Got it to work! Actually I wanted to draw an image on the screen, as a GUI. I discovered after some tweaking that the texture is only rendered if it is a multiple of 2, like the creation of DDS texture files. Is there a way to re size them within the DrawImage() command, or is that OpenGL only ? Quote 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.