View Full Version : Mastiff's at it again - LUA help, please!
Mastiff
May 20th, 2005, 11:39 AM
This will be a long night, I fear... I like to start with whatever I believe will give me the most problems, and sure enough... I'm trying to get the new NetRemote Feedback LUA to work, but where to put it? It's not working in the main directory, and creating a directory below Girder, called LUA, doesn't work either. Or does it? I try to fire this command:
NetRemote.SendLabel("PowerState", GirderPowerState)
The error message is:
[string "Z:\Kopi av Kino.GML:\NetRemote og stua\Pana..."]:10: attempt to index global `NetRemote' (a nil value)
stack traceback:
[string "Z:\Kopi av Kino.GML:\NetRemote og stua\Pana..."]:10: in main chunk
As always, help will be appreciated, and even more if it comes without the (probably well deserved) intro: "You moron, you should know that..." :roll: :wink:
Rob H
May 20th, 2005, 12:07 PM
Put it in the luascript directory then use
require("NetRemote Feedback") in any script that needs feedback
Mastiff
May 20th, 2005, 12:19 PM
Thanks, Rob! Now it's free to really confuse me! :oops:
...rogramfiler\Promixis\Girder\luascript\compat-5.1.lua:66: C:\Programfiler\Promixis\Girder\luascript\NetRemot e Feedback.lua:663: malformed number near `0.091'
stack traceback:
[C]: in function `assert'
...rogramfiler\Promixis\Girder\luascript\compat-5.1.lua:66: in function `require'
[string "Z:\Kopi av Kino.GML:\NetRemote og stua\Pana..."]:1: in main chunk
Rob H
May 20th, 2005, 12:37 PM
What version of G4?
Mastiff
May 20th, 2005, 12:38 PM
Latest, Alpha 17 from May 13.
Rob H
May 20th, 2005, 12:40 PM
Strange, it's working here with that version - there's nothing wrong with that number.
Unless it's a localisation issue? What do you use in Norway to indicate a decimal point?
Mastiff
May 20th, 2005, 12:43 PM
A comma.
Edit: And you're right. Thanks! Changing that to a dot and restarting Girder fixed that problem. Is that something that can be fixed in Girder/LUA, or do I have to remember to change decimal sign on every computer?
So I'm at the next one:
Loading NetRemote Feedback.lua
LOAD
Varmepumpen står på 1
Setting PowerState to "1"
[string "Z:\Kopi av Kino.GML:\NetRemote og stua\Pana..."]:14: attempt to call global `RegSetStringValue' (a nil value)
stack traceback:
[string "Z:\Kopi av Kino.GML:\NetRemote og stua\Pana..."]:14: in main chunk
Something tells me that the synthax for setting values to the Windows registry are different in LUA 5. Gotta check that.
Rob H
May 20th, 2005, 12:48 PM
Okay, try changing the '.' to a comma at line 633, and maybe put a space after the number and before the real comma
Mastiff
May 20th, 2005, 12:50 PM
Eh...how do I find line 633? It takes a while to count... :wink:
Rob H
May 20th, 2005, 12:50 PM
That's one for Ron.
It's certainly a bit worrying
Mastiff
May 20th, 2005, 12:51 PM
Talk about crossposting!
Rob H
May 20th, 2005, 12:53 PM
Eh...how do I find line 633? It takes a while to count... :wink:
That was for NetRemote Feedback, not the problem you currently have.
For your current problem take a look in the help for Lua Scripting, and follow the link to the Registry object
Mastiff
May 20th, 2005, 12:55 PM
Thanks! And I know that it was for the feedback, but I think I'll just stay with the . as the decimal point for now, at least until Ron says something about this.
Rob H
May 20th, 2005, 01:03 PM
What are you using to edit Lua files?
I use SciTE from http://www.scintilla.org
Ron
May 20th, 2005, 01:11 PM
Okay help me out here what is the problem?
Mastiff
May 20th, 2005, 01:13 PM
Well, I have tried... As usual I think I need it spelled out for me the first time... This is what I have arrived at so far, from the help file:
RegObj = win.CreateRegistry ('HKEY_LOCAL_MACHINE', 'Software\\Varmepumpe\\PowerState\\', GirderPowerState, Create = 1)
But it complains that:
`)' expceted near `='
And as usual I'm stumped... I'm just tring to write the Girder variable GirderPowerState to the registry key shown...
Mastiff
May 20th, 2005, 01:15 PM
This crossposting is making me crazy! Ron, that one was for Rob. For you: A comma as a decimal point (instead of a dot) breaks Rob's NetRemote Feedback.
Rob H
May 20th, 2005, 01:17 PM
That should just be
RegObj = win.CreateRegistry ('HKEY_LOCAL_MACHINE', 'Software\\Varmepumpe\\PowerState\\', GirderPowerState, 1)
Ron
May 20th, 2005, 01:21 PM
That's why you should not post 2 questions in 1 thread :-)..
Numbers must use the dot, don't use the comma.
Mastiff
May 20th, 2005, 01:32 PM
Thanks. Almost there... This creates the registry "subbranch" (don't know what they are called) PowerState below Varmepumpe, not the value PowerState = 1 or 0 in the branch Varmempumpe.
Rob H
May 20th, 2005, 01:33 PM
The thing is that NetRemote Feedback.lua does use the dot but still gave an error in http://www.promixis.com/phpBB2/viewtopic.php?p=118587#118587
Post
I'm not entirely sure what Tor changed to get it to work.
Ron
May 20th, 2005, 01:34 PM
Weird. Don't tell me Lua uses localized numbers.
Mastiff
May 20th, 2005, 01:35 PM
Rob, I changed to the dot under localized settings.
Ron, it didn't with version 4, at least. Because I have never had that problem before.
Ron
May 20th, 2005, 01:36 PM
Thanks Mastiff, so it does use localized numbers, adding to todo list. So that it does not.
Rob H
May 20th, 2005, 01:38 PM
Thanks. Almost there... This creates the registry "subbranch" (don't know what they are called) PowerState below Varmepumpe, not the value PowerState = 1 or 0 in the branch Varmempumpe.
Okay. You probably want something like
RegObj = win.CreateRegistry ('HKEY_LOCAL_MACHINE', 'Software\\Varmepumpe\\', 1)
RegObj:Write("PowerState", GirderPowerState)
RegObj:CloseKey()
RegObj:Destroy()
Mastiff
May 20th, 2005, 01:38 PM
Thanks, Rob! And this is just the start of my weekend... To bad I need such a long thing for a simple registry write? It will be a lot of manual replacing in my scripts...
But good night for now!
Rob H
May 20th, 2005, 01:41 PM
Weird. Don't tell me Lua uses localized numbers.
Yeah, certainly looks like it. Not a great design decision is it!? One would hope there's a way to turn that off
Rob H
May 20th, 2005, 01:42 PM
Thanks, Rob! And this is just the start of my weekend... To bad I need such a long thing for a simple registry write? It will be a lot of manual replacing in my scripts...
Well you could always create a RegSetStringValue function that wraps all of that up.
But good night for now!
'night
Ron
May 20th, 2005, 01:43 PM
Not smart of Lua indeed. There is a way in Windows - SetLocaleInfo.
edit. SetLocale is no good.
Mastiff
May 20th, 2005, 01:44 PM
Rob, didn't reach the bed in time for that one... He-he... Functions... That means an external LUA file, right? :oops:
Rob H
May 20th, 2005, 01:45 PM
But won't that screw up localisation of date handling?
Mastiff
May 21st, 2005, 12:32 AM
At least for NetRemote that's possible to set on the clients, right?
Rob H
May 21st, 2005, 01:21 AM
Good point
Mastiff
May 21st, 2005, 05:15 AM
Woops...there's a much easier way to set the registry:
r = win.RegSetStringValue ("HKEY_LOCAL_MACHINE", "Software\\Varmepumpe","Horisontal dyse", GirderHorisontal );
Rob H
May 21st, 2005, 05:23 AM
Ah, missed that one!
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.