create account

a script for mudlet to setup channel specific chat modes by jfmherokiller

View this thread on: hive.blogpeakd.comecency.com
· @jfmherokiller ·
$0.15
a script for mudlet to setup channel specific chat modes
This script allows  you to change where your command text is sent based on defined channels (it works really well with a tabbed chat window)
```
local Chats = {
  "New",
  "Pub",
  "OOC",
  "Auction",
  "Update"
}
SelectedMode = "None"
changeCMDInput = false
--capture chat line and prepend channel to beginning
function controlInput(_, command)
    if changeCMDInput and SelectedMode ~= "None" then
        changeCMDInput = false --set this if check to false to it doesn't occur every input
        --Also set the bool check BEFORE any send() functions within a sysDataSendRequest function
        send(SelectedMode .. " " .. command, false) --Duplicate and unknown command
        denyCurrentSend() --Deny the original command, not the commands sent with sendAll.
        changeCMDInput = true
    end
end
--remove the chat redirection
function UnregisterChatHandler()
    killAnonymousEventHandler(myevent)
end
--enable speaking only in selected channel mode
function SetChatMode(ModeToSet)
    if (table.contains(Chats, ModeToSet)) then
        SelectedMode = ModeToSet
    else
        SelectedMode = "None"
    end
    changeCMDInput = true
end
--setup the chat
function SetupChatMode()
    --generate aliases for all enabled chats
    for k, v in pairs(Chats) do
        local realCode = 'SetChatMode("' .. v .. '")'
        local StringToCheck = "^" .. "SetChatModeTo" .. v .. "$"
        tempAlias(StringToCheck, realCode)
    end
    --setup the disable and removal aliases
    tempAlias("^setChatModeToNone$", [[SetChatMode("None")]])
    tempAlias("^RemoveChatMode$", [[UnregisterChatHandler()]])
    --register the chat redirection event
    myevent = myevent or registerAnonymousEventHandler("sysDataSendRequest", "controlInput")
end
```
👍  , , , , , , , , ,
properties (23)
authorjfmherokiller
permlinka-script-for-mudlet-to-setup-channel-specific-chat-modes
categoryprogramming
json_metadata{"tags":["programming","technology","mudlet","lua"],"app":"hiveblog/0.1","format":"markdown"}
created2020-07-07 07:21:00
last_update2020-07-07 07:21:00
depth0
children2
last_payout2020-07-14 07:21:00
cashout_time1969-12-31 23:59:59
total_payout_value0.076 HBD
curator_payout_value0.074 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,751
author_reputation311,353,057,143
root_title"a script for mudlet to setup channel specific chat modes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,385,436
net_rshares623,187,558,059
author_curate_reward""
vote details (10)
@gitplait-mod2 ·
Great works man. Thanks for sharing

<sub> **Your post has been submitted to be manually curated by @gitplait community account because this is the kind of publications we like to see in our community.** </sub>

Join our [Community on Hive](https://hive.blog/trending/hive-103590) and Chat with us on [Discord](https://discord.gg/CWCj3rw).

[[Gitplait-Team]](https://gitplait.tech/)

👍  
properties (23)
authorgitplait-mod2
permlinkre-jfmherokiller-qd38jb
categoryprogramming
json_metadata{"tags":["programming"],"app":"peakd/2020.07.1"}
created2020-07-07 07:23:36
last_update2020-07-07 07:23:36
depth1
children1
last_payout2020-07-14 07:23:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length384
author_reputation28,898,670,427
root_title"a script for mudlet to setup channel specific chat modes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,385,460
net_rshares959,178,666
author_curate_reward""
vote details (1)
@jfmherokiller ·
What suprised me the most was that I was able to "construct" regex strings manually before passing them to the function
properties (22)
authorjfmherokiller
permlinkqd38q4
categoryprogramming
json_metadata{"app":"hiveblog/0.1"}
created2020-07-07 07:27:54
last_update2020-07-07 07:27:54
depth2
children0
last_payout2020-07-14 07:27:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length119
author_reputation311,353,057,143
root_title"a script for mudlet to setup channel specific chat modes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,385,532
net_rshares0