nebula
Junior Member
fear.
Posts: 59
|
Post by nebula on Dec 15, 2005 15:47:10 GMT -5
anyway to catch when the script is going to be unloaded and run commands at that point? and i figured since you're catching unload, why not catch command
|
|
|
Post by X-Drop on Dec 15, 2005 16:55:07 GMT -5
hmmm... not sure what you mean? If you want to catch the script as its unloading, well just add whatever your trying to accomplish at the very end of the script. After your main loop is no longer true or whatever, the script will read those last few lines before it unloads. When you say "run commands", are you just talking about sending a command for the script through the console? Don't see the point at the end of your script, but you could Control.control_SendString("/console .Lunar command yourscript.lua yourcommandhere". Or even use a hotkey to send a command like, Control.control_BindKey("F1",true,false,false,".Lunar command yourscript.lua yourcommandhere")But again, I gotta wonder why you are calling commands as your script is unloading.
|
|
nebula
Junior Member
fear.
Posts: 59
|
Post by nebula on Dec 15, 2005 17:12:28 GMT -5
But again, I gotta wonder why you are calling commands as your script is unloading. to unbind things assumed unload jes killed the thread, didn't even think to add something after the main loop ^^;
|
|
|
Post by me3you2 on Dec 15, 2005 18:18:56 GMT -5
I have been messing around with Windower.script_GetArg Windower.script_GetArgCount Windower.script_GetCommandCount Windower.script_GetCommand
I created two functions in my script
function GetArguments() ArgArray = {} ArgCount=Windower.script_GetArgCount( ) for arg=1,ArgCount-1,1 do -- The 1st Argument is the script's name. Argument=Windower.script_GetArg(arg) ArgArray[arg] = Argument end --end for end --end function function GetCommands () CommandArray = {} CommandCount = Windower.script_GetCommandCount( ) if CommandCount ~= 0 then for cmd=1,CommandCount,1 do Command=Windower.script_GetCommand() CommandArray[cmd] = Command end -- end if end --end for end --end function
I call GetArguments() right before the main while loop, and GetCommand() at the start of the main loop.
I wrote this last night at like 2AM so if it needs fixing let me know.
|
|
|
Post by X-Drop on Dec 15, 2005 22:53:54 GMT -5
If you open the console and unload the script, you will kill the script immeadiately. Thus all of your hot keys will still be binded. Best thing to do is incorperate a way of killing your main loop with a hotkey. Something that will make your while loop no longer true. Now when the script leaves the main loop, it will read all the way to the very last lines of the script. Here is where you may want to make a function call to unbind any hotkeys.
|
|
|
Post by TinyTerror on Dec 21, 2005 22:01:22 GMT -5
I could add a callback so that the Unload() function in your script is called by lunar automatically when the script is unloaded. It would be really easy. The only thing I think might be a problem is that people might not understand how callbacks work. It can always be an optional feature.
|
|
|
Post by digikun on Dec 22, 2005 3:39:23 GMT -5
Also one thing that would be nice is to automaticly clear keys that have been pressed down by the script.
It creates a problem when, for example, I have a loop that presses a key for a set amount of time then depresses the key. If the script is killed in the middle of that delay it creates a problem where windower considers the key pressed at all times.
|
|
|
Post by TinyTerror on Dec 22, 2005 8:30:00 GMT -5
Also one thing that would be nice is to automaticly clear keys that have been pressed down by the script. It creates a problem when, for example, I have a loop that presses a key for a set amount of time then depresses the key. If the script is killed in the middle of that delay it creates a problem where windower considers the key pressed at all times. Thats a good point. I should be able to do this pretty easily. I'll just keep a list of all the keys the script has currently pressed and unpress them on unload.
|
|
|
Post by chanterelle on Jan 24, 2006 15:32:13 GMT -5
How about input callbacks? I think that would be easier to code for than binding, unless I don't understand how binding works. Currently I just bind keys so that they send commands back to my script, which is pretty bass ackwards.
|
|