Cross Profile Communication - CPC

Share your scripts and packages with other Mudlet users.
Post Reply
takilara
Posts: 26
Joined: Tue Jul 28, 2020 10:23 pm

Cross Profile Communication - CPC

Post by takilara »

I've made a simple package that make it convenient to "send orders" to other profiles.

Package is here:
https://github.com/takilara/cpc/releases/latest

Currently supported commands:
  • #HELP - In game help
  • #ALL <command> - Asks all profiles to execute the command
  • #DO <command> - Asks all profiles except the current, to execute the command
  • #BID <profile> <command> - Ask the speficied profile to execute the command
I hope this is of help to someone.

regards

User avatar
Vadi
Posts: 4941
Joined: Sat Mar 14, 2009 3:13 pm

Re: Cross Profile Communication - CPC

Post by Vadi »

Nice! Works well. As a reminder you need to install this package in all profiles you'd like to be hooked up,

beckham894
Posts: 14
Joined: Thu Aug 30, 2018 2:07 pm

Re: Cross Profile Communication - CPC

Post by beckham894 »

One more friendly reminder is that the profile name must be in one single word in order to make #bid command works.

User avatar
Vadi
Posts: 4941
Joined: Sat Mar 14, 2009 3:13 pm

Re: Cross Profile Communication - CPC

Post by Vadi »

Indeed. Maybe the new getProfileTabNumber() function can be used here to specify the tab #?

beckham894
Posts: 14
Joined: Thu Aug 30, 2018 2:07 pm

Re: Cross Profile Communication - CPC

Post by beckham894 »

I also found one strange thing while testing the code.
lets say i have the below code setup:
Code: [show] | [select all] lua
sendAll("get water from bag", "give water to (profile A/B)", false)
expandAlias("#bid (profile A/B) put water in bag", false)
when fire from profile A, the code work perfectly. (profile A get water from bag and pass it to profile B then profile B put water in bag)

but when fire from profile B, somehow the #bid code is executed first in profile A then sendAll code is executed in profile B. (profile A put "water (which is none) in bag first then profile B get water from bag and pass it to profile A)

Any idea why?

User avatar
Vadi
Posts: 4941
Joined: Sat Mar 14, 2009 3:13 pm

Re: Cross Profile Communication - CPC

Post by Vadi »

I haven't tried it out, but this could be due to the use of expandAlias - I understand it's a bad habit from other clients. Try `cpc:handleCommand("big", "(profile A/B) put water in bag")` instead.

beckham894
Posts: 14
Joined: Thu Aug 30, 2018 2:07 pm

Re: Cross Profile Communication - CPC

Post by beckham894 »

Nope it was expandAlias problem. Using cps:handleCommand result is the same

takilara
Posts: 26
Joined: Tue Jul 28, 2020 10:23 pm

Re: Cross Profile Communication - CPC

Post by takilara »

beckham894 wrote:
Sun Mar 14, 2021 7:17 pm
I also found one strange thing while testing the code.
lets say i have the below code setup:
Code: [show] | [select all] lua
sendAll("get water from bag", "give water to (profile A/B)", false)
expandAlias("#bid (profile A/B) put water in bag", false)
when fire from profile A, the code work perfectly. (profile A get water from bag and pass it to profile B then profile B put water in bag)

but when fire from profile B, somehow the #bid code is executed first in profile A then sendAll code is executed in profile B. (profile A put "water (which is none) in bag first then profile B get water from bag and pass it to profile A)

Any idea why?
Sorry, i didnt notice this message :(
I am not sure if the last message means that it is not an issue when using cpc:handleCommand or if the issue occurs with both modes.

I'll see if i can reproduce it, sounds really strange though, I dont really know how the sendAll works, it almost sounds like it gets placed onto the execution thread as an event, and for some reason it is then handled after the #BID event.

A workaround may be to use a tempTimer to force delay of the #BID command, though if handleCommand solves it, i would rather recommend using that.

(personally i use #BID for anything i execute manually, e.g. things i type in, or place on my F-keys. And i use cpc:handleCommand for anything i script)

Post Reply