[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Tips and tricks
. . -> [Subject]  CallPlugin and multiple parameters.
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

CallPlugin and multiple parameters.

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


Posted by Shadowfyr   USA  (1,783 posts)  [Biography] bio
Date Fri 20 Sep 2002 06:38 AM (UTC)

Amended on Fri 20 Sep 2002 06:44 AM (UTC) by Shadowfyr

Message
Well since there seems to be no real way to do this with the call. I have come up with this instead>

'==========================================================================================
'Latch for External plugin calls.
'
'Call syntax is "Name(Param,Param2,...)"
' i.e. CallPlugin "22ca9b6ff9d79f1a8e9f5895","CallLatch","Potion_Setcolor(title,#B0F080)"
'==========================================================================================
'NOTE: A call that uses () and (something) will both produce 1 parameter. Make sure you
'have error checking in the sub you call from here to deal with invalid values. ;)
'==========================================================================================
sub CallLatch (CallInf)
  dim temp,params,npar
  temp = split(CallInf, "(")    'Break things up at the first bracket, so temp(0) is the Sub and temp(1) is params.
  if ubound(temp) = 1 then      'If there are any parameters, remove the ) and split them into seperate bits.
    temp(1) = replace(temp(1),")","")
    params = split(temp(1),",")
  end if
  select case temp(0)   'Check against the Sub name to find a match.
    case "Potion_Setcolor"   ' Check against the first valid sub (this can be anything, but
                             ' is less confusing if it matches the real name).
      npar = 2   'How many parameters should there be?
      if ubound(params) <> npar - 1 then   'Test npar - 1 (arrays are 1 less than the 'real'
                                           'number of parameters. If it fails show an error.
        world.colournote "Red","Black", "Error: Invalid call to CallLatch in " & world.getpluginname & "."
        world.colournote "Red","Black", "Call was " & CallInf
        world.colournote "Red","Black", "  Error -- Invalid number of parameters. Should be " & npar & "."
        world.colournote "Red","Black", " "
      else   ' Everything looks OK, so lets make the real call here.
        call Potion_Setcolor(trim(params(0)),trim(params(1)))
      end if
    case else   'This is if we mis-spell are sub name in the other plugin/script or we
                'Tried to call a sub this plugin doesn't support.
      world.colournote "Red", "Black", "Error: Invalid call to CallLatch in " & world.getpluginname & "."
      world.colournote "Red", "Black", "Call was " & CallInf
      world.colournote "Red","Black", "  Error -- No such routine can be called."
      world.colournote "Red", "Black", " "
  end select 
end sub


This comes straight out of some upgrades I am making to a plugin and if used right will 'fake' a real call. Though it does require that you add your own test and error messages, etc. ;)
[Go to top] top

Posted by Vaejor   (120 posts)  [Biography] bio
Date Reply #1 on Fri 20 Sep 2002 12:58 PM (UTC)
Message
Why not just send through an array as your single parameter?
[Go to top] top

Posted by Shadowfyr   USA  (1,783 posts)  [Biography] bio
Date Reply #2 on Fri 20 Sep 2002 01:45 PM (UTC)
Message
I could have, but this way you 'seem' to be calling the exact routine that is used internally by the plugin. But also, according to Nick it is not technically allowed, since he is not sure if all script types support such an array.
[Go to top] 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.


3,651 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]