Kraxie Posted April 5, 2015 Share Posted April 5, 2015 Hello! I wanted to make some sort of message box to pop up for the player if for example an error occurred and I wanted it to show a popup box instead of just logging it into a console. Is this possible? If not, is there a module or something to add the ability to do this? Thanks, KraXarN Quote Windows 7 | Intel Core i7-4790K | 16 GB RAM | Nvidia GTX 980 Link to comment Share on other sites More sharing options...
gamecreator Posted April 6, 2015 Share Posted April 6, 2015 You can either code it yourself using context commands http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/context/ or use existing code. Either a GUI available for purchase like FlowGUI http://www.leadwerks.com/werkspace/topic/11262-flowgui-for-leadwerks/ or maybe this would be simpler http://www.leadwerks.com/werkspace/topic/12374-multiple-text-gui/ Quote Link to comment Share on other sites More sharing options...
Jazz Posted April 6, 2015 Share Posted April 6, 2015 error("This pops up this text") Quote --- Scott Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060 Link to comment Share on other sites More sharing options...
Einlander Posted April 6, 2015 Share Posted April 6, 2015 Do you want the pop up box to stop the game? If so this is what you want. http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/debug/debugerror-r752 If you want it in game then you may have to choose it yourself. Quote Link to comment Share on other sites More sharing options...
Kraxie Posted April 6, 2015 Author Share Posted April 6, 2015 You can either code it yourself using context commands http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/context/ or use existing code. Either a GUI available for purchase like FlowGUI http://www.leadwerks.com/werkspace/topic/11262-flowgui-for-leadwerks/ or maybe this would be simpler http://www.leadwerks.com/werkspace/topic/12374-multiple-text-gui/ Hm, so basically I create a new window and then render text inside it? error("This pops up this text") That just results in a script error :/ Do you want the pop up box to stop the game? If so this is what you want. http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/debug/debugerror-r752 If you want it in game then you may have to choose it yourself. That just stops the game and logs the error to the console with no popup message :/ Quote Windows 7 | Intel Core i7-4790K | 16 GB RAM | Nvidia GTX 980 Link to comment Share on other sites More sharing options...
gamecreator Posted April 6, 2015 Share Posted April 6, 2015 Hm, so basically I create a new window and then render text inside it? The simplest way is to draw a filled rectangle using this command http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/context/contextdrawrect-r724 and then draw text over that with this command (with a different color) http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/context/contextdrawtext-r731 If you want to get fancy you can replace the rectangle with an image and draw it with the DrawImage command, then do the text on top of that http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/context/contextdrawimage-r721 Check out the sample code on how to use the commands. Quote Link to comment Share on other sites More sharing options...
Kraxie Posted April 6, 2015 Author Share Posted April 6, 2015 The simplest way is to draw a filled rectangle using this command http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/context/contextdrawrect-r724 and then draw text over that with this command (with a different color) http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/context/contextdrawtext-r731 If you want to get fancy you can replace the rectangle with an image and draw it with the DrawImage command, then do the text on top of that http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/context/contextdrawimage-r721 Check out the sample code on how to use the commands. Hm, okay, but I can't seem to create a new window without duplicating my current one... It seems like I need to set the Window:Create() outside of App.lua, but how do I do that and still be able to call it from any other script? Quote Windows 7 | Intel Core i7-4790K | 16 GB RAM | Nvidia GTX 980 Link to comment Share on other sites More sharing options...
Rick Posted April 6, 2015 Share Posted April 6, 2015 So you have to think about what you want here. You can have in-game message box or you can have an OS message box. The OS message box would have nothing to do with LE. You'd have to code this in C++ for the platform you are on. On windows just look up Windows MessageBox to see how to do this. For Linux I'm not sure exactly how, but I'm sure they have something. Gamecreator's solution is more in-game. You are just drawing images/rects on screen to simulate a window and drawing text and buttons and such. You are making the message box yourself with LE commands this way. 1 Quote Link to comment Share on other sites More sharing options...
Kraxie Posted April 6, 2015 Author Share Posted April 6, 2015 So you have to think about what you want here. You can have in-game message box or you can have an OS message box. The OS message box would have nothing to do with LE. You'd have to code this in C++ for the platform you are on. On windows just look up Windows MessageBox to see how to do this. For Linux I'm not sure exactly how, but I'm sure they have something. Gamecreator's solution is more in-game. You are just drawing images/rects on screen to simulate a window and drawing text and buttons and such. You are making the message box yourself with LE commands this way. I want something as close to an OS Box as possible. I only have the Indie Edition, but I'll probably get the Standard Edition next time it goes on sale, so I might just have to wait until then if there is no other way to do it... Quote Windows 7 | Intel Core i7-4790K | 16 GB RAM | Nvidia GTX 980 Link to comment Share on other sites More sharing options...
Einlander Posted April 6, 2015 Share Posted April 6, 2015 You are now heading for technical territory. First you will need to turn off Sandbox Lua in the Leadwerks options menu. Your game will not work in the Leadwerks game player on Steam anymore. Now add this code when you want to make w messagebox appear local ffi = require("ffi") ffi.cdef[[int MessageBoxA(void *w, const char *txt, const char *cap, int type);]] self.window:ShowMouse() ffi.C.MessageBoxA(nil, "Hello world!", "Test", 0) self.window:HideMouse() Reference: http://luajit.org/ext_ffi.html Beyond this example I can't help as it is beyond my ability as a programmer. 1 Quote Link to comment Share on other sites More sharing options...
Rick Posted April 6, 2015 Share Posted April 6, 2015 Also, note that I think that would only work for Windows. If you wanted this on Linux you'd have to research that and probably do some #ifdef in that code. Quote Link to comment Share on other sites More sharing options...
cassius Posted April 6, 2015 Share Posted April 6, 2015 I just designed a message box in paint.net and used drawimage to show it when a key is pressed. It contains instructions for key presses during game. 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...
Kraxie Posted April 6, 2015 Author Share Posted April 6, 2015 You are now heading for technical territory. First you will need to turn off Sandbox Lua in the Leadwerks options menu. Your game will not work in the Leadwerks game player on Steam anymore. Now add this code when you want to make w messagebox appear local ffi = require("ffi") ffi.cdef[[int MessageBoxA(void *w, const char *txt, const char *cap, int type);]] self.window:ShowMouse() ffi.C.MessageBoxA(nil, "Hello world!", "Test", 0) self.window:HideMouse() Reference: http://luajit.org/ext_ffi.html Beyond this example I can't help as it is beyond my ability as a programmer. Exactly what I was looking for! Thanks! Also, note that I think that would only work for Windows. If you wanted this on Linux you'd have to research that and probably do some #ifdef in that code. I read on that site somewhere that it sadly was Windows only... I'll see if I can get it working on Linux as well, that would be great. I just designed a message box in paint.net and used drawimage to show it when a key is pressed. It contains instructions for key presses during game. I'm looking for some sort of OS Info Box, not something in-game Quote Windows 7 | Intel Core i7-4790K | 16 GB RAM | Nvidia GTX 980 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.