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 ➜ Using the Chat system with lua?

Using the Chat system with lua?

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


Posted by Supyo   (1 post)  Bio
Date Sun 12 Jul 2009 07:26 AM (UTC)

Amended on Sun 12 Jul 2009 11:22 AM (UTC) by Supyo

Message
I know there is a plugin which comes with MUSH which ables people to use the chat system easier, but how would one go about adding your hit points to when ever you chat?

I'm just learning to script using lua, so I don't even know where to start, any help would be appreciated.

*/*hp */*m */*mv *br

That's my prompt

I also am having trouble being able to send things into chat on triggers, for example

<triggers>
<trigger
enabled="y"
match="* has been blinded."
send_to="12"
sequence="100"
>
<send>ChatEverybody &quot;(%1)is blind&quot;, 1</send>
</trigger>
</triggers>

doesn't work I get

Compile error
World: Untitled world
Immediate execution
[string "Trigger: "]:1: unexpected symbol near '<'

No clue what that means.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 12 Jul 2009 09:50 PM (UTC)
Message
First, paste the trigger in like this:

http://mushclient.com/pasting

The < and > symbols are part of the XML way that triggers are displayed. Don't type them into the trigger itself.


Second, the examples in the chat write-up are for VBscript. Lua needs brackets around function arguments, a minor change. So, change:


ChatEverybody "(%1)is blind", 1


to:


ChatEverybody ("%1 is blind", 1)



As for adding the HP to every message, I'll look into that now ...

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Sun 12 Jul 2009 10:29 PM (UTC)

Amended on Sun 12 Jul 2009 10:33 PM (UTC) by Nick Gammon

Message
This plugin shows how you can add your HP to every outgoing message.

It detects outgoing chat messages, and uses your most recent prompt (if any) to amend the message by putting your HP after the quote that is normally in the message.

In other words, it changes:


Nick chats to everybody, 'hi there everyone'

to:

Nick chats to everybody, '[20] hi there everyone'


... assuming your HP are 20.

To use this, copy between the lines, paste into a text document (eg. MUSHclient's notepad) and save to disk as Add_HP_to_chat_messages.xml.

Then use File menu -> Plugins to install as a plugin.

If anyone else wants to use it, you would need to change the trigger "match" line to match your prompt.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Monday, July 13, 2009, 7:47 AM -->
<!-- MuClient version 4.42 -->

<!-- Plugin "Add_HP_to_chat_messages" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Add_HP_to_chat_messages"
   author="Nick Gammon"
   id="32d08b53ff6acd8df946b0a1"
   language="Lua"
   purpose="Adds your HP to outgoing chat messages"
   date_written="2009-07-13 07:39:53"
   requires="4.40"
   version="1.0"
   >

</plugin>


<!--  Triggers  -->

<triggers>
  <trigger
   enabled="y"
   match="*/*hp */*m */*mv *br*"
   send_to="12"
   sequence="100"
  >
  <send>hp = %1</send>
  </trigger>
</triggers>

<!--  Script  -->


<script>
<![CDATA[
function OnPluginChatMessageOut (id, message, sText)

  -- providing we have not already added the HP to the message
  -- handle messages 4 (chat to everybody)  
  --                 5 (chat to one person)
  --                 6 (chat to group)
  -- and we know the HP 
  
  if not reformatting and 
     message >= 4 and 
     message <= 6 and
     tonumber (hp) then

    reformatting = true  -- stop recursing to do it again

    -- add the HP after the quote in bold (1) and green (32)
    sText = string.gsub (sText, "'\027", string.format ("'%s[%i] \027", ANSI (1, 32), hp), 1)
    
    -- send the amended message
    ChatMessage (id, message, sText)

    -- return so we don't send it twice
    reformatting = false
    return false
  end -- if

  -- send normally
  return true
end -- OnPluginChatMessageOut 


]]>
</script>


</muclient>

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


13,563 views.

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.