Post by sabotender on Jan 28, 2006 4:25:35 GMT -5
I'm trying to build a script that you call after you hook a fish and decide that you want to reel it in. I am doing this because the fishing system kills my hands after an hour or two.
What I'm looking for is to have someone more familiar with Lua / Lunar review this and see if I'm using the commands and syntax properly as well as offer any suggestions as to optimizing the code (is recursion in Lua / scripting a bad idea? >_>)
I would implement acctually running the script by setting up a hotkey in windower, probably bound to Alt-F1, that does the following:
The following is my basic logic for the script:
following is my attempt at writing the script itself:
I have, as should be obvious, borrowed heavily from some other implementations that do similar (as far as the logic is concerned).
Will my final end command unload the script or will I need to pass an unload command to the windower? I'm also unsure if I closed out all my nested statements properly in the "beatsFish" function.
This code is obviously untested and since I have yet to use Lunar is there anything in the above (assumeing it's not complete garbage) that is currently broken?
EDIT: it also occurs to me that perhaps this is an undesireable project to have posted? Seeing as you need to start the thing every time you fish, and have to acctually manually start the fishing perhaps it's ok? obviously remove (or I will) if this shouldn't be here >_>
What I'm looking for is to have someone more familiar with Lua / Lunar review this and see if I'm using the commands and syntax properly as well as offer any suggestions as to optimizing the code (is recursion in Lua / scripting a bad idea? >_>)
I would implement acctually running the script by setting up a hotkey in windower, probably bound to Alt-F1, that does the following:
.Lunar load fishBeats.lua
The following is my basic logic for the script:
base%=stamina%
beatsFish(d, base%)
function beatsFish(key, staminaOld)
IF stamina%==0
push "ENTER"
ELSE
push key
staminaNew=stamina%
if staminaNew < staminaOld
fight(key, staminaNew)
else
fight(~key, staminaNew)
following is my attempt at writing the script itself:
function pushKey(Key, Duration)
Control.control_SetKey(Key,true)
Windower.script_Sleep(Duration)
Control.control_SetKey(Key,false)
end
function beatsFish(direction, staminaOld)
if staminaOld==0 then pushKey("NUMPADENTER", 10)
else
pushKey(direction, 50)
staminaNew=FFXI.target_GetHPPercent( )
if staminaNew<staminaOld then beatsFish(direction, staminaNew)
elseif direction=="D" then beatsFish("S", staminaNew)
else beatsFish("D", staminaNew) end
end
end
baseStamina=FFXI.target_GetHPPercent( )
beatsFish("D", baseStamina)
end
I have, as should be obvious, borrowed heavily from some other implementations that do similar (as far as the logic is concerned).
Will my final end command unload the script or will I need to pass an unload command to the windower? I'm also unsure if I closed out all my nested statements properly in the "beatsFish" function.
This code is obviously untested and since I have yet to use Lunar is there anything in the above (assumeing it's not complete garbage) that is currently broken?
EDIT: it also occurs to me that perhaps this is an undesireable project to have posted? Seeing as you need to start the thing every time you fish, and have to acctually manually start the fishing perhaps it's ok? obviously remove (or I will) if this shouldn't be here >_>