[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Ridiculiously newbie question, im really sorry

Ridiculiously newbie question, im really sorry

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Alderkar   (11 posts)  [Biography] bio
Date Tue 24 Nov 2015 12:01 AM (UTC)

Amended on Tue 24 Nov 2015 12:04 AM (UTC) by Alderkar

Message
This is going to sound idiotic, but im having trouble just getting going...

I am attempting to make a trigger that auto heals by casting a spell. It was easy enough by using the gui and saying
prompt in game looks like this
<100%><100%><100%><well underway>


so I have it going
when: <*%><*%><*%><*>

Send(send to script):

if %1 < 100 then
Send "c 'cure critical"
end -- if

This part is working, but i want the trigger to turn itself off when 1% <100 is no longer true

I also was hoping i could enable it with an alias. Im trying to copy this from an earlier post that and modify it to suit my needs (putting the stolen script at the very bottom of my post), but i think im doing it wrong. Am i supposed to be dropping this alias right into a file like scriptname.lua in the "External script file" box in the scripts menu?

I know this sounds stupid but im very basic at this. Im receiving errors like this, am i supposed to be nestling this in a function or something? I suspect im completely out to lunch in trying to add this alias.

Immediate execution
[string "Script file"]:1: unexpected symbol near '<'
Error context in script:
1*: <aliases>
2 : <alias
3 : name="ToggleTrigger"


any help would be appreciated, im sorry for making such a basic question but im just getting started :(


<aliases>
<alias
name="ToggleTrigger"
match="tt *"
enabled="y"
send_to="12"
ignore_case="y"
sequence="100"
>
<send>
EnableTrigger ("%1", (GetTriggerOption("%1", "enabled")+1)%%2)
ColourNote ("sienna", "thistle", "%1 trigger is enabled: " .. tostring(GetTriggerOption("%1", "enabled") == 1))
</send>
</alias>
</aliases>


So as i said im modifying these values they arent for my situation exactly but i cant even get started.
[Go to top] top

Posted by Meerclar   USA  (733 posts)  [Biography] bio
Date Reply #1 on Tue 24 Nov 2015 03:52 AM (UTC)
Message
Actually, I suspect the problem is much simpler to solve than you're trying to make it. Have you converted %1 from string to numeric at some point that we simply aren't seeing? If you're doing a proper numeric comparison, you don't need to turn the trigger off if %1 > 100 because it won't fire anyway. You'll want to use the toNumber function to convert %1 so it actually behaves like a numeric comparison instead of comparing the literal string against 100 which *will* lead to some very interesting results.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[Go to top] top

Posted by Alderkar   (11 posts)  [Biography] bio
Date Reply #2 on Tue 24 Nov 2015 10:28 AM (UTC)
Message
That would normally be ok, but the spell has a build in wait state of a second or two so during combat i would be spamming myself with heal and lock myself from casting anything else or fleeing.

also because of the specific situation im in my health slowly drains so i would be pissing away my mana all the time. Which is why I was looking at the alias>trigger heal to 100% and quit option so use when ever I choose to heal up.

it also occurs to me that I could have a second trigger for 1 > 100 that disables a group of triggers (which would have my healing spell in it) it might be a ugly way to do it though.

I basically want a for 1% < 100 do heal if 1 > 100 exit

Also I just checked the actual client directory, i didnt realize there was a lua folder full of stuff that i was probably supposed to be reading in the first place. I started a new folder from scratch not even thinking to check there first. oops
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Tue 24 Nov 2015 07:55 PM (UTC)
Message
Quote:


Immediate execution
[string "Script file"]:1: unexpected symbol near '<'
Error context in script:
1*: <aliases>
2 : <alias
3 : name="ToggleTrigger"


I know this sounds stupid but im very basic at this. Im receiving errors like this, am i supposed to be nestling this in a function or something? I suspect im completely out to lunch in trying to add this alias.


You seem to be over-complicating things. Maybe read this:

Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


The XML code which you appear to be using should not be in the "send" box. That is a way of transporting aliases from one place to another (eg. the forum).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Meerclar   USA  (733 posts)  [Biography] bio
Date Reply #4 on Wed 25 Nov 2015 04:22 PM (UTC)
Message
Alderkar said:

That would normally be ok, but the spell has a build in wait state of a second or two so during combat i would be spamming myself with heal and lock myself from casting anything else or fleeing.

also because of the specific situation im in my health slowly drains so i would be pissing away my mana all the time. Which is why I was looking at the alias>trigger heal to 100% and quit option so use when ever I choose to heal up.

Unless you have some combination of a far more powerful cure crit, far less hp, vastly more mana, or vastly more dangerous combat than most mu* I'm familiar with, you don't want to start casting heals at 99% health anyway so your design logic needs improvement for anything resembling effeciency.

Quote:
it also occurs to me that I could have a second trigger for 1 > 100 that disables a group of triggers (which would have my healing spell in it) it might be a ugly way to do it though.

Better approach would be a series of more powerful healing sequences based on decreasing hp and the actual healing potential of your cure crit spell compared to your max hp. Put the most powerful heals at lower priorities so they fire before the weaker sequences and your mana efficiency improves rather dramatically. To prevent locking yourself up, you could design them so that they self disable and have another trigger for some minimum hp% hp enable them again.

Quote:
I basically want a for 1% < 100 do heal if 1 > 100 exit

This is exactly what your original design logic is.

Quote:
Also I just checked the actual client directory, i didnt realize there was a lua folder full of stuff that i was probably supposed to be reading in the first place. I started a new folder from scratch not even thinking to check there first. oops

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[Go to top] top

Posted by Alderkar   (11 posts)  [Biography] bio
Date Reply #5 on Wed 25 Nov 2015 09:16 PM (UTC)
Message
Thanks for the replys guys :) im going to tackle this again on the weekend, its so intimidating. Im not very scripty. If I get something working ill post and get your critiques.

Thank you very much for all the help so far:)
[Go to top] top

Posted by Alderkar   (11 posts)  [Biography] bio
Date Reply #6 on Thu 26 Nov 2015 01:05 PM (UTC)
Message
wow

I think i just needed to sleep on this, I feel stupid. I think i was trying to mix and match different languages.

if anyone is interested, I have it working now and feel empowered to try harder things.

prompt looks like this in game <100%><100%><100%><soon!>

i have a trigger matching <*%><*%><*%><*> in the group called healing

sendto script part:

if %1 < 100 then
Send "c 'cure critical"
else
EnableGroup ("healing", false)
end--if

THEN

I have an alias called heal
that does: EnableGroup ("healing", true)

I dont know why that was so hard for me to wrap my brain around, I was struggling with ending my if loop. kept getting an error. Ill figure out this syntax thing soon :)
[Go to top] top

Posted by Meerclar   USA  (733 posts)  [Biography] bio
Date Reply #7 on Fri 27 Nov 2015 12:09 AM (UTC)
Message
You might still want to do some checking to verify what %1 actually is if you aren't using toNumber to get actual numeric comparisons because what you posted isn't going to work the way you expect it to.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[Go to top] top

Posted by Alderkar   (11 posts)  [Biography] bio
Date Reply #8 on Fri 27 Nov 2015 12:47 AM (UTC)
Message
wont %1 always be the first * in the prompt? im pretty basic haha:)
[Go to top] top

Posted by Meerclar   USA  (733 posts)  [Biography] bio
Date Reply #9 on Fri 27 Nov 2015 01:22 AM (UTC)

Amended on Fri 27 Nov 2015 01:39 AM (UTC) by Meerclar

Message
Yes, %1 will always be the first * in your trigger but (and I'm sure Nick or Fiendish will correct me if I screw this up - and I probably will) the way wildcards work in triggers, it should be the remainder of line beyond the location of the wildcard being captured as the wildcard. There's also some extra fun with comparing numbers without using toNumber to actually get numbers. String comparisons of numbers work far differently than numeric comparisons http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=8455 provides some examples of what I'm talking about and links to more info which links to still more info.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #10 on Fri 27 Nov 2015 04:56 AM (UTC)
Message
His example:


<*%><*%><*%><*>


... should work OK.

The wildcards are non-greedy so it should match the HP in this case. To be safer you would use a regular expression and make sure it matches numbers, eg.


^<([0-9]+)%><([0-9]+)%><([0-9]+)%><.*>


In this case you don't want to quote the wildcard because that turns it into a string.

Template:regexp Regular expressions
  • Regular expressions (as used in triggers and aliases) are documented on the Regular expression tips forum page.
  • Also see how Lua string matching patterns work, as documented on the Lua string.find page.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Alderkar   (11 posts)  [Biography] bio
Date Reply #11 on Fri 27 Nov 2015 01:43 PM (UTC)
Message
oh my god, i have no idea.

im just going to curl up over ->

sound good?
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


28,521 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]