Krae said: Aha! Wow I had never discovered that whole external script file thing! Thank you for pointing that out.
No problem.
Krae said: So I can just start out straight away with coding no things needed to open it?
Once MUSHclient knows the name of the file, it'll automatically run it. You can even set it to reload it whenever the file changes; check out the options in the Scripting configuration.
Krae said:I just started with something not quite sure if this is possible since I'm not sure if I'm doing it right;
--mw = {}
--function enemaff()
-- win = "enemaff"
-- WindowCreate (win, 700, 0 ,170, 145, 6, 2, ColourNameToRGB("green"))
-- WindowRectOp (win, 1, 700, 0, 145, 0, ColourNameToRGB("tan"))
-- WindowShow (win, true)
-- WindowFont (win, "f", "Trebuchet MS", 14, true, false, false, false)
-- WindowText (win, "f", ("Target is: "..GetVariable("target")), 4, 0, 0, 0, ColourNameToRGB ("darkred"), false)
--afflictions = {} -- empty table
-- if GetVariable("dizziness") == "1" then
-- Note ("Dizzy!"
-- GetVariable ("stupidity") == "1" then
-- Note ("Stupid!")
-- end
-- count = 0
-- for k, v in pairs (afflictions) do
-- count = count + 1
--end
Just putting the '--' in to make it not affect anything just yet.
This is the whole script file right now, am I on the right track here or not quite?
All things considered, yes, you're on the right track. I suggest using indentation heavily though, because you're missing an 'end' and it's not immediately obvious. Conventional Lua indentation, by the way, is two spaces. Lastly, you can do a multiline comment with "--[[ ]]".
You don't really need to comment this stuff out, though. Functions are inert until you call them, so unless you're worried about using the variable name or the code is syntactically broken, there's no need.
mw = {}
win = "enemaff" -- Moved out of the function since it's constant
-- Don't worry too much about short names; enemy_aff would be clearer.
-- draw_enemy_affs would be perfect.
function enemaff()
WindowCreate (win, 700, 0 ,170, 145, 6, 2, ColourNameToRGB("green"))
WindowRectOp (win, 1, 700, 0, 145, 0, ColourNameToRGB("tan"))
WindowShow (win, true)
WindowFont (win, "f", "Trebuchet MS", 14, true, false, false, false)
WindowText (win, "f", "Target is: " .. GetVariable("target"), 4, 0, 0, 0, ColourNameToRGB ("darkred"), false)
-- This table will always be empty, because it's created every time in the function.
-- Is this what you wanted? If not, consider putting it outside the function instead.
afflictions = {} -- empty table
if GetVariable("dizziness") == "1" then
Note ("Dizzy!") -- You forgot a ) here.
end -- You forgot this 'end'.
if GetVariable ("stupidity") == "1" then
Note ("Stupid!")
end
local count = 0 -- Making this local.
for k, v in pairs (afflictions) do
count = count + 1
end
end -- You forgot this 'end'.
Krae said: As an addendum, sorry for continuously bugging you guys! I can understand it must be annoying to have to break things down.
What's annoying is that everyone who actually deserves our help thinks they're bugging us. ;) It's really no big deal, you're obviously taking our advice and trying things on your own. |