Handling MSDP

  • GickerLDS
  • GickerLDS's Avatar Topic Author
  • Offline
  • New Member
More
15 Sep 2014 19:30 #1 by GickerLDS
Handling MSDP was created by GickerLDS
Hi guys,

Wondering if anyone can help me with setting up the client here for using msdp in creating various graphical elements. The one I wanted to start with was the group tab, but if there's something simpler, that would be fine too, like a graphical representation or hp, mv and exp_tnl.

I have Kavir's protocol snippet working on a CircleMUD 3.1 base. I've managed to get it to work by copying what others have done.. but my understanding from scratch is very limited.

Thanks guys,

Gicker

Please Log in or Create an account to join the conversation.

More
15 Sep 2014 20:26 #2 by plamzi
Replied by plamzi on topic Handling MSDP
Gicker,

To get started, go to Articles & Scripts, and make a copy of GroupTab.js. Put it in "Private", edit it, and add a meta tag containing your server and port, e. g. "mud.d20mud.com:6000". Then, at the very bottom, change it to listen to 'msdp' instead of 'gmcp'.

Then, hit your app URL with two extra parameters:
www.mudportal.com/play?host=mud.d20mud.c...20Wars&dev=1&debug=1

The app should load with your new script included, and it will show you lots of helpful information in the console log. A great way to develop is Firefox + Firebug.

I took a quick look and your game is already negotiating and sending MSDP. So now it's a matter of modifying the Group Tab's update function to read from the incoming MSDP data.
The following user(s) said Thank You: GickerLDS

Please Log in or Create an account to join the conversation.

  • GickerLDS
  • GickerLDS's Avatar Topic Author
  • Offline
  • New Member
More
15 Sep 2014 20:34 - 15 Sep 2014 20:35 #3 by GickerLDS
Replied by GickerLDS on topic Handling MSDP
Thanks Plamzi,

I've done so. I don't see the group tab window, but that may be because it isn't receiving data that the script recognizes.

It's really the update part where I need some direction.

For instance, in my google chrome console I can see the MSDP info being sent.

Eg.
detected msdp:GROUP1_NAMEDrice Util.js?v=85:208
detected msdp:GROUP1_CUR_HP76 Util.js?v=85:208
detected msdp:GROUP1_MAX_HP76 Util.js?v=85:208
detected msdp:GROUP1_CUR_MV1160 Util.js?v=85:208
detected msdp:GROUP1_MAX_MV1160 Util.js?v=85:208
detected msdp:GROUP1_TNL62 Util.js?v=85:208
ÿúEHEALTH76ÿðÿúEMAX_HEALTH76ÿðÿúEMANA0ÿðÿúEMAX_MANA0ÿðÿúEMOVEMENT1160ÿðÿúEMAX_MOVEMENT1160ÿðÿúEOPPONENT_HEALTH0ÿðÿúETANK_HEALTH0ÿðÿúETANK_MAX_HEALTH0ÿðÿúEXP_TNL62ÿðÿúEEXP4780ÿðÿúEEXP_CAP7680ÿðÿúEROOM_MAPDrice&STR: 14 DEX: 17 CON: 13&INT: 14 WIS: 13 CHA: 10&REF: 19 FOR: 24 WIL: 17&&Attacks: (+10)&Damage: 2d8+6&&ÿðÿúEGROUP1_NAMEDriceÿðÿúEGROUP1_CUR_HP76ÿðÿúEGROUP1_MAX_HP76ÿðÿúEGROUP1_CUR_MV1160ÿðÿúEGROUP1_MAX_MV1160ÿðÿúEGROUP1_TNL62ÿð￿ Util.js?v=85:208
detected msdp:HEALTH76 Util.js?v=85:208
detected msdp:MAX_HEALTH76 Util.js?v=85:208
detected msdp:MANA0 Util.js?v=85:208
detected msdp:MAX_MANA0 Util.js?v=85:208
detected msdp:MOVEMENT1160 Util.js?v=85:208
detected msdp:MAX_MOVEMENT1160 Util.js?v=85:208
detected msdp:OPPONENT_HEALTH0 Util.js?v=85:208
detected msdp:TANK_HEALTH0 Util.js?v=85:208
detected msdp:TANK_MAX_HEALTH0 Util.js?v=85:208
detected msdp:XP_TNL62 Util.js?v=85:208
detected msdp:EXP4780 Util.js?v=85:208
detected msdp:EXP_CAP7680 Util.js?v=85:208
detected msdp:ROOM_MAPDrice&STR: 14 DEX: 17 CON: 13&INT: 14 WIS: 13 CHA: 10&REF: 19 FOR: 24 WIL: 17&&Attacks: (+10)&Damage: 2d8+6&& Util.js?v=85:208
detected msdp:GROUP1_NAMEDrice Util.js?v=85:208
detected msdp:GROUP1_CUR_HP76 Util.js?v=85:208
detected msdp:GROUP1_MAX_HP76 Util.js?v=85:208
detected msdp:GROUP1_CUR_MV1160 Util.js?v=85:208
detected msdp:GROUP1_MAX_MV1160 Util.js?v=85:208
detected msdp:GROUP1_TNL62 Util.js?v=85:208
ÿúEHEALTH76ÿðÿúEMAX_HEALTH76ÿðÿúEMANA0ÿðÿúEMAX_MANA0ÿðÿúEMOVEMENT1160ÿðÿúEMAX_MOVEMENT1160ÿðÿúEOPPONENT_HEALTH0ÿðÿúETANK_HEALTH0ÿðÿúETANK_MAX_HEALTH0ÿðÿúEXP_TNL62ÿðÿúEEXP4780ÿðÿúEEXP_CAP7680ÿðÿúEROOM_MAPDrice&STR: 14 DEX: 17 CON: 13&INT: 14 WIS: 13 CHA: 10&REF: 19 FOR: 24 WIL: 17&&Attacks: (+10)&Damage: 2d8+6&&ÿðÿúEGROUP1_NAMEDriceÿðÿúEGROUP1_CUR_HP76ÿðÿúEGROUP1_MAX_HP76ÿðÿúEGROUP1_CUR_MV1160ÿðÿúEGROUP1_MAX_MV1160ÿðÿúEGROUP1_TNL62ÿð￿ Util.js?v=85:208
detected msdp:HEALTH76 Util.js?v=85:208
detected msdp:MAX_HEALTH76 Util.js?v=85:208
detected msdp:MANA0 Util.js?v=85:208
detected msdp:MAX_MANA0 Util.js?v=85:208
detected msdp:MOVEMENT1160 Util.js?v=85:208
detected msdp:MAX_MOVEMENT1160 Util.js?v=85:208
detected msdp:OPPONENT_HEALTH0 Util.js?v=85:208
detected msdp:TANK_HEALTH0 Util.js?v=85:208
detected msdp:TANK_MAX_HEALTH0 Util.js?v=85:208
detected msdp:XP_TNL62 Util.js?v=85:208
detected msdp:EXP4780 Util.js?v=85:208
detected msdp:EXP_CAP7680 Util.js?v=85:208
detected msdp:ROOM_MAPDrice&STR: 14 DEX: 17 CON: 13&INT: 14 WIS: 13 CHA: 10&REF: 19 FOR: 24 WIL: 17&&Attacks: (+10)&Damage: 2d8+6&& Util.js?v=85:208
detected msdp:GROUP1_NAMEDrice Util.js?v=85:208
detected msdp:GROUP1_CUR_HP76 Util.js?v=85:208
detected msdp:GROUP1_MAX_HP76 Util.js?v=85:208
detected msdp:GROUP1_CUR_MV1160 Util.js?v=85:208
detected msdp:GROUP1_MAX_MV1160 Util.js?v=85:208
detected msdp:GROUP1_TNL62 

However I am unsure what to do in the update section to turn that into viewable interface.

Thanks for your help man,

Gicker
Last edit: 15 Sep 2014 20:35 by GickerLDS. Reason: Sorry didn't realize there'[d be that wall of text, though I selected a sub-section of what was output.

Please Log in or Create an account to join the conversation.

More
15 Sep 2014 21:17 #4 by plamzi
Replied by plamzi on topic Handling MSDP
This is the first time working with MSDP for me as well, so I made a small change that will fire the 'msdp' event with all the values already separated out into an array. Should make everyone's life easier. Take a look now.

As for why nothing is showing up yet, look at the "init" method in Group Tab. Currently, it's set to dock it inside an existing Chatter Box. You can make it instead create a new Window and then put the ".list" div inside it.

Then start tinkering in "update" and collect all the info inside the "group" object. Currently, "draw" needs to have all the information inside "group" when it is called. This is by far the simplest way to do it, but if you don't know when everything is ready, you may have to make "draw" smart enough to handle incremental drawing, e. g. based on a person's name being set as the id of their panel.

If you're not sure what "group" has to look like and if "draw" doesn't provide enough of a hint, read the API on Group Tab or hit Bedlam with &debug=1 and you'll see it in your console log.

Please Log in or Create an account to join the conversation.

  • GickerLDS
  • GickerLDS's Avatar Topic Author
  • Offline
  • New Member
More
15 Sep 2014 23:03 #5 by GickerLDS
Replied by GickerLDS on topic Handling MSDP
Cool. I'm able to parse the msdp now, but I'm still having issues getting the group window to appear. Any tips? Thanks for all your help thus far.

Gicker

Please Log in or Create an account to join the conversation.

More
16 Sep 2014 00:22 #6 by plamzi
Replied by plamzi on topic Handling MSDP
Instead of:
var init = function() {
		o.id = Config.ChatterBox.tab({ name: 'group' });
		j(o.id).append('<div class="list" style="clear:both; min-height: 30px; height: 100%; position: relative"></div>');
	}

Try something like:
var init = function() {
		new Window({ id: 'group-window' });
		j('#group-window').append('<div class="list" style="clear:both; min-height: 30px; height: 100%; position: relative"></div>');
	}
The following user(s) said Thank You: GickerLDS

Please Log in or Create an account to join the conversation.

  • GickerLDS
  • GickerLDS's Avatar Topic Author
  • Offline
  • New Member
More
16 Sep 2014 00:24 #7 by GickerLDS
Replied by GickerLDS on topic Handling MSDP
Wow. That was easy :) Thanks man!

Please Log in or Create an account to join the conversation.

  • GickerLDS
  • GickerLDS's Avatar Topic Author
  • Offline
  • New Member
More
16 Sep 2014 00:53 #8 by GickerLDS
Replied by GickerLDS on topic Handling MSDP
Spoke too soon.

Here's my code if you want to take a look:
var groupOutput = function(o) {
 
 var GROUP1_NAME = "";
 var GROUP2_NAME = "";
 var GROUP3_NAME = "";
 var GROUP4_NAME = "";
 var GROUP5_NAME = "";
 
 var GROUP1_CUR_HP = "";
 var GROUP2_CUR_HP = "";
 var GROUP3_CUR_HP = "";
 var GROUP4_CUR_HP = "";
 var GROUP5_CUR_HP = "";
 
 var GROUP1_MAX_HP = "";
 var GROUP2_MAX_HP = "";
 var GROUP3_MAX_HP = "";
 var GROUP4_MAX_HP = "";
 var GROUP5_MAX_HP = "";
 
 var GROUP1_CUR_MV = "";
 var GROUP2_CUR_MV = "";
 var GROUP3_CUR_MV = "";
 var GROUP4_CUR_MV = "";
 var GROUP5_CUR_MV = "";
 
 var GROUP1_MAX_MV = "";
 var GROUP2_MAX_MV = "";
 var GROUP3_MAX_MV = "";
 var GROUP4_MAX_MV = "";
 var GROUP5_MAX_MV = "";
 
 var GROUP1_TNL = ""; 
 var GROUP2_TNL = ""; 
 var GROUP3_TNL = ""; 
 var GROUP4_TNL = ""; 
 var GROUP5_TNL = "";
 
 var update = function(d) {
    go[d[0]] = d[1];
    return d;
 };
 
 var alertVals = function() {
    alert("GROUP1_NAME = "+GROUP1_NAME);
 };
 
 return {
    update: update,
    alertVals: alertVals
 };
 
};

var d20Groups = function(o) {
    
  var init = function() {
     new Window({ id: 'group-window' });
     j('#group-window').append('<div class="list" style="width: 200px; min-width: 200px; min-height: 30px; height: 100%; position: relative;top: 0px;left: 0px">GROUP LIST</div>');
  };
  
  var draw = function() {
    //j('#group-window .list').html('<table width="100%" cellspacing="2"><tr><td>'+go["GROUP1_NAME"]+'</td><td>'+go["GROUP1_CUR_HP"]+'/'+go["GROUP1_MAX_HP"]+'HP</td><td>'+go["GROUP1_CUR_MV"]+'/'+go["GROUP1_MAX_MV"]+'Sp</td><td>'+go["GROUP1_TNL"]+'% To Next Level</td></tr></table>');
    j('#group-window .list').append('<div>testarama</div>');
  };
  
  var update = function(d) {
      /*log("Label: "+d[0]+" and Value: "+d[1]); */
      switch(d[0]) {
         case "GROUP1_NAME":
         case "GROUP2_NAME":
         case "GROUP3_NAME":
         case "GROUP4_NAME":
         case "GROUP5_NAME":
         
         case "GROUP1_CUR_HP":
         case "GROUP2_CUR_HP":
         case "GROUP3_CUR_HP":
         case "GROUP4_CUR_HP":
         case "GROUP5_CUR_HP":
         
         case "GROUP1_MAX_HP":
         case "GROUP2_MAX_HP":
         case "GROUP3_MAX_HP":
         case "GROUP4_MAX_HP":
         case "GROUP5_MAX_HP":
         
         case "GROUP1_CUR_MV":
         case "GROUP2_CUR_MV":
         case "GROUP3_CUR_MV":
         case "GROUP4_CUR_MV":
         case "GROUP5_CUR_MV":
         
         case "GROUP1_MAX_MV":
         case "GROUP2_MAX_MV":
         case "GROUP3_MAX_MV":
         case "GROUP4_MAX_MV":
         case "GROUP5_MAX_MV":
         
         case "GROUP1_TNL": 
         case "GROUP2_TNL": 
         case "GROUP3_TNL": 
         case "GROUP4_TNL": 
         case "GROUP5_TNL": 
           go[d[0]] = d[1];
           break;
        }
        /*alert(d[0]+" = "+d[1]);*/
        draw();
  };
  
  return {
    init: init,
	update: update
  };
};

var gt = new d20Groups({ id: '#group-tab' });
var go = new groupOutput({ id: '#group-output' });

Event.listen('msdp', gt.update);

Cheers man,

Gicker

Please Log in or Create an account to join the conversation.

More
16 Sep 2014 02:17 - 16 Sep 2014 02:19 #9 by plamzi
Replied by plamzi on topic Handling MSDP
You can start by examining the contents of the data you're receiving:
var groupOutput = function(o) {
console.log(o);
...
}

You'll notice that it always comes to you in an array. Key-value pairs will have the key in position 0 and the value in position 1, so:
var groupOutput = function(o) {
var myvars = {};
if (o.length == 2)
myvars[o[0]] = o[1];
console.log(myvars);
...
}

There is support for MSDP tables and arrays, but they will all come to you as flat (1D) arrays, with the necessary separators for you to do what you need. That's to save you from having to detect what type of object the incoming data is.

Dumping object values using console.log is the bread and butter of fast web development.
Last edit: 16 Sep 2014 02:19 by plamzi.

Please Log in or Create an account to join the conversation.