Mudlet help

edited August 2013 in Mechanic's Corner
I'm trying to do what is probably a very simple thing, but I'm JUST starting with scripting my own simple stuff...Alright so I set an alias that when entered would set a variable to 1, and while this variable was set to 1 I am supposed to keep bashing stuff, until it is dead. But when I try to activate it, my mudlet freezes up and I need to close the process, so I'm assuming something went terribly, terribly wrong. Here is what I did.

Alias pattern: ^tab$

bashing = 1

end

if bashing then

if isbalanced then do

send("play minorsecond "..tar)

if haskilled then

bashing = 0

end

end

end



help a newb out ^_^

Comments

  • EnyalidaEnyalida Nasty Woman, Sockpuppeteer to the Gods
    What is that first end for?
  • KaimanahiKaimanahi The One True Queen
    This is kind of a strange alias in principle and function, but maybe going through this will help your coding understanding a little more. I think what you are wanting is something like this:

    if isbalanced and not haskilled then
     send("play minorsecond " .. tar)
    end

    So it fires the alias if you have balance (assuming you have a trigger that sets isbalanced to true when you regain balance, and false when you lose it) and if your target wasn't killed (assuming you have a trigger that sets haskilled to true when tar is killed, and false...? When you pick up a corpse? Set a new target? This I don't really understand.). Also it would probably be better to eliminate the balance trigger and instead use gmcp or if you have m&m the "do" system. 

    Couple of other comments. You use "do" in loops, not if statements, so the "do" you have in there probably causes a bug. Also in your attempt when you have the line "if bashing then", your alias would still fire when bashing has a value of 0. Your "bashing = 0" line should really be something like "bashing = false".
    image
  • I had an end because I kept getting an lua function error saying I needed another 'end' dunno,

    also, used do because i kept getting an error saying i needed to use 'do' haha. Ive sort of fixed it by setting the alias to enable a trigger that fires on the EQ recovery line, but its sort of spammy. I dont use gcmp but I suppose I should

    I have this

    ^You have slain a (.*?)$
    haskilled = 1

    as a trigger to set the variable. Im gonna throw in what you said Kelly and see if that works (now that I see it, it makes sense and should) dunno why I was trying to make it so complicated


  • NeosNeos The Subtle Griefer
    When using variables to check something, use true/false, not numbers, as all numbers, even 0, will default to true. Only use numbers/strings when you need to make future use of that information.
    Love gaming? Love gaming stuff? Sign up for Lootcrate and get awesome gaming items. Accompanying video.

     Signature!


    Celina said:
    You can't really same the same, can you?
    Zvoltz said:
    "The Panthron"
  • edited August 2013
    Neos said:
    When using variables to check something, use true/false, not numbers, as all numbers, even 0, will default to true. Only use numbers/strings when you need to make future use of that information.

    thanks, as I said I have not the foggiest what Im doing, sort of muddling through and trying to teach myself. Thank you!


    Using your advice I've come up with this:

    ^tab$

    if not bashing then enableTrigger[[EQ bash]]

    echo("Auto bash enabled\n")

    bashing = true

    send("play minorsecond "..tar)  -- makes it so you don't have to input the first attack

    else if bashing then disableTrigger[[EQ bash]]

    bashing = false

    echo("Auto bash disabled")

    end

    end



    And here is the trigger I have for 'EQ bash'


    ^You have recovered balance on all limbs\.$


    isbalanced = true

    if bashing and not haskilled

    then send("play minorsecond "..tar)

    else if haskilled and isbalanced

    then send("get "..tar , false)

    send("get essence" , false)

    send("get gold" , false)

    haskilled = false

    end

    end



    Maybe not efficient, but it seems to be working. Any tips on efficiency to maybe make this slightly better?

  • KaimanahiKaimanahi The One True Queen
    In your alias, instead of having "else if" and then an additional "end" to close your new if statement, you just want to do "elseif" and remove the extraneous "end".

    For the second trigger, you don't have to make it a perl regex; you could have just used an exact match trigger for that line. Also there is no value added in having the "isbalanced = true" line, and then the "and isbalanced" later. If that trigger is firing, you already know that you have balance and don't need a variable to track it.
    image
  • edited February 2014


  • edited August 2013
    Kelly said:
    In your alias, instead of having "else if" and then an additional "end" to close your new if statement, you just want to do "elseif" and remove the extraneous "end".

    For the second trigger, you don't have to make it a perl regex; you could have just used an exact match trigger for that line. Also there is no value added in having the "isbalanced = true" line, and then the "and isbalanced" later. If that trigger is firing, you already know that you have balance and don't need a variable to track it.


    I tweaked it to fit my warrior character and this is what I now have (somewhat the same, with diff commands plugged in) I also set each balance line (left arm, right arm) on different triggers so as to not be forced to double swing. Here is the setup now:

    Alias pattern: ^1$

    if not bashing then enableTrigger[[EQ bash right]]

        enableTrigger[[EQ bash left]]

    cecho("<blue>Auto bash enabled\n")

    bashing = true

            send("swing "..tar)

                    send("swing "..tar)

    elseif bashing then disableTrigger[[EQ bash right]]

                                disableTrigger[[EQ bash left]]

                     bashing = false

               cecho("<red>Auto bash disabled\n")

    end

    end




    and the two triggers are set up this way
    Pattern: You have recovered balance on your left arm.


    if bashing

    then send("swing "..tar.." left hand")

    end




    I have one for the right arm set up the same way. I guess my final question is, is there any way to combine the two triggers in a way that it would still recognize that its either my left or my right hand that is balanced, and swing accordingly?


    also..keep in mind that this is my first time ever trying to code anything in any language, so dont laugh at me T_T

  • KaimanahiKaimanahi The One True Queen
    Hrm, I think what you're asking is...

    ^You have recovered balance on your (?:left|right) arm\.$

    Or use a begin of line substring trigger and stop the line after "your"?
    image
Sign In or Register to comment.