intp
New Member
Posts: 5
|
Post by intp on Apr 14, 2006 0:13:52 GMT -5
Is there any other way you can get peoples attention if they don't have the game in focus using lua? like playing a sound file or making a system noise or bringing the game back into focus?
|
|
intp
New Member
Posts: 5
|
Post by intp on Apr 14, 2006 18:32:39 GMT -5
another quick question I can't seem to find the answer on... How do I force a script to end? I want something like if (Windower.script_GetCommand() == "quit") then <end script> end
thanks
|
|
|
Post by TinyTerror on Apr 17, 2006 14:32:45 GMT -5
I think there might be a command in lua's system library to execute a system command. You could use this to launch a wav sound in winamp or window's built in sound player. Its a ghetto fix, but it should work until I can figure out sound.
|
|
|
Post by TinyTerror on Apr 17, 2006 14:42:10 GMT -5
As for your second question, yes there is a command to exit from a script. Normally I would recomend that you try to use good programming practices to allow the script to end on its own, but sometimes this is more trouble than it's worth. The command you are looking for is ScriptRunner.scriptExit. It doesn't take any arguments or return any values (I think, cant check because I am at work). I left it undocumented for a reason. Yes, it will exit your script, but it does so in a way that is not well tested. Essentially it trigger's the script's internal exit hooking mechanism. This will cause the script to think it has been asked to unload by Lunar. If all goes well it will exit without a problem. This function is in there as a debug tool for my use while testing. This being said, I have not tested it very much, and it may malfunction. Give it a try, and let me know if it melts ffxi.
The problem with Lunar is that it is full of moving pieces all connected together. The end user only actually sees the very top of whats going on under the hood. Hell, even I only ever see half of what's happening. The rest remains a mystery to all but god. Many of my projects turn out like that for some reason.
|
|
sdphantom
Full Member
Savior and Destroyer
Posts: 230
|
Post by sdphantom on Apr 20, 2006 1:36:20 GMT -5
A good way to exit a script is like this:
while true do
-- Code Block
local cmd=Windower.script_GetCommand()
if cmd=="quit" then break elseif cmd="someOtherCommand" then -- Command Block end
-- Code Block
end
The Break command forces the interpreter to exit out of the innermost loop. Since the entire script is just 1 single loop, Break exits the script.
Reguarding use of the os.execute() command. I have played around with this for a while. When executed, some programs will halt the launcher's process. Executing these programs directly using os.execute() will cause FFXI to freeze until the program executed is closed.
I did find a way to counter this by calling a windows system command to isolate the executed program from the launcher. This is done by calling Start with the program path as an argurment.
Example:os.execute("start c:\path\to\file.exe fileArguements")
|
|
|
Post by TinyTerror on Apr 20, 2006 8:54:05 GMT -5
Well, if os.execute is a blocking command, there should be a non blocking counterpart somewhere. It doesn't make sense for the language to just have blocking only, since the blocking behavior is artificial anyway. The process you are statring with os.execute is seperate from lunar, and really has no reason to require blocking.
|
|
sdphantom
Full Member
Savior and Destroyer
Posts: 230
|
Post by sdphantom on Apr 20, 2006 21:52:49 GMT -5
From the behaviour of os.execute(), I gather that it simply calls the C function, system(), which does block.
Right down to the way the OS works, every program executed is run through the OS command module, aka Console. If a program is started by the user, a new Console is created for that program. Most programs hide the console so the end user never realizes it's there.
I'm sure you know about call stacks, so I'll cut that part of the explanation. Basically, one call stack exists for every Console. When using the C function, system(), it adds the command sent to the call stack. system() does not return until after the command sent is finnished. To counter this, send the Start command with the actual system call as it's arguement to force the OS to spawn a new Console for the call instead of executing it on top of the current stack, causing system() to return immediately even if the command sent hasn't finnished.
Using Start as part of the system call is a workaround. I know you won't let me go into Lua interpreter's source code and make it a permanent fix, lol.
|
|