Hi all,
I made a script in MUSH to calculate the accuracy of my weapons as I'm sailing on my boat in MM. I was able to work out the basics of the code but for some reason, only 2 of the weapons are working correctly, and the others don't. This is the error I am getting
My variables are:
Basically, the code captures the following string:
Your ship fires * * at *, and * land.
The syntax of that string is: Your ship fires <amount> <weapon type> at <shipname>, and <amount> land(s).
I have the code to convert the words (ten nine eight, etc) to the numerical values, and to crunch the math, then to display that numerical value as a %.
This is how I have the string formatted:
Your ship fires ([^\s]+) (.+) at (.+)\, and ([^\s]+) land
I can get the heavy and light ballistae accuracy, but for everything else it says:
L CANNON : -1.#IND%
FIRE LAUNCHER : -1.#IND%
Or:
H BALLISTA : 0%
L BALLISTA : 0%
The following is my code for that matched string:
I don't understand why I cannot get the script working, but I know from previous programming experience that it is something trivial, like a comma or period somewhere.
My other question is:
I'm wanting to record the # of gold-ingots recovered per trip (a trip being leaving docks and returning). My question is how do I enable the variable when I leave docks (I have strings that I can match when I leave) and then disable that same variable when I dock again?
I appreciate any help in this matter, and apologize for the length of my post. I figure more information is better than being vague.
Thanks,
Forral
I made a script in MUSH to calculate the accuracy of my weapons as I'm sailing on my boat in MM. I was able to work out the basics of the code but for some reason, only 2 of the weapons are working correctly, and the others don't. This is the error I am getting
[AWAY][Mail][*][SPK](450hull SEdir SLOW SEwind 100%shld 1385, 594) You give the order to fire!
BOOM! Your ship fires ten basic-cannon rounds at Exposed Plague, and six land.
Run-time error
World: Materia Magica - Forral
Immediate execution
[string "Trigger: "]:72: bad argument #1 to 'GetVariable' (string expected, got nil)
stack traceback:
[C]: in function 'GetVariable'
[string "Trigger: "]:72: in main chunk
Exposed Plague's shields absorb the full force of the cannon.
Smiling Norba, the Sea Queen tells you, 'Yer gonna regret that! Arr!@#'
My variables are:
ingaverage
ingot
ship_firelauncher_hit
ship_firelauncher_shot
ship_harpoon_hit
ship_harpoon_shot
ship_hballista_hit
ship_hballista_shot
ship_lballista_hit
ship_lballista_shot
ship_hcannon_hit
ship_hcannon_shot
ship_lcannon_hit
ship_lcannon_shot
ship_mcannon_hit
ship_mcannon_shot
Basically, the code captures the following string:
Your ship fires * * at *, and * land.
The syntax of that string is: Your ship fires <amount> <weapon type> at <shipname>, and <amount> land(s).
I have the code to convert the words (ten nine eight, etc) to the numerical values, and to crunch the math, then to display that numerical value as a %.
This is how I have the string formatted:
Your ship fires ([^\s]+) (.+) at (.+)\, and ([^\s]+) land
I can get the heavy and light ballistae accuracy, but for everything else it says:
L CANNON : -1.#IND%
FIRE LAUNCHER : -1.#IND%
Or:
H BALLISTA : 0%
L BALLISTA : 0%
The following is my code for that matched string:
howmany = 0
hits = 0
if "%1" == "ten" then
howmany = 10
elseif "%1" == "nine" then
howmany = 9
elseif "%1" == "eight" then
howmany = 8
elseif "%1" == "seven" then
howmany = 7
elseif "%1" == "six" then
howmany = 6
elseif "%1" == "five" then
howmany = 5
elseif "%1" == "four" then
howmany = 4
elseif "%1" == "three" then
howmany = 3
elseif "%1" == "two" then
howmany = 2
elseif "%1" == "one" then
howmany = 1
elseif "%1" == "zero" then
howmany = 0
end
if "%4" == "ten" then
hits = 10
elseif "%4" == "nine" then
hits = 9
elseif "%4" == "eight" then
hits = 8
elseif "%4" == "seven" then
hits = 7
elseif "%4" == "six" then
hits = 6
elseif "%4" == "five" then
hits = 5
elseif "%4" == "four" then
hits = 4
elseif "%4" == "three" then
hits = 3
elseif "%4" == "two" then
hits = 2
elseif "%4" == "one" then
hits = 1
elseif "%4" == "zero" then
hits = 0
end
if "%2" == "heavy-ballista rounds" then
weapon_shot = "ship_hballista_shot"
weapon_hit = "ship_hballista_shot"
elseif "%2" == "light-ballista rounds" then
weapon_shot = "ship_lballista_shot"
weapon_hit = "ship_lballista_shot"
elseif "%2" == "fire-launcher rounds" then
weapon_shot = "ship_firelauncher_shot"
weapon_hit = "ship_firelauncher_hit"
elseif "%2" == "heavy-cannon rounds" then
weapon_shot = "ship_hcannon_shot"
weapon_hit = "ship_hcannon_hit"
elseif "%2" == "medium-cannon rounds" then
weapon_shot = "ship_mcannon_shot"
weapon_hit = "ship_mcannon_hit"
elseif "%2" == "light-cannon rounds" then
weapon_shot = "ship_lcannon_shot"
weapon_hit = "ship_lcannon_hit"
end
SetVariable(weapon_hit,tonumber(GetVariable(weapon_hit))+hits)
SetVariable(weapon_shot,tonumber(GetVariable(weapon_shot))+howmany)
I don't understand why I cannot get the script working, but I know from previous programming experience that it is something trivial, like a comma or period somewhere.
My other question is:
I'm wanting to record the # of gold-ingots recovered per trip (a trip being leaving docks and returning). My question is how do I enable the variable when I leave docks (I have strings that I can match when I leave) and then disable that same variable when I dock again?
I appreciate any help in this matter, and apologize for the length of my post. I figure more information is better than being vague.
Thanks,
Forral