Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Simple script

Simple script

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


Pages: 1  2  3 

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #30 on Sat 18 Feb 2006 03:21 PM (UTC)
Message
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?

Everything turns around in the end
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #31 on Sat 18 Feb 2006 10:29 PM (UTC)
Message
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".

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #32 on Sat 18 Feb 2006 11:50 PM (UTC)

Amended on Sun 19 Feb 2006 12:22 AM (UTC) by Metsuro

Message
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.

Everything turns around in the end
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #33 on Sun 19 Feb 2006 05:26 AM (UTC)
Message
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]



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #34 on Sun 19 Feb 2006 06:23 AM (UTC)
Message
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?

Everything turns around in the end
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #35 on Sun 19 Feb 2006 04:26 PM (UTC)
Message
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.

Everything turns around in the end
Top

Posted by Nexes   (65 posts)  Bio
Date Reply #36 on Fri 24 Feb 2006 02:25 AM (UTC)
Message
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.
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #37 on Fri 24 Feb 2006 02:00 PM (UTC)
Message
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.

Everything turns around in the end
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #38 on Fri 24 Feb 2006 07:22 PM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #39 on Fri 24 Feb 2006 07:42 PM (UTC)
Message
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.

Everything turns around in the end
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #40 on Sun 26 Feb 2006 02:25 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #41 on Thu 02 Mar 2006 01:42 AM (UTC)
Message
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?

Everything turns around in the end
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #42 on Fri 03 Mar 2006 05:55 AM (UTC)
Message
herb = "%1"

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


97,791 views.

This is page 3, subject is 3 pages long:  [Previous page]  1  2  3 

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

Go to topic:           Search the forum


[Go to top] top

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