View Full Version : GVMS upgrade -> LUA!
Ron
October 13th, 2002, 03:55 PM
Hi People,
I'm going to move to Lua as the default scripting language, GVMS will be available as an optional download. I've been thinking about implementing a system where girder can accept multiple scripting languages but it turns out that this gives some rather big problems with the variables. Besides I'm providing the GVMS for people that still need it.
Change will be done in the next release of Girder, unless someone can give some compelling reasons not to.
People that are interested in the posibilities of Lua can visit the Lua homepage (http://www.lua.org). Its a complete scripting language that can do just about anything you imagine. ( as long as the support libraries are compiled into the script ;-) ) I'll also do something about the tiny edit box that we now have to use to edit the script.
Marsupial
October 13th, 2002, 03:55 PM
Will it be possible to simply "translate" the script?
that would be just great.
vynce
October 13th, 2002, 03:55 PM
Sounds cool! I can't wait to upgrade my GVMS scripts to Lua.
Ron
October 13th, 2002, 03:55 PM
There will be no automatic translation program,... just yet ( time considerations ) but upgrading should be relativly easy for people that programmed before.
If you want to play around with lua already read this post
http://www.girder.nl/phpBB2/viewtopic.php?t=2003
vynce
October 13th, 2002, 03:55 PM
I have been playing with Lua for the last few hours converting my GVMS scripts. So far it is working really well. I have found one bug though, and have a question.
First the bug. When the Girder Variable Display window is open and you create and then delete a double float in two separate commands, the list of variables is not updated properly and duplicates of other variables appear, most commonly PI and result. So,
Group
|
--Lua Command1: a = 10
|
--Lua Command2: a = nil
If Command1 then Command2 are executed manually one after the other then duplicates of variables will appear in the Variable Display window.
Now the question. In GVMS if you assigned a float to an integer it would just be truncated (ie. int a = 10/3;). Since there are no integers in Lua this doesn't work. Is there an easy way to truncate the end of a float. I have been using format() to do it, which works, but seems kind of messy (ie. a = format("%d", 10/3) ).
Thanks
Ron
October 13th, 2002, 03:55 PM
aah the bug is just an improper refresh of the window. Adding to the todo list.
About the rounding problem, I've added a function called "round" to Lua.
[double result] = round([value], [decimal places] ) ;
eg:
a = round ( 20/3, 10);
a will be 6,6666666666
the updated Lua scripting engine.
http://www.girder.nl/temp/gvms.zip
vynce
October 13th, 2002, 03:55 PM
Cool, thanks for the function. It works well for rounding, but I need truncation :). If I have 0.999 I want it to return 0, not 1 (just chop the end off). So, I wrote this Lua function which mostly works. Perhaps you could write a better one and integrate it into Lua.
function truncate(n)
local decimal = strfind(n, "%.")
if decimal == nil then
return n
else
return tonumber(strsub(n, 1, decimal-1))
end
end
I also found another bug which I'm sure you know about and will be fixed when you release the next version of Girder, but here it is anyway. F11 doesn't work anymore for resetting the variables to default. This is useful for debugging scripts.
Thanks
Edit: My truncate() function is having problems with very small numbers (ie. 0.0000347). I think this is because it is not finding the . (decimal point) properly. Maybe there is another way to truncate numbers (?). I have also modified the above code slightly and clarified my definition of truncation.
Edit Again: The problem is that Lua represents 0.0000347 as 3.47E-5 (which I'm sure most, if not all, languages would do). So, 3.47E-5 is truncated to 3 :(. I think I either need to find a way of storing the number as a string and not a number, converting the scientific notation back to the correct number format and storing it as a string, or just detect the E- in there.
vynce
October 13th, 2002, 03:55 PM
Well, I have a new truncate function which works with small scientific notated numbers and regular numbers. It still won't work with very big numbers though (ie. 99999999999).
Deleted. Had bugs.
function truncate(n)
decimal = strfind(n, ".", 1, 1)
if decimal == nil then
return n
elseif strfind(n, "e-", 1, 1) ~= nil then
return 0
else
return tonumber(strsub(n, 1, decimal-1))
end
end
Edit: My fixed truncate function didn't actually work properly. I've tested this one and it seems to work, but you never know :-?
Ron
October 13th, 2002, 03:55 PM
truncation thats easy :-)
round( value - 0.5 , 0 );
vynce
October 13th, 2002, 03:55 PM
aahahahaha :lol:. That is a really simple solution compared to my huge, buggy truncation function! Well, at least I learned how to use Lua a bit better :D. Thanks Ron.
levyshay
October 13th, 2002, 03:55 PM
Anyone has an idea why:
TimerOSD = 123;
and then in OSD Popup plugin putting [TimerOSD]
Works fine, But:
TimerOSD = "OFF";
and then in OSD Popup plugin putting [TimerOSD]
Causes OSD Popup plugin to beep my PC speaker (The text is displayed correctly)??
Shay Levy.
BTW: I'm using this : http://www.girder.nl/temp/gvms.zip Lua plugin.
Mark F
October 13th, 2002, 03:55 PM
I don't think PopUp Plugin is causing this beep directly (on purpose). There are NO calls to sound generating code in the plugin sources. The beep may be a side effect caused by the plugin calling the Girder API but this has not changed for some time.
levyshay
October 13th, 2002, 03:55 PM
I don't think PopUp Plugin is causing this beep directly (on purpose). There are NO calls to sound generating code in the plugin sources. The beep may be a side effect caused by the plugin calling the Girder API but this has not changed for some time.
I didn't mean that also, What I think is that the string generated by LUA contains 0x7 at the end so Popup OSD beeps.
Shay Levy.
Holger
October 13th, 2002, 03:55 PM
aah the bug is just an improper refresh of the window. Adding to the todo list.
About the rounding problem, I've added a function called "round" to Lua.
[double result] = round([value], [decimal places] ) ;
eg:
a = round ( 20/3, 10);
a will be 6,6666666666
the updated Lua scripting engine.
http://www.girder.nl/temp/gvms.zip
Hi Ron,
Sorry, but this is not a round function, because this would result in 6,6666666667 ..... ;-)
Best Regards
Holger
Ron
October 13th, 2002, 03:55 PM
oh come on.
Holger
October 13th, 2002, 03:55 PM
oh come on.
:D
vBulletin® v3.7.4, Copyright ©2000-2008, Jelsoft Enterprises Ltd.