|
Post by azural on Feb 18, 2006 3:37:08 GMT -5
Clk:191828 Tid:92108 Scriptrunner.ExecuteScript: Returning from script with erro r: ...ne\Windower 3.21\plugins\Lunar\scripts\Leviathan.lua:975: attempt to conca tenate global `script_path' (a nil value)
Then the script ends... any idea?
|
|
sdphantom
Full Member
Savior and Destroyer
Posts: 230
|
Post by sdphantom on Feb 18, 2006 4:55:32 GMT -5
I decided to download this to help debug. Interesting, but I do see conditions that can cause problems. Also some modifications that will make the Leviathan capable of running without knowing the player's name. Along with a few optimizations.
|
|
|
Post by X-Drop on Feb 18, 2006 10:56:31 GMT -5
Clk:191828 Tid:92108 Scriptrunner.ExecuteScript: Returning from script with erro r: ...ne\Windower 3.21\plugins\Lunar\scripts\Leviathan.lua:975: attempt to conca tenate global `script_path' (a nil value) Then the script ends... any idea? I see that you removed the contents of the Leviathan folder. Why? Please look at the installation "Read Me.txt" again. It is a pretty straight forward install. - Unzip
- Move the "Leviathan" folder and the "Fish.lua" file into the Lunar/Scripts directory.
- Move the "Leviathan.txt" file into the Windower/scripts directory.
- Installation complete!
[EDIT]Oh, this just dawned on me... you must have been one of the three people that downloaded an imcomplete copy of Leviathan! Sorry bout that. I made a post about that fact earlier in case you missed it. What you need to do is download version 1.51 and all should be good.
I decided to download this to help debug. Interesting, but I do see conditions that can cause problems. Also some modifications that will make the Leviathan capable of running without knowing the player's name. Along with a few optimizations. Although it's not perfect, I am pretty excited to have a script run multiple threads to achieve a common goal. Hopefully future releases of Lunar will incorporate these multithreading ideas more fully. For instance, check out how pressing a hotkey in one thread simulates an instant change in another thread without actually having to stop and check for new commands. The idea of using something global like IsKeyBound() was actually Tiny Terrors idea to allow multiple threads to communicate. Before I was using some crazy reading/writing technique to produce a communication hub. But it was terribly slow because I had to create a semaphore to lock the comm file when it was being written to. As for the player name, yeah I could have used something like "/target <me>" then used FFXI.player_GetTargetName(), but I would rather just wait for FFXI.player_GetPlayerName() to work again.
|
|
sdphantom
Full Member
Savior and Destroyer
Posts: 230
|
Post by sdphantom on Feb 18, 2006 19:37:00 GMT -5
I decided to download this to help debug. Interesting, but I do see conditions that can cause problems. Also some modifications that will make the Leviathan capable of running without knowing the player's name. Along with a few optimizations. Although it's not perfect, I am pretty excited to have a script run multiple threads to achieve a common goal. Hopefully future releases of Lunar will incorporate these multithreading ideas more fully. For instance, check out how pressing a hotkey in one thread simulates an instant change in another thread without actually having to stop and check for new commands. The idea of using something global like IsKeyBound() was actually Tiny Terrors idea to allow multiple threads to communicate. Before I was using some crazy reading/writing technique to produce a communication hub. But it was terribly slow because I had to create a semaphore to lock the comm file when it was being written to. Actually, most of the work would be done to the way string.find() is used to make it more efficient. As for the player name, yeah I could have used something like "/target <me>" then used FFXI.player_GetTargetName(), but I would rather just wait for FFXI.player_GetPlayerName() to work again. Another change with how string.find() is used, instead of searching for the entire line, search for key components that only appear in the line you're looking for. EX: "fishing skill raises (0%.%d) points" or "fishing skill has reached level (%d)" Both string patterns should work with no need for the player's name to be known at all. Probably should add a check for chat type to make sure the line matched is not a fake, EX: someone relaying the exact message over the LS or /tell.
|
|
|
Post by X-Drop on Feb 18, 2006 20:43:29 GMT -5
Another change with how string.find() is used, instead of searching for the entire line, search for key components that only appear in the line you're looking for. EX: "fishing skill raises (0%.%d) points" or "fishing skill has reached level (%d)" Both string patterns should work with no need for the player's name to be known at all. Probably should add a check for chat type to make sure the line matched is not a fake, EX: someone relaying the exact message over the LS or /tell. The only reason I bother with the player's name is the rare possibility that the player is fishing in a crowded area and multiple catches are made within a small time frame. In that instance, the chance exist for the wrong line to be parsed. Using the player's name guarantees that the correct line is captured ever time. ^^
|
|
sdphantom
Full Member
Savior and Destroyer
Posts: 230
|
Post by sdphantom on Feb 19, 2006 2:49:37 GMT -5
Another change with how string.find() is used, instead of searching for the entire line, search for key components that only appear in the line you're looking for. EX: "fishing skill raises (0%.%d) points" or "fishing skill has reached level (%d)" Both string patterns should work with no need for the player's name to be known at all. Probably should add a check for chat type to make sure the line matched is not a fake, EX: someone relaying the exact message over the LS or /tell. The only reason I bother with the player's name is the rare possibility that the player is fishing in a crowded area and multiple catches are made within a small time frame. In that instance, the chance exist for the wrong line to be parsed. Using the player's name guarantees that the correct line is captured ever time. ^^ Good point, but that would only effect the item cought, which is a major thing. As for skillups, it doesn't matter since the server never does send skillup info of other players. There is still a mess in the paths that can be narrowed down to only one line per path varible assignment and there's a theoretical bug that would cripple Leviathan if the directory Windower was in didn't contain the word Windower. The plan I have to clean up the paths would fix this as well.
|
|
|
Post by X-Drop on Feb 19, 2006 12:33:02 GMT -5
Good point, but that would only effect the item cought, which is a major thing. As for skillups, it doesn't matter since the server never does send skillup info of other players. There is still a mess in the paths that can be narrowed down to only one line per path varible assignment and there's a theoretical bug that would cripple Leviathan if the directory Windower was in didn't contain the word Windower. The plan I have to clean up the paths would fix this as well. I would love to see your proposals. By all means, please post them.
|
|
Rexo
New Member
Posts: 2
|
Post by Rexo on Feb 19, 2006 13:19:39 GMT -5
hey X-drop i finally got this to kinda work...i got it to show, but when i catch a fish doesnt say the fish info or anything, doesnt keep count... it just doesnt work, and i see the red windower text that tells me to post that error up here.. can you help me out. thanks
|
|
|
Post by X-Drop on Feb 19, 2006 16:00:32 GMT -5
hey guys well i almost got the working... i did as instuctions said and its kida confusing... i get this when i try to load it out in gameplay...:"Desktop\windower\plugins\Lunar\scripts\Fish.lua:29 Error!Unable to open Leviathan.txt file." I have no idea whats going on, but can somepne here help me out? please, thanks! hey X-drop i finally got this to kinda work...i got it to show, but when i catch a fish doesnt say the fish info or anything, doesnt keep count... it just doesnt work, and i see the red windower text that tells me to post that error up here.. can you help me out. thanks When I read your first post on the 17th, I immeadiately saw that I needed to rewrite the lines for the Windower path. So I did that and uploaded the fix as version 1.51. Make sure you have that copy. I think it unzips as 4 items -- "Leviathan" folder, "Fish.lua", "Leviathan.txt", and a "Read Me.txt". After you install that, if you have any errors at run time just give me the details. Post the Windower console error line and I'll help you to figure out the problem.
|
|
sdphantom
Full Member
Savior and Destroyer
Posts: 230
|
Post by sdphantom on Feb 19, 2006 18:17:04 GMT -5
I haven't tested the modification to this function, but the origional worked fine in my other scripts. The only change is how the windower path is found and the text that displays if unable to create the windower script file. It includes a cleanup line to dispose of the script file when finnished executing. function runCmd(cmd) -------------------------------------------------------------------------------------------------------- local _,_,windowerPath=string.find(debug.getinfo(1).source,"^(.+[\\/])plugins[\\/]Lunar[\\/]Scripts[\\/]") local scriptFile=string.gsub(os.tmpname(),"[\\/%.]","")..".tws" local fopt=io.open(windowerPath.."scripts/"..scriptFile,"wt")
if fopt then fopt:write(cmd) fopt:close() Windower.console_Exec(scriptFile,true) os.remove(windowerPath.."scripts/"..scriptFile)
return true else Windower.console_Write("Unable to open command script.") return false end -------------------------------------------------------------------------------------------------------- end
|
<Edit: Returns true if successful or false on error.> <Edit: Rewrote the script filename generator to include the '\' bugfix internally> <Edit: Fixed "string.gsub()", used to be "script.gsub()">
|
|
imk
New Member
madness?
Posts: 13
|
Post by imk on Feb 19, 2006 19:06:11 GMT -5
vim for the win!!!!!!!!!!!!!!!!!!!!
|
|
|
Post by X-Drop on Feb 19, 2006 21:51:55 GMT -5
function runCmd(cmd) -------------------------------------------------------------------------------------------------------- local _,_,windowerPath=string.find(debug.getinfo(1).source,"^(.+[\\/])plugins[\\/]Lunar[\\/]Scripts[\\/]") local scriptFile=script.gsub(os.tmpname(),"[\\/%.]","")..".tws" local fopt=io.open(windowerPath.."scripts/"..scriptFile,"wt")
if fopt then fopt:write(cmd) fopt:close() Windower.console_Exec(scriptFile,true) os.remove(windowerPath.."scripts/"..scriptFile)
return true else Windower.console_Write("Unable to open command script.") return false end -------------------------------------------------------------------------------------------------------- end
|
Nicely done!^^ I had a feeling you were gonna grab the path with "Windower" included rather than use "Windower" in the search. Got a couple of questions because I'm unfamilar with the os.tmpname() function. - What does the "wt" option do?
- Does that actually create a new file??
- What is the extension ".tws" for?
If "wt" does what I think it does, thats awsome. I looked it up but I could never find references for it. vim for the win!!!!!!!!!!!!!!!!!!!! huh?
|
|
sdphantom
Full Member
Savior and Destroyer
Posts: 230
|
Post by sdphantom on Feb 20, 2006 0:49:39 GMT -5
function runCmd(cmd) -------------------------------------------------------------------------------------------------------- local _,_,windowerPath=string.find(debug.getinfo(1).source,"^(.+[\\/])plugins[\\/]Lunar[\\/]Scripts[\\/]") local scriptFile=string.gsub(os.tmpname(),"[\\/%.]","")..".tws" local fopt=io.open(windowerPath.."scripts/"..scriptFile,"wt")
if fopt then fopt:write(cmd) fopt:close() Windower.console_Exec(scriptFile,true) os.remove(windowerPath.."scripts/"..scriptFile)
return true else Windower.console_Write("Unable to open command script.") return false end -------------------------------------------------------------------------------------------------------- end
|
Nicely done!^^ I had a feeling you were gonna grab the path with "Windower" included rather than use "Windower" in the search. Thx. ^.^ Given that "plugins" is a required folder for windower plugins to work and "Lunar\Scripts" is required for Lunar to run scripts, I decided to use those. I know of ways to make this function crash, but it'll be far beyond accidental to do so. <Edit: Oh, be sure to get the updated version. I fixed a small mistake in calling the string.gsub() function. (Mistyped it as "script.gsub()".)> Got a couple of questions because I'm unfamilar with the os.tmpname() function. os.tmpname() basically returns a random filename that is guarenteed not to exist at the time it's called. There might be some confusion between the "member of" operator "." and the string concatenation operator "..". I hope stating this clears things up as well. What does the " wt" option do? Lua uses the same file mode definitions as C: - "w" - Basic write mode (overwrites the contents of the entire file, creates a new file if it doesn't exist), Defaults to text mode
- "wt" - Write text mode (does basic string conversions to make text user-readible depending on OS platform)
- "wb" - Write binary mode (writes to file with no text conversions, binary-safe)
Does that actually create a new file?? Yes, a new file is created if one doesn't exist already. If a file by that name does exist (shouldn't anyway) and the script has permissions to write to that file, the file contents will be erased and written over. The only way an error can occur in write mode is if the script doesn't have permission to create or write to the specified file. Permission errors are caught by the function internally, so it's self-sufficient. The file is also deleted once Windower is finnished executing it for cleanup. What is the extension " .tws" for? ".tws" is just an extention I made up as an extra step to make sure the file generated is unique. It's supposed to stand for "Temapary Windower Script". It doesn't really matter what changes you make to the filename at that point, the script will still know what to do. If "wt" does what I think it does, thats awsome. I looked it up but I could never find references for it. It's an old C definition for the filemode. Lua doesn't document it since it's the default anyway. All Lua says in it's documentation is on page 52 of the PDF. "This string is exactly what is used in the standard C function fopen."
|
|
sdphantom
Full Member
Savior and Destroyer
Posts: 230
|
Post by sdphantom on Feb 20, 2006 2:28:45 GMT -5
I've held my comment until after I fixed some things. Check out how pressing a hotkey in one thread simulates an instant change in another thread without actually having to stop and check for new commands. Actually, the script is stopping and checking commands at some point. Until we can get event callbacks, nobody can really say this truthfully. What I see that's eliminated is the check for what command is being executed. Instead, it's taking in the command as a function name. I see the script is made more to interface with it's GUI rather than CLI, but the script can crash if a user decides to send a command manually to the script. The idea of using something global like IsKeyBound() was actually Tiny Terrors idea to allow multiple threads to communicate. Before I was using some crazy reading/writing technique to produce a communication hub. But it was terribly slow because I had to create a semaphore to lock the comm file when it was being written to. It works, but this is another example of dirty code. It's capable of causing interference with other scripts running. Slim chance given the number of keys that can be bound and the different shift states, but still possible enough to happen by accident. Other than using the command function I posted to send commands to other scripts (better idea), we'll pretty much need that IPC lib that Tiny has in one of the upcoming versions.
|
|
sdphantom
Full Member
Savior and Destroyer
Posts: 230
|
Post by sdphantom on Feb 20, 2006 2:59:26 GMT -5
Here's the rewritten path function. function define_path() -------------------------------------------------------------------------------------------------------- local i,j -- temperary placeholder varibles (not used, just shifts the important varible over)
i,j,script_path = string.find(debug.getinfo(1).source,"(.+[\\/]Lunar[\\/]Scripts[\\/].+[\\/])") i,j,dir_name = string.find( Windower.script_GetArg(1),"(.+[\\/])") i,j,lunar_path = string.find(debug.getinfo(1).source,"(.+[\\/]Lunar[\\/]Scripts[\\/])") i,j,windower_path = string.find(debug.getinfo(1).source,"^(.+[\\/])plugins[\\/]Lunar[\\/]Scripts[\\/]") -------------------------------------------------------------------------------------------------------- end
|
2 of the varibles can easily be derrived from the others. function define_path() -------------------------------------------------------------------------------------------------------- local i,j -- temperary placeholder varibles (not used, just shifts the important varible over)
i,j,windower_path = string.find(debug.getinfo(1).source,"^(.+[\\/])plugins[\\/]Lunar[\\/]Scripts[\\/]") i,j,dir_name = string.find( Windower.script_GetArg(1),"(.+[\\/])")
lunar_path = windower_path.."plugins\\Lunar\\Scripts\\" script_path = lunar_path..dir_name -------------------------------------------------------------------------------------------------------- end
|
|
|