Afflicting script error

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Afflicting script error

Post by icesteruk »

I've been looking all day on how to fix these, done searches in google/on mudlet/wiki.. can someone point me on what I'm doing wrong as It keeps bringing back errors.

I'm just trying to make a simple attacker sort of script/alias so I can test my system out.

error: Lua syntax error:[string "function Alias87()..."]:19: unecpected near '['
Code: [show] | [select all] lua
local aff1 = {
"anorexia",
"stupidity",
"loneliness",
"recklessness",
"masochism",
}
local aff2 = {
"anorexia",
"stupidity",
"impatience",
"vertigo",
"confusion",
}

if not combat.afflictions[aff2] then

whisperone = [aff2]
end
if not combat.afflictions[aff1] and not whisperone[aff1] then
whispertwo = [aff1]
end

if combat.enemy.afflictions.rebounding then
send("frenzy " .. god.target)
send("Dwhisper " .. whisperone .. " " .. whispertwo .. " " .. god.target)
end

end

User avatar
demonnic
Posts: 886
Joined: Sat Dec 05, 2009 3:19 pm

Re: Afflicting script error

Post by demonnic »

If I'm reading this right, what it seems you are trying to do is check to see if any of the afflictions in the aff1 table are in the combat.afflictions table?

The way it is written, it is checking

if not combat.afflictions[{"anorexia", "stupidity", "loneliness", "recklessness", "masochism"}] and I don't believe that is what you're looking for. For one, I'm not certain Lua will accept a table as the key in a table, but for another it would only return true if there were an item at key {"anorexia", "stupidity", "loneliness", "recklessness", "masochism"}.

Could you post what you have in combat.afflictions, and provide a more detailed explanation of what you're trying to accomplish?

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Afflicting script error

Post by icesteruk »

I'm trying to use the table as a kind of check, like..

if one of the afflictions in the aff table isn't in combat.afflictions ((the table I'm using to track afflictions on the person i will be afflicting) then give them the first afflicton...

the combat.affliction table is similar to the affliction table which tracks your own afflictions but instead it'll track the afflictions of your target..

User avatar
demonnic
Posts: 886
Joined: Sat Dec 05, 2009 3:19 pm

Re: Afflicting script error

Post by demonnic »

Ok, but what if they have the first affliction in the list? What it seems to me you may want is something like the following:
Code: [show] | [select all] lua
local aff1 = {
  "anorexia",
  "stupidity",
  "loneliness",
  "recklessness",
  "masochism",
}
local aff2 = {
  "anorexia",
  "stupidity",
  "impatience",
  "vertigo",
  "confusion",
}
for _,flicted in ipairs(aff2) do
  if not table.contains(combat.afflictions, flicted) then
    whisperone = flicted
    break
  end
end
for _,flicted in ipairs(aff1) do
  if not table.contains(combat.afflictions, flicted) and not whisperone == flicted then
    whispertwo = flicted
    break
  end
end

if combat.enemy.afflictions.rebounding then
  send("frenzy " .. god.target)
end
send("Dwhisper " .. whisperone .. " " .. whispertwo .. " " .. god.target)
It should be noted that this could lead to some interesting results for some cases. Such as them having all the affs in aff2, at which point it will likely repeat whatever whisperone was previously. You may want to work some guards in against that sort of thing, but this should hopefully set you in the right direction.

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Afflicting script error

Post by icesteruk »

yeah, if the person has the 1st aff it'll move onto the 2nd and so on..

and the list has over 20 afflictions + venoms, if the person gets all the 'affs' then it'll be funny to see...

thank you :)

User avatar
demonnic
Posts: 886
Joined: Sat Dec 05, 2009 3:19 pm

Re: Afflicting script error

Post by demonnic »

Happy to help =)

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Afflicting script error

Post by icesteruk »

I just added it and seems it isn't tracking what the 'flicted' is.. like the whisperone/whispertwo are staying blank heh..

Sorry for being a total newb :(

User avatar
demonnic
Posts: 886
Joined: Sat Dec 05, 2009 3:19 pm

Re: Afflicting script error

Post by demonnic »

any errors?

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Afflicting script error

Post by icesteruk »

oh, its all firing just the 2nd part of it isn't..

from the ECHO Commands..

frenzy Nothing
Dwhisper anorexia 0 Nothing

from messing with the code, I deleted 'and not whisperone == flicted ' out of it and it works fine :)

Thank you again

User avatar
demonnic
Posts: 886
Joined: Sat Dec 05, 2009 3:19 pm

Re: Afflicting script error

Post by demonnic »

That does leave you with the possibility of trying to whisper the same affliction twice in one Dwhisper. Particularly anorexia

Post Reply