Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Unity (LUA) error handling. DIY message boxes?

Author
Message
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 1st Feb 2012 21:08
Does anyone use the Unity LUA scripting plugin?

I looked at the documentation and all over the forum but there is no clear way to replace the script error messages with your own message boxes.

I do not want to have a window based message box popup when there is a script error. The message box that shows up does not use the error message theme, and provides the user with a means to proceed or close the program. Nothing wrong with this, it is just not is required in certain situations; I do not want the user to press continue; even though it either crashes or shuts down anyway, since you can check the script result.

Furthermore, sometimes the scripts being run on the fly are for minor calculations; a windows error message box makes the process of checking syntax look unstable even though it is a minor error with the user input.

(I am aware that I can compile the scripts before hand or at runtime)

If no one knows what could be done, then I'd have to do a syntax check of my own.

Brendy boy
19
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 1st Feb 2012 22:23
Quote: "Does anyone use the Unity LUA scripting plugin?"

no

Quote: "I do not want to have a window based message box popup when there is a script error."

use one of the free lua plugins. You can set the function which will be called upon every script error, so no message boxes if you don't want them

Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 3rd Feb 2012 03:06
Oh well.. Thanks Brendy boy.

MrValentine
AGK Backer
14
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Feb 2012 10:58
If you can cook up some code to test with UNITY plugin I have it so do not mind taking my time to test for you as then you will figure this out and I can learn how to use some lua stuff a fair trade no?

Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 3rd Feb 2012 13:11
Unity does everything else pretty well; its also got some inbuilt DBPRO commands.



I will look into using other plugins as Brendy suggested, specifically for runtime expressions later.

Expressions created like this, where the string to the right of the = sign would have come from the user, could cause unwanted error messages if the syntax is bad:

result = Lua Execute("calculatorResult = 360 * 45 / 5")
Print Lua Get String("calculatorResult")

For general development Unity will suffice, due to me already purchasing it. You have the options of compiling the Lua script anyway:

Quote: "It is often useful to have your scripts in the form of text files. However, when you distribute
your game, it is preferable to have all scripts in a compiled, non-human readable form. Using
the Lua Compiler, “Luac”, it is possible to precompile your scripts.
The main advantages of precompiling are: faster loading, protecting source code from user
changes, and off-line syntax error detection (so no errors are detected at run time).
You have two choices when compiling – using the standable LUAC compiler, or native Unity
functions.
1. To compile a script, simply run Luac.exe with a single argument – the file name of the
script to compile:
This will create the file luac.out, which is your compiled script. This file can be loaded using
LOAD LUA, just like any other file.
If you don’t want to call your output file output.luac, you can use the –o flag:
More information about the Lua compiler can be found on the Lua web site:
http://www.lua.org/manual/5.0/luac.html
2. For documentation for the functions LUA COMPILE STRING and LUA COMPILE
FILE, please see the Command Directory."


Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 3rd Feb 2012 13:25
Here is the plugin one I am going to try. It has the ability to call DBPRO functions directly. Unity can only use messages, or you'd need to return values from a unity function from DBPRO.

Barnski's LUA plugin

Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 3rd Feb 2012 19:35 Edited at: 3rd Feb 2012 20:48
So far Barnski's plugin has worked fine. The only problem is some strange syntax error reports: Like with the following, it thinks the array called 'Globals' is nil (undeclared) because there is a comment before it at the start of the script.

Take away the comment or put it after the initiation and it runs fine.



Edit:

I will switch back to Unity in this case, there are too many wierd lua syntax erros creeping up everywhere; lots of apparently undefined functions. Everything is being logged in a console and I can see the functions being declared prior to referencing them. Possibly the chunk scope of lua executions in this plugin are not quite what I expected in relation to what should be global values.

I will make do with silly error message boxes for now.

Login to post a reply

Server time is: 2025-05-08 08:36:05
Your offset time is: 2025-05-08 08:36:05