Simple script

Posted by Metsuro on Thu 08 Dec 2005 01:25 AM — 43 posts, 141,406 views.

USA #0
Ok I am tring to get an script to automaticly pick herbs based on a formula from 2 triggers and an alias.

alias would be like

pick (herb)

first trigger would catch on:

you have recovered balance -- and then do "plants"

second trigger will match on

(herb) (number) left.

so I was thinking it might work like

local herb
local pick

function start_pick (name, output, wildcs)
herb = wildcards[1]
Send("plants")
end

function check_pick (name, output, wildcs)
(something to check if the herb was the right one if not have another function to check it maybe?)
if wildcard[2] > 0 then
Send("pick ", herb)
else
Note("Cant pick anymore ", herb)
end
end

something... like that... I guess?
Australia Forum Administrator #1
Well you are on the right track. Time to start testing your ideas. For some simple things you don't need a separate script file. I'll take your "pick" alias idea and show how it can all be done in the alias:


<aliases>
  <alias
   match="pick *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>herb = "%1"
Send "plants"</send>
  </alias>
</aliases>



Now if you type "pick mushroom" (for example), it saves the word "mushroom" in the herbs variable, and sends "plants" to the MUD.

You can check the variable by typing into the command window:

/print (herb)

You should see echoed: mushroom

Now try the other things yourself. If you are posting, try using the copy function in the alias list to copy the actual alias as I have done, to avoid typing errors.

By the way, you need attention to detail in your scripts. For example:


function start_pick (name, output, wildcs)
herb = wildcards[1]
Send("plants")
end


The variable name you have used in the function line is "wildcs" but then you are using "wildcards" a line later. They have to be spelt the same.

USA #2
Ok I got it work, using:


function do_pick (name, output, wildcs)
 if wildcs[2] == herb then
  if wildcs[3] > "10" then
   Send("pick ", herb)
  else
   Note("No more for you to pick.")
   EnableTriggerGroup ("Herbs", false)
  end
 end
end


but now I notice its really spammy checking plants over and over again... so how could I gag it maybe?
Amended on Thu 08 Dec 2005 03:09 AM by Nick Gammon
Australia Forum Administrator #3
Can you paste the actual output you receive, and your actual trigger?

I wouldn't do this:


if wildcs[3] > "10" then


You want a numeric compare, right? That is a string compare. Try:


if wildcs[3] > 10 then


No, I wouldn't gag anything, I would fix the problem.
USA #4
no see I tried that it said I was comparing a number to a string, and thats the only way I could get it to work.

<triggers>
<trigger
enabled="y"
group="Herbs"
match="^(.*) \((.*?)\) (.*?) left\.$"
regexp="y"
script="do_pick"
sequence="100"
>
</trigger>
</triggers>
Amended on Thu 08 Dec 2005 11:40 PM by Metsuro
Australia Forum Administrator #5
You are right, it should read:


if tonumber (wildcs[3]) > 10 then


You still want a numeric compare.

Try this:


/print ("20" > "5") --> false


But 20 is greater than 5. String compares work like that. It thinks the 5 is greater than the 2.

Now try:


/print (tonumber ("20") > 5) --> true


Why is it spamming? Is the other trigger not in the "Herbs" group?

It is really hard to help you, despite repeated requests you are only giving parts of what you are doing. You haven't posted your trigger that matches on "you have recovered balance".

USA #6
all that does is do the command plants it was the only way I could figure to do it.

<triggers>
<trigger
custom_colour="2"
group="Herbs"
match="You have recovered balance on all limbs."
regexp="y"
sequence="99"
>
<send>plants</send>
</trigger>
</triggers>

which makes it spam cause its always checking to see the herbs. well I could have it just check once and store it as a variable, on how many I can pick and just subtract one when I do it... but sometimes when you pick the herb will grow more or someone till come in and pick them too, so I thought it best to do it this way.

the prompt will get spammier depending on the season because of the different herbs. and the trigger I didn't really know how to do so...

--You have recovered balance on all limbs.
plants
1410h, 1500m, 1860e, 10p ex-
The following plants are growing in this room:
A sprig of chervil (chervil) 11 left.
pick chervil
1410h, 1500m, 1860e, 10p ex-
You reach down and carefully harvest a sprig of chervil.
1410h, 1500m, 1860e, 10p e-

You have recovered balance on all limbs.
plants
1410h, 1500m, 1860e, 10p ex-

Across the heavens, the stars and moon challenge night's dark reign, revealing
familiar constellations that tell the tales of myth and legend.
1410h, 1500m, 1860e, 10p ex-
The following plants are growing in this room:
A sprig of chervil (chervil) 10 left.
No more for you to pick.--
to get all this in a course of several seconds trying to speak with others... is rather... hard...

[edit] the prompt was meant to go in this one... donno why I put it in the other...
Amended on Thu 08 Dec 2005 11:41 PM by Metsuro
USA #7
and now that I think of it... I would like to add another trigger and script to check to see if the plant is in hibernation or not hrm...
USA #8
Ok well I am wanting to make a table to go with this... but I'm not sure how I'd set up a script to look for the information I want, and I dont think I would need a linear scan for it either...
USA #9
and yet if tonumber (wildcs[4]) > 10 then still doesn't work either
Australia Forum Administrator #10
Please post the whole thing, not just a snippet.

In what way doesn't it work? Error message? If so, what?
USA #11
in my idioicy I didn't bother to look around and found out what was causing it not to work, simple error in my typing. So thank you for working with me on that, but I am still needing a way to make a none linear scan of a table i guess?
Australia Forum Administrator #12
See my post about using tables:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=6036
USA #13
herbs = {
{ name = "Arnica" , month = "Klangiary"},
{ name = "Calamus" , month = "Dioni" },
{ name = "Chervil" , month = "Roarkian" },
{ name = "Colewort" , month = "Kiani" },
{ name = "Coltsfoot" , month = "Juliary" },
{ name = "Faeleaf" , month = "Juliary" },
{ name = "Flax" , month = "Estar" },
{ name = "Galingale" , month = "Shanthin" },
{ name = "Horehound" , month = "Vestia" },
{ name = "Juniper" , month = "Dioni" },
{ name = "Kafe" , month = "Urlachmar"},
{ name = "Kombu" , month = "Dioni" },
{ name = "Marjoram" , month = "Shanthin" },
{ name = "Merbloom" , month = "Estar" },
{ name = "Mistletoe" , month = "Avechary" },
{ name = "Myrtle" , month = "Estar" },
{ name = "Pennyroyal" , month = "Klangiary"},
{ name = "Reishi" , month = "Tzarin" },
{ name = "Rosehips" , month = "Shanthin" },
{ name = "Sage" , month = "Dioni" },
{ name = "Sargassum" , month = "Tzarin" },
{ name = "Sparkleberry" , month = "Dvarsh" },
{ name = "Weed" , month = "Estar" },
{ name = "Wormwood" , month = "Vestia" },
{ name = "Yarrow" , month = "Roarkian" },
}

function do_pick (name, output, wildcs)
-- a for here if thats even possible maybe...
-- check for name?
-- check for month?
-- check month vs curret month?
if wildcs[2] == herb then
if tonumber (wildcs[4]) > 10 then
Send("pick ", herb)
else
Note("No more for you to pick.")
Send("inr all ", herb)
DoAfter(4, EnableTriggerGroup ("Herbs", false))
end
end
end

OK this is what I have so far.. I've put comments in where think things might go... but I'm not even sure where I could put something... and how to do it using what I have...
Australia Forum Administrator #14
You are on the right track here. Maybe you can take a look at the other script for balances and understand what it is doing better. What to do next depends a fair bit on the MUD output and what you want to achieve.

If it is trying to eat herbs too often, then I would be keeping a table of the ones I need to eat (as I did in the other script) and then match the list of herbs I actually get to what I need. If none, then no more eating required.
USA #15
Its not for eatting *scratch* what I am trying to do is make a script that picks herbs from the room down to 10 automaticly right... but because some herbs hibernate during a certain month, you shouldn't really pick them cause you might have a chance to ruin the next growing period for it... so I am trying to check it.
USA #16

function do_pick (name, output, wildcs)
 for _, v in ipairs (herbs) do
  if month == v.month then
   Note("Hibernating")
  else
   if wildcs[2] == herb then
    if tonumber (wildcs[4]) > 10 then
     Send("pick ", herb)
    else
     Note("No more for you to pick.")
     Send("inr all ", herb)
     DoAfter(4, EnableTriggerGroup ("Herbs", false))
    end
   end
 end
end
end


i've tried doing it this way, and it works kinda... I donno if it actually checks to see what month it is... but then it spams the game with pick (herb) many many times... so.... I'm guessing I did something really wrong here...
Amended on Sun 11 Dec 2005 11:44 PM by Nick Gammon
USA #17
The problem I am guessing that its not looking for the herb i want but its checking all herbs vs the month right? so how might I change it to look for just the one herbs month? also at the end of the 4 seconds I believe it saids 5 to the game... and I dont know why?
Amended on Sun 11 Dec 2005 10:35 PM by Metsuro
Australia Forum Administrator #18
OK, let's look at your function. You have to think logically if you are going to make it work ...


function do_pick (name, output, wildcs)
 table.foreach (wildcs, print)

 for _, v in ipairs (herbs) do
  if month == v.month then
   Note("Hibernating")
  else
   if wildcs[2] == herb then
    if tonumber (wildcs[4]) > 10 then
     Send("pick ", herb)
    else
     Note("No more for you to pick.")
     Send("inr all ", herb)
     DoAfter(4, EnableTriggerGroup ("Herbs", false))
    end
   end
 end



I've added the line in bold to print the wildcards you are getting. Based on the earlier trigger you had (and that is the only one I have to work with), if you match on:


A sprig of chervil (chervil) 11 left.


... the wildcards are:


1 A sprig of chervil
2 chervil
3 11
0 A sprig of chervil (chervil) 11 left.


So straight away we see your tests for wildcs[4] are not going to be a big success, as there is no wildcard 4.

Next thing is, we see from your table:


{ name = "Chervil" , month = "Roarkian" },


Now you have "Chervil" in the table, but the wildcard is "chervil". I know it is similar, but they are different words.

Then you have a test:


if month == v.month then


Where is "month" defined? What is in it?

Moving on, I see:


if wildcs[2] == herb then


How is "herb" set up? Do you mean:


if wildcs[2] == v.name then


That would compare the herb in the table to the one you got. I can't see the point in going through the table if you don't compare the herb names.

Quote:

also at the end of the 4 seconds I believe it saids 5 to the game ...


You have this:


DoAfter(4, EnableTriggerGroup ("Herbs", false))


What that will do, is after 4 seconds send the "return code" from EnableTriggerGroup. The definition for EnableTriggerGroup says it returns "A count of the number of items in that group". Thus I presume there are 5 things in the group, and it is sending 5 to the MUD.

What you want is something slightly different. You want to execute 'EnableTriggerGroup ("Herbs", false)' as a command after 4 seconds, not right now. So it should read:


DoAfterSpecial (4, 'EnableTriggerGroup ("Herbs", false)', 12)


What that does, is after 4 seconds send the string 'EnableTriggerGroup ("Herbs", false)' to the scripting engine (destination 12) to be executed then.

USA #19
<aliases>
<alias
match="pick *"
enabled="y"
send_to="12"
sequence="100"
>
<send>herb = "%1"
EnableTriggerGroup ("Herbs", true)
Send "plants"</send>
</alias>
</aliases>

<triggers>
<trigger
group="Herbs"
keep_evaluating="y"
match="^(.*) \((.*?)\) (.*) (.*?) left\.$"
omit_from_output="y"
regexp="y"
script="do_pick"
sequence="100"
>
</trigger>
</triggers>

I had to change the trigger because of the space difference in each one. from the (chervil) to the number in the room.

Herb is the variable I use to see which herb I am currently picking. Now what I want to do is get the herb i am currently pick see what month its hibernation is, and if it so happens to be that the month is its hibernation month it wont pick it. However, I am not sure how I need to set it up to check for the one specific herb.
Australia Forum Administrator #20
Quote:

I want to do is get the herb i am currently pick see what month its hibernation is ...


The easiest way of doing that is to rejig your table a bit. You had a table of tables, but to look up the month corresponding to a herb, this is simpler:

 
herbs = {
        arnica    = 'Klangiary',
        calamus   = 'Dioni',
        chervil   = 'Roarkian',
        colewort  = 'Kiani',
        coltsfoot = 'Juliary',
        faeleaf   = 'Juliary',
        flax      = 'Estar',
        galingale = 'Shanthin',
        horehound = 'Vestia',
        juniper   = 'Dioni',
        kafe      = 'Urlachmar',
        kombu     = 'Dioni',
        marjoram  = 'Shanthin',
        merbloom  = 'Estar',
        mistletoe = 'Avechary',
        myrtle    = 'Estar',
        pennyroyal = 'Klangiary',
        reishi    = 'Tzarin',
        rosehips  = 'Shanthin',
        sage      = 'Dioni',
        sargassum = 'Tzarin',
        sparkleberry = 'Dvarsh',
        weed      = 'Estar',
        wormwood  = 'Vestia',
        yarrow    = 'Roarkian',
}

print (herbs.yarrow) -- Roarkian



See how in this case I simply put the herb name in, and get its month? In your case you might say:


foundherb = wildcs [2]
hibernate_month herbs [foundherb]

if month == hibernate_month then
   Note("Hibernating")
else
-- blah blah





What might help you is the TraceOut function which is new to MUSHclient from version 3.68 onwards. This lets you put debugging stuff into your script, which only appears if you turn on Game -> Trace.

I have modified your existing script (I know it isn't working, but to show you the idea) to add some traces:


function do_pick (name, output, wildcs)
 TraceOut "in do_pick"

 table.foreach (wildcs, 
    function (k, v) TraceOut ("wildcard ", k, " = ", v) end  )

 TraceOut ("month = ", month)
 TraceOut ("herb = ", herb)

 for _, v in ipairs (herbs) do
  if month == v.month then
   Note("Hibernating")
  else
   if wildcs[2] == herb then 
    TraceOut ("we have ", wildcs[4], " of ", wildcs[2])
    if tonumber (wildcs[4]) > 10 then
     Send("pick ", herb)
    else
     Note("No more for you to pick.")
     Send("inr all ", herb)
     DoAfter(4, EnableTriggerGroup ("Herbs", false))
    end
   end
 end
end
end


Now if we go to the Game menu and turn Trace on, and then find a herb, we see this:


TRACE: Matched trigger "^(.*) \((.*?)\) (.*?) left\.$"
TRACE: Executing trigger script "do_pick"
TRACE: in do_pick
TRACE: wildcard 1 = A sprig of chervil
TRACE: wildcard 2 = chervil
TRACE: wildcard 3 = 11
TRACE: wildcard 0 = A sprig of chervil (chervil) 11 left.
TRACE: month = nil
TRACE: herb = nil


However as soon as we turn Trace off, the spammy output goes away. So it is useful to have your debugging code there, until everything is working.

Here I am displaying the wildcard contents, and the values of 'month' and 'herb' so I can see what is going on.
USA #21
After a little toying around I got this...

TRACE: Matched alias "pick *"
plants
TRACE: Executing trigger script "do_pick"
TRACE: in do_pick
TRACE: wildcard 1 = A sprig of marjoram
TRACE: wildcard 2 = marjoram
TRACE: wildcard 3 =
TRACE: wildcard 4 = 60
TRACE: wildcard 0 = A sprig of marjoram (marjoram) 60 left.
TRACE: month = Roarkian
TRACE: herb = chervil
TRACE: Executing trigger script "do_pick"
TRACE: in do_pick
TRACE: wildcard 1 = A stem of galingale
TRACE: wildcard 2 = galingale
TRACE: wildcard 3 =
TRACE: wildcard 4 = 60
TRACE: wildcard 0 = A stem of galingale (galingale) 60 left.
TRACE: month = Roarkian
TRACE: herb = chervil
TRACE: Executing trigger script "do_pick"
TRACE: in do_pick
TRACE: wildcard 1 = A sprig of chervil
TRACE: wildcard 2 = chervil
TRACE: wildcard 3 =
TRACE: wildcard 4 = 45
TRACE: wildcard 0 = A sprig of chervil (chervil) 45 left.
TRACE: month = Roarkian
TRACE: herb = chervil
Hibernating

I think I can say... it works now woo.
USA #22
argh ok now i have another problem, when there is none of a herb in the room i am wanting to pick, the triggers stay on, i need a way to turn them off if there is none of that herb in the room, any suggestions on how i could do that?
USA #23
Heh, alrighty back to my harvesting script! hehe. I've had it working the way I wanted since my last post, but now I need a table with each herbs price, and i thought i could make a table with many tables in it, but I dont know if i can do it and still work the way it does now...
Australia Forum Administrator #24
You can certainly make a table with tables in it, but it won't work exactly the same as now.


herbs = {
        arnica    = { month = 'Klangiary', price = 20 },
        calamus   = { month = 'Dioni', price = 20 },
-- and so on ... 
}


Now you need to reference the key in the subtable to get the items (month, price), like this:


print (herbs.arnica.month, herbs.arnica.price) --> Klangiary 20

USA #25
after going to 2.73 i get this error now.

Error number: 0
Event: Run-time error
Description: [string "Plugin"]:261: attempt to index global `herb' (a string value)
stack traceback:
[string "Plugin"]:261: in function `do_pick'
Called by: Function/Sub: do_pick called by trigger
Reason: processing trigger ""

not sure whats happening.
Russia #26
You probably accidentally set the herb object to a string. Try doing a search for "herb =" in your plugin file, and see if there's a string being assigned to it somewhere.
Australia Forum Administrator #27
Are you getting confused between "herb" and "herbs"? One is the name of a herb, the other is a table of herbs.
USA #28
i have an alias that sets herb to a string because its a word, and i thought a word had to be a string?
Australia Forum Administrator #29
You get your exact error message if you try to do this:


herb = "arnica"
print (herb [22]) --> attempt to index global `herb' (a string value)


You cannot index into a string. Do you mean "herbs" which is your table of herbs?
USA #30
function do_pick (name, output, wildcs)
--TraceOut "in do_pick"

-- table.foreach (wildcs, 
  --  function (k, v) TraceOut ("wildcard ", k, " = ", v) end  )

 --TraceOut ("month = ", month)
 --TraceOut ("herb = ", herb)
  hibernate_month = herbs [herb.month]
   if (wildcs[2]) == herb then
    if month == hibernate_month then
     Note("Hibernating")
    else
   --TraceOut ("we have ", wildcs[4], " of ", wildcs[2])
     if tonumber (wildcs[4]) > 10 then
      Send("pick ", herb)
      Note("There are ", ((wildcs[4])-10), " left to pick.")
     else
      Note("No more for you to pick.")
      Send("inr all ", herb)
       if spices == true then
        Send("inr all spices")
        spices = nil
       end
      DoAfterSpecial (2, 'EnableTriggerGroup ("Herbs", false)', 12)
   end
 end
end
end


thats my function, and I still dont see where it attempts to index it? I see wildcs[2] trying to check it, maybe I did something wrong there?
Australia Forum Administrator #31
This line:


hibernate_month = herbs [herb.month]


In Lua saying "herb.month" is the same as writing:


herb ["month"]


Thus, you are indexing into "herb".
USA #32
ok i changed herbs [herb.month] to herb ["month"] but I still get the same error. So i'm guessing that wouldn't be how to fix it maybe, mind helping me here, cause I have no clue how to fix it.
Amended on Sun 19 Feb 2006 12:22 AM by Metsuro
Australia Forum Administrator #33
Quote:

i changed herbs [herb.month] to herb ["month"] but I still get the same error


I said those 2 were the same, so I'm not sure how you thought that changing it from one to the other would help.

Do you mean:


hibernate_month = herbs [month]


USA #34
Well before I downloaded the new verison of mush it worked the way I had it. but does herbs [month] check the specific herbs month?
USA #35
Alright stupid me didn't save a copy before I started trying to fix things, so i think I broke a whole lot more...


<!--  Triggers  -->

<triggers>
  <trigger
   group="Herbs"
   match="^Hmm\, that wasn\'t the herb you thought after all\. It was some rare spices\!$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>spices = true</send>
  </trigger>
  <trigger
   group="Herbs"
   match="^Today is the (.*?) of (.*?)\,(.*)"
   match_inverse="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>month = "%2"</send>
  </trigger>
  <trigger
   custom_colour="2"
   group="Herbs"
   match="You have recovered balance on all limbs."
   regexp="y"
   sequence="99"
  >
  <send>plants</send>
  </trigger>
  <trigger
   group="Herbs"
   keep_evaluating="y"
   match="^(.*) \((.*?)\) (.*) (.*?) left\.$"
   omit_from_output="y"
   regexp="y"
   sequence="99"
  >
  </trigger>
  <trigger
   group="Herbs"
   match="The following plants are growing in this room:"
   omit_from_output="y"
   sequence="100"
  >
  </trigger>
  <trigger
   group="Herbs"
   match="^(.*) \((.*)\) (.*) (.*?) left\.$"
   regexp="y"
   script="do_pick"
   sequence="100"
  >
  </trigger>
  <trigger
   enabled="y"
   expand_variables="y"
   group="Alerts"
   match="Your last login was from domain:"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>send "date"</send>
  </trigger>
</triggers>

<!--  Aliases  -->

<aliases>
  <alias
   match="pick *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>herb = "%1"
EnableTriggerGroup ("Herbs", true)
Send "plants"</send>
  </alias>
</aliases>

<!--  Script  -->


<script>
<![CDATA[
herbs = {
        arnica    = { month = 'Klangiary', price = 5 },
        calamus   = { month = 'Dioni', price = 10 },
        chervil   = { month = 'Roarkian', price = 5 },
        colewort  = { month = 'Kiani', price = 5 },
        coltsfoot = { month = 'Juliary', price = 5 },
        faeleaf   = { month = 'Juliary', price = 5 },
        flax      = { month = 'Estar', price = 5 },
        galingale = { month = 'Shanthin', price = 8 },
        horehound = { month = 'Vestia', price = 7 },
        juniper   = { month = 'Dioni', price = 7 },
        kafe      = { month = 'Urlachmar', price = 7 },
        kombu     = { month = 'Dioni', price = 8 },
        marjoram  = { month = 'Shanthin', price = 7 },
        merbloom  = { month = 'Estar', price = 5 },
        mistletoe = { month = 'Avechary', price = 5 },
        myrtle    = { month = 'Estar', price = 7 },
        pennyroyal = { month = 'Klangiary', price = 7 },
        reishi    = { month = 'Tzarin', price = 8 },
        rosehips  = { month = 'Shanthin', price = 5 },
        sage      = { month = 'Dioni', price = 6 },
        sargassum = { month = 'Tzarin', price = 6 },
        sparkleberry = { month = 'Dvarsh', price = 5 },
        weed      = { month = 'Estar', price = 5 },
        wormwood  = { month = 'Vestia', price = 7 },
        yarrow    = { month = 'Roarkian', price = 6 },
}

spices = nil
function do_pick (name, output, wildcs)
--TraceOut "in do_pick"

-- table.foreach (wildcs, 
  --  function (k, v) TraceOut ("wildcard ", k, " = ", v) end  )

 --TraceOut ("month = ", month)
 --TraceOut ("herb = ", herb)
  hibernate_month = (herbs.herb.month)
   if wildcs[2] == herb then
    if month == hibernate_month then
     Note("Hibernating")
    else
   --TraceOut ("we have ", wildcs[4], " of ", wildcs[2])
     if tonumber (wildcs[4]) > 10 then
      Send("pick ", herb)
      Note("There are ", ((wildcs[4])-10), " left to pick.")
     else
      Note("No more for you to pick.")
      Send("inr all ", herb)
       if spices == true then
        Send("inr all spices")
        spices = nil
       end
      DoAfterSpecial (2, 'EnableTriggerGroup ("Herbs", false)', 12)
   end
 end
end
end

]]>
</script>

rather upset cause before I went up to the new verison it worked fine, I am just not understanding what happened and what I messed up.
#36
Just curious, but what IRE mud are you playing on? I've never heard of one that had seasons...well, I knew about perenials and the other ones, but people don't even care about that, they just harvest down to the minimum.
USA #37
Lusternia's plants have certain months were they disappear, which is the ones in the table. the month after a room or two will come back with a few of the plant, then they must be reharvested. This script used to work with the older verions of mushclient, which I find very odd... and cant seem to tell... where I screwed up or how i might fix it.
Australia Forum Administrator #38
I really don't think that using the latest version of MUSHclient will cause a Lua script to stop working. If you really think that is the case, download the earlier version of MUSHclient and see if that is really the problem.

Providing line-by-line debugging of users scripts is more than I can offer on this forum. I can help with suggestions about how to make things work with MUSHclient, and provide snippets which illustrate these ideas.

The suggestions I provide usually both compile and work in the test environment that I am using to demonstrate an idea. However it is up to you to make them work for a particular MUD.

If you are having problems with syntax errors in Lua, or working out how to get it to do things, then there is excellent documentation on the Lua site, an online "Lua Manual" which you can read, or download for local use. Or, you can buy it as a paperback book, as I have done.

You recent post about it "not working" is very non-specific. Does it not work because of compile-time errors, run-time errors, triggers not matching, script not doing what you expect, or what? It is very hard to debug a simple "it doesn't work" claim.
USA #39
Its the same error I've had for awhile, i've said the error twice in this forum, you told me I was indexing a global variable, so I didn't know how to change it so it would work.
Australia Forum Administrator #40
I have got rid of that error message by changing:


hibernate_month = (herbs.herb.month)


to:


hibernate_month = (herbs [herb].month)


The reason for this is that we don't want literally "herb", we want what the variable herb contains. This change does that.
USA #41
alright I am now getting a new error.

<aliases>
  <alias
   match="pick *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>herb = %1
EnableTriggerGroup ("Herbs", true)
Send "plants"</send>
  </alias>


gives me this error...

Error number: 0
Event:        Run-time error
Description:  [string "Alias: "]:4: attempt to index field `herb' (a nil value)
stack traceback:
	[string "Alias: "]:4: in main chunk
Called by:    Immediate execution


but i thought that herb = %1 would work, I've used it this way for a few things and it used to work, unless i'm mistake, how might i be able to fix that?
Australia Forum Administrator #42
herb = "%1"