AggrorJorn Posted December 6, 2009 Share Posted December 6, 2009 Hi, I'm trying to load an image on screen when the player is very close to a certain object. I'm trying the following to achieve this: TTexture hand = LoadTexture("abstract::hand.dds") DrawImage(hand, MouseX(), MouseY(), 20, 20 ) I get the following error message: '=' expected near 'hand'. According to the wiki, I'm using the commands correctly. Who can tell me whats going wrong here? 1 Quote Link to comment Share on other sites More sharing options...
macklebee Posted December 6, 2009 Share Posted December 6, 2009 Hi, I'm trying to load an image on screen when the player is very close to a certain object. I'm trying the following to achieve this: TTexture hand = LoadTexture("abstract::hand.dds") DrawImage(hand, MouseX(), MouseY(), 20, 20 ) I get the following error message: '=' expected near 'hand'. According to the wiki, I'm using the commands correctly. Who can tell me whats going wrong here? dont know if this will work but try: hand = LoadTexture("abstract::hand.dds") DrawImage(hand, MouseX(), MouseY(), 20, 20 ) 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...
AggrorJorn Posted December 6, 2009 Author Share Posted December 6, 2009 dont know if this will work but try: hand = LoadTexture("abstract::hand.dds") DrawImage(hand, MouseX(), MouseY(), 20, 20 ) thx for your suggestion. the good news: no error message. the bad news: the image doesn't display. I've copied and modified the FPS controller scripts for this. I wonder if it is possible to run the script in the editor and to draw the image on screen when in game modus of the editor. Quote Link to comment Share on other sites More sharing options...
macklebee Posted December 6, 2009 Share Posted December 6, 2009 thx for your suggestion. the good news: no error message. the bad news: the image doesn't display. I've copied and modified the FPS controller scripts for this. I wonder if it is possible to run the script in the editor and to draw the image on screen when in game modus of the editor. well i just did it inside the example02.lua... don't forget to add it in the main loop to be rendered each flip... just like drawtext. --Register abstract path RegisterAbstractPath("") --Set graphics mode if Graphics(1024,768)==0 then Notify("Failed to set graphics mode.",1) return end --Create framewerk object and set it to a global object so other scripts can access it fw=CreateFramewerk() if fw==nil then Notify("Failed to initialize engine.",1) return end SetGlobalObject("framewerk",fw) camera=fw.main.camera camera:SetPositionf(0,0,-2) light=CreateSpotLight(10) light:SetRotationf(45,55,0) light:SetPositionf(5,5,-5) material=LoadMaterial("abstract::cobblestones.mat") mesh=CreateCube() mesh:Paint(material) ground=CreateCube() ground:SetScalef(10.0,1.0,10.0) ground:SetPositionf(0.0,-2.0,0.0) ground:Paint(material) light=CreateDirectionalLight() light:SetRotationf(45,45,45) hand=LoadTexture("abstract::hand.dds") while AppTerminate()==0 do mesh:Turnf(AppSpeed()*0.5,AppSpeed()*0.5,AppSpeed()*0.5) fw:Update() fw:Render() DrawImage(hand,20,20,200,200) Flip(0) end as for doing it in the fpscontroller... let me look. 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...
Rick Posted December 6, 2009 Share Posted December 6, 2009 Where are you doing this? In the main loop right before Flip() or in an entity? Remember that 2D needs to be done right before the Flip() statement so really an entity can't handle this right now. I think Josh should create a function that gets called per entity right before the Flip() so it can though. You could probably do this though by adding some code in the fps code. Loop through all entities and if the function Draw2D() exists call it. Then in the entity you want to do this add a Draw2D() function. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted December 6, 2009 Author Share Posted December 6, 2009 yips that was the problem. I had DrawImage before the update Render. Thanks for your quick help Quote Link to comment Share on other sites More sharing options...
macklebee Posted December 6, 2009 Share Posted December 6, 2009 Where are you doing this? In the main loop right before Flip() or in an entity? Remember that 2D needs to be done right before the Flip() statement so really an entity can't handle this right now. I think Josh should create a function that gets called per entity right before the Flip() so it can though. You could probably do this though by adding some code in the fps code. Loop through all entities and if the function Draw2D() exists call it. Then in the entity you want to do this add a Draw2D() function. he said he was doing it in fpscontroller.lua... nothing about an entity. in any case he can do it in that code just like I did in the example02.lua... but aggror, i wouldn't use the mouse positions for your locations of the drawn image... the fpscontroller's "mouse" is always in the center of the screen right? so just draw the hand texture in the center of the screen. 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...
AggrorJorn Posted December 6, 2009 Author Share Posted December 6, 2009 Where are you doing this? In the main loop right before Flip() or in an entity? Remember that 2D needs to be done right before the Flip() statement so really an entity can't handle this right now. I think Josh should create a function that gets called per entity right before the Flip() so it can though. You could probably do this though by adding some code in the fps code. Loop through all entities and if the function Draw2D() exists call it. Then in the entity you want to do this add a Draw2D() function. in the main loop. That would be a solution. I think that when I´ll be using more of these drawings, I´ll try something like that. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted December 6, 2009 Author Share Posted December 6, 2009 small question offtopic. I use the following code centering the image. --show hand if KeyDown(KEY_R)==1 then local x = GraphicsWidth()/2 local y = GraphicsHeight()/2 hand = LoadTexture("abstract::hand.dds") DrawImage(hand,x,y,50,50) end Is this a correct use of the restiction 'local'? Quote Link to comment Share on other sites More sharing options...
macklebee Posted December 6, 2009 Share Posted December 6, 2009 small question offtopic. I use the following code centering the image. --show hand if KeyDown(KEY_R)==1 then local x = GraphicsWidth()/2 local y = GraphicsHeight()/2 hand = LoadTexture("abstract::hand.dds") DrawImage(hand,x,y,50,50) end Is this a correct use of the restiction 'local'? sure that would work... but i would load the texture before the main loop instead of in the main loop. also you need to offset the 'x' and 'y' by half the size of the image if you expect it to be centered. 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...
AggrorJorn Posted December 6, 2009 Author Share Posted December 6, 2009 I see what you mean. Its more professional ofcourse but at the moment I have an image that is adapted to centering the hand. Quote Link to comment Share on other sites More sharing options...
macklebee Posted December 6, 2009 Share Posted December 6, 2009 ? the x and y is the upper left hand corner of your texture... if the texture is to be drawn 50x50, then it means you have to make x = (GraphicsWidth()/2)-25 and y = (GraphicsHeight()/2)-25 if you are going to place the texture in the dead center of your screen. 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...
AggrorJorn Posted December 6, 2009 Author Share Posted December 6, 2009 thanks for your help Quote Link to comment Share on other sites More sharing options...
macklebee Posted December 6, 2009 Share Posted December 6, 2009 thanks for your help no problem, glad i could help. its funny you were asking that question. I added the same thing to the code for the switch just today and i had named my texture the exact same thing for the time being as place art... 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...
Rick Posted December 6, 2009 Share Posted December 6, 2009 he said he was doing it in fpscontroller.lua... nothing about an entity. in any case he can do it in that code just like I did in the example02.lua... but aggror, i wouldn't use the mouse positions for your locations of the drawn image... the fpscontroller's "mouse" is always in the center of the screen right? so just draw the hand texture in the center of the screen. He can, but how much cooler would it be to be able to distribute an entity that you can just drag & drop into the editor and have it do 2D stuff. People could make 2D HUDs and interfaces that we can just drop & drag into the editor. Now that's cool. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted December 6, 2009 Author Share Posted December 6, 2009 He can, but how much cooler would it be to be able to distribute an entity that you can just drag & drop into the editor and have it do 2D stuff. People could make 2D HUDs and interfaces that we can just drop & drag into the editor. Now that's cool. now there's innovation! Quote Link to comment Share on other sites More sharing options...
Rick Posted December 6, 2009 Share Posted December 6, 2009 The crappy part currently is that it would require a change to the fps and other "game" scripts. If Josh made each entity call a 2D draw function in the correct place by default then we shouldn't have to require changes to these and it would make it easier. I'll make a feature request for it. 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.