Mudlet Help

So I am making an auto target script, all it does is track targets in the room, I hit my attack alias, it attacks the target. However, the issue I am having is that it changes targets each time... I can't figure out why or how to fix it. I'm new to coding and using a basic script that I found on a youtube video. I was wondering if anyone has any advice on how to get it to stick with one target until it is dead and then switch to the next one? This is the script I am using so far.

valid_target = { ["a large rabbit with one black ear"] = true, ["a brown floppy-eared rabbit"] = true, ["a creamy white goat"] = true, } function autoTarget() sendGMCP("Char.Items.Room") if gmcp.Char.Items.List.location == "room" then for k,v in ipairs(gmcp.Char.Items.List.items) do if valid_target[v.name] then tar = v.id end--if end--For end--If end--autoTarget function autoAssault() if tar then send("doublewhirl " .. tar) end--if end--autoAssault()

Thank you in advance.

Comments

  • edited May 2017
    if valid_target[v.name] then
       tar = v.id
       break
    end--if

    Should fix it. You'll want to make it so it only runs autoTarget on entry or when the mob dies, though. Otherwise it'll just be constantly setting. Alternatively make it not search the room table if your target's still in the room.
  • Ryzeth said:
    if valid_target[v.name] then
       tar = v.id
       break
    end--if

    Should fix it. You'll want to make it so it only runs autoTarget on entry or when the mob dies, though. Otherwise it'll just be constantly setting. Alternatively make it not search the room table if your target's still in the room.

    @Ryzeth thanks wasn't aware I could do something like that. I'll add it in.
  • So I'm using the same setup, and having some issues with tracking things...

    function autoAssault() if tonumber(string.match(gmcp.Char.Vitals.charstats[2], "%d+")) >= 17 and rage_backfist then send("sbp " .. tar) end--if if tar and gmcp.Char.Vitals.charstats[4] == "willow" then send("combo " .. tar .. " flashheel left hiraku dart head") elseif tonumber(kata_chain) == 12 and gmcp.Char.Vitals.charstats[4] == "willow" then send("transition to rain form") send("combo " .. tar .. " frontkick left kuro right ruku torso") end--if end--autoAssault()

    For some reason, it isn't doing anything and I can't figure out what I am doing wrong with the code. Anyone that can take a look and help me resolve it by explaining where I screwed up, would be greatly appreciated. Thanks.

  • edited May 2017
    If you're in anything but willow form, that script isn't gonna do anything.

    Also does Shikudo stance save just with the name? Or is the table value listed as 'Stance: willow' etc?

  • AhmetAhmet Wherever I wanna be
    @Ryzeth "Form: Willow"
    Huh. Neat.
  • @Ryzeth when I do gmcp.Char.Vitals.charstats[4] it shows "Form: Willow".

    Even when I am in willow form it still won't do anything.

  • edited May 2017
    Keles said:
    @Ryzeth when I do gmcp.Char.Vitals.charstats[4] it shows "Form: Willow".

    Even when I am in willow form it still won't do anything.

    Try this.
    function autoAssault()
    	local rage = tonumber(string.match(gmcp.Char.Vitals.charstats[2], "Rage: (%d+)"))
    	local form = string.match(gmcp.Char.Vitals.charstats[4], "Form: (%w+)")
    
    	if rage >= 17 and rage_backfist then
    		send("sbp "..tar)
    	end
    
    	if tar and (form == "willow") then
    		send("combo "..tar.." flashheel left hiraku dart head")
    	elseif tonumber(kata_chain) >= 12 form =="willow" then
    		send("transition to rain form")
    		send("combo "..tar.." frontkick left kuro right ruku torso")
    	end
    end

    You'll still have to build on that for when you're not in willow form, though.
  • Also oops, should be == "Willow" 

    Capitalisation matters, folks.
  • @Ryzeth It works! Thank you very much! I can work on building off it now that I have a better idea how it is supposed to be done. You rock.

  • edited May 2017
    Also because I didn't proofread it (literally just wrote it on the spot)
    </code>elseif tonumber(kata_chain) >= 12 form =="Willow" then</pre>Should be<br><pre class="CodeBlock"><code>elseif tonumber(kata_chain) >= 12 <b>and</b> form =="Willow" then
  • function autoAssault() local rage = tonumber(string.match(gmcp.Char.Vitals.charstats[2], "Rage: (%d+)")) local form = string.match(gmcp.Char.Vitals.charstats[4], "Form: (%w+)") if rage >= 17 and rage_backfist then send("sbp " .. tar) end if tar and tonumber(kata_chain) <= 10 and(form == "Willow") then send("combo " .. tar .. " flashheel left hiraku dart head") elseif tonumber(kata_chain) >= 10 and form =="Willow" then send("transition to rain form") send("combo " .. tar .. " frontkick left kuro right ruku torso") end if tar and tonumber(kata_chain) <= 23 and (form == "Rain") then send("combo " .. tar .. " frontkick left kuro right ruku torso") elseif tonumber(kata_chain) >= 24 and (form == "Rain") then send("transition to oak form") send("combo " .. tar .. " livestrike ruku torso risingkick head") end if tar and tonumber(kata_chain) <= 12 and (form == "Oak") then send("combo " .. tar .. " livestrike livestrike risingkick head") elseif tonumber(kata_chain) >= 12 and (form == "Oak") then send("transition to willow form") send("combo " .. tar .. " flashheel left hiraku dart head") end end

    This is the script so far. I am posting it here in case anyone else wants is messing with Shikudo and wants or needs a basic hunting setup. Feel free to build off it, post improvements, etc etc. Thanks goes to @Ryzeth for getting it started!

  • JonathinJonathin Retired in a hole.
    @Ryzeth

    Doesn't matter if you just lower() like you should.
    I am retired and log into the forums maybe once every 2 months. It was a good 20 years, live your best lives, friends.
Sign In or Register to comment.