"You're Too Far Away!" MUSHClient plugin

Talk about anything TI here! Also include suggestions for the game, website, and these forums.

Moderators: Maeve, Maeve

Post Reply
User avatar
Pixie
Posts: 255
Joined: Tue Sep 30, 2014 1:55 pm
Location: Sol System

Tue Oct 04, 2016 8:34 am

Super tired of trying to hand things to people/NPCs, only to find that they're too far away?! ME TOO!

Lets say you want to hand a bottle of rum to your servant Bill, but oh no! He's halfway across the room! Simply enter "give rum Bill" from any distance, and the plugin will know that you're too far away from him, approach him for you, and hand him the item when you've gotten close enough.

This plugin does not support combat situations of any kind.

Credits: Original by Galaban, altered for TI syntax by Pixie.

Installation:

Go into Program FIles -> MUSHclient -> worlds -> plugins

Copy this into a fresh notepad file:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
<plugin
   name="Too_Far_Away"
   author=" Galaban"
   id="1559876f89e24dbf07374dc1"
   language="Lua"
   purpose="automatically approach if needed"
   save_state="y"
   date_written="2016-03-04 07:20:36"
   requires="4.60"
   version="1.0"
   >

</plugin>


<!--  Triggers  -->

<triggers>

  <!-- triggers for watching our status after we enter the "give" command -->
  <trigger
   group="giveChecks"
   enabled="n"
   match="* needs to be closer to *."
   send_to="12"
   sequence="100"
   script="approachDone"
  />

  <trigger
   group="giveChecks"
   enabled="n"
   match="You're too far away!"
   send_to="12"
   sequence="100"
   script="needApproach"
  />

  <trigger
   group="giveChecks"
   enabled="n"
   match="You give * to *."
   send_to="12"
   sequence="100"
   script="gaveDone"
  />
  <trigger
   group="giveChecks"
   enabled="n"
   match="Nothing found to give."
   send_to="12"
   sequence="100"
   script="gaveDone"
  />

  <!-- always-on triggers for monitoring approaches -->
  <trigger
   enabled="y"
   match="Approach whom?"
   send_to="12"
   sequence="100"
   script="approachCancel"
  />

  <trigger
   enabled="y"
   match="Where is it * wants to go?"
   send_to="12"
   sequence="100"
   script="approachCancel"
  />

  <trigger
   enabled="y"
   match="* has reached * target."
   send_to="12"
   sequence="100"
   script="approachDone"
  />

  <trigger
   enabled="y"
   match="* comes to a stop."
   send_to="12"
   sequence="100"
   script="approachCancel"
  />

  <trigger
   enabled="y"
   match="* moves toward *."
   send_to="12"
   sequence="100"
   script="approachStart"
  />
  
  <trigger
   enabled="y"
   match="* is already there!"
   send_to="12"
   sequence="100"
   script="approachDone"
  />

</triggers>

<!--  Aliases  -->

<aliases>
  <alias
   match="^give (.+) (\S+)$"
   enabled="y"
   regexp="y"
   expand_variables="y"
   group="BOT"
   send_to="12"
   sequence="100"
  >
  <send>autoGive("%1", "%2")</send>
  </alias>
</aliases>

<!--  Script  -->


<script>
<![CDATA[


------------------------
--  AutoGive
--
local closeto = ""
local approaching = ""
local approachCmd = ""
local giveCmd = ""
local tmpGive = nil

function autoGive(object, person)

    EnableTriggerGroup("giveChecks", true)
    approachCmd = ""
    giveCmd = ""
    if (closeto == "" or string.find(closeto, person) == nil) then        
        tmpGive = object .. " " ..person
        Send("approach "..person)
    else
        approachCmd = person
        giveCmd = object

        Send("give "..object .. " " ..person)
    end
end

function needApproach()
    if (approachCmd == "") then return end
    Send("approach "..approachCmd)

    tmpGive = giveCmd .. " " ..approachCmd

    approachCmd = ""
    giveCmd = ""
end

function gaveDone()
    EnableTriggerGroup("give", false)
end

function approachStart(rName, rLine, rWildcards)
    approaching = string.lower(rWildcards[1])
end

function approachDone()

    EnableTriggerGroup("give", false)

    --stack them so that the string.find will find them
    closeto = closeto.." " ..approaching

    approaching = ""
    approachCmd = ""
    giveCmd = ""

    if (tmpGive == nil) then
        return
    end

    Send("give "..tmpGive)
    tmpGive = nil
end

function approachCancel()
    clearCommands()
end

function clearCommands()
   closeto = ""
    approaching = ""
    approachCmd = ""
    giveCmd = ""
    tmpGive = nil
    EnableTriggerGroup("giveChecks",false)
end

function string.starts(String,Start)
   return string.sub(String,1,string.len(Start))==Start
end

function OnPluginBroadcast (msg, id, name, text)
   if (id == 'b3aae34498d5bf19b5b2e2af') then
      if (text == "reload") then
            clearCommands()
      end
      if (string.starts(text,"ROOMVNUM")) then
            clearCommands()
        end
      return
  end
end


Note("[Pixie's 'You're Too Far Away!' script loaded.]")

]]>
</script>


</muclient>
Do "save as" and enter "TooFarAway.xml". Close it. Place the file into the plugins folder.

Open up TI in MUSHclient. Go up to File -> Plugins. Click add, locate the plugin and open. The ToFarAway plugin should now be listed there. Highlight it and install/enable.

Using the Plugin: You don't have to do anything special to use it. Just try to hand something to someone that's too far away, and watch it work!

Silrie

Tue Oct 04, 2016 10:51 pm

*serenades the Pixie*

Have I told you lately

That I love you!

Silrie

Wed Oct 05, 2016 9:40 pm

Hmmm, this works really great when you're too far away, but if you're close enough, it won't let you give anything over.

User avatar
Pixie
Posts: 255
Joined: Tue Sep 30, 2014 1:55 pm
Location: Sol System

Thu Oct 06, 2016 2:30 pm

Fixing! Will post this evening with the updated script.

User avatar
Pixie
Posts: 255
Joined: Tue Sep 30, 2014 1:55 pm
Location: Sol System

Sat Dec 16, 2017 12:28 am

A billion years later, fixed the plugin. Just edited the main post above, so the instructions still stand.

User avatar
The_Last_Good_Dragon
Posts: 254
Joined: Sun Feb 14, 2016 1:08 am

Sun Dec 17, 2017 11:18 am

I am in love!!
~~ Team Farra'n'Stuff. ~~

User avatar
Kuzco
Posts: 180
Joined: Wed Sep 07, 2016 2:12 am

Mon Dec 18, 2017 8:29 am

Lord bless!

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 14 guests