Macros

From LugdunonWiki
Revision as of 16:51, 15 February 2015 by SuperHawksman (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
It has been suggested that this page/section be rewritten.
Reason: "Few examples and little practical information given"
Engine Content: This information applies to the engine and therefore to all servers.

Introduction

This page showcases macros that you might wish to incorporate into your gameplay. If you have a macro that you would like to see added, send it in an email to lugdunondev@gmail.com for review and possible inclusion here, with credit to you!

Set Lighting LOD (Level of Detail)

This macro will cycle through 3 different light maps of differing quality:

  1. function(macro)
  2. {
  3.     var lod=game.getCurrentGameState().environment.getLOD()+1;
  4.    
  5.     if(lod > 3)
  6.     {
  7.         lod=1;
  8.     }
  9.        
  10.     game.getCurrentGameState().environment.setLOD(lod);
  11.    
  12.     game.console.log("Lighting LOD (Level of Detail) is now: "+lod);
  13. }

Consume Food

This macro will search your action bar and inventory for food, and attempt to consume the first food item it finds:

  1. function(macro)
  2. {
  3.     var p;
  4.     var i;
  5.     var ii;
  6.    
  7.     for(i=0;i<net.lugdunon.character.Character.ACTION_PLAY_SIZE;i++)
  8.     {
  9.         ii=game.player.getInventoryItem(
  10.             net.lugdunon.character.Character.ACTION_PLAY_BLOCK,
  11.             i
  12.         );
  13.        
  14.         if(ii && ii.itemDef && (ii.itemDef.getItemType() == "FOOD"))
  15.         {
  16.             p={
  17.                 blockType :net.lugdunon.character.Character.ACTION_PLAY_BLOCK,
  18.                 blockIndex:i
  19.             };
  20.             break;
  21.         }
  22.     }
  23.    
  24.     if(!p)
  25.     {
  26.         for(i=0;i<net.lugdunon.character.Character.INVENTORY_SIZE;i++)
  27.         {
  28.             ii=game.player.getInventoryItem(
  29.                 net.lugdunon.character.Character.INVENTORY_BLOCK,
  30.                 i
  31.             );
  32.            
  33.             if(ii && ii.itemDef && (ii.itemDef.getItemType() == "FOOD"))
  34.             {
  35.                 p={
  36.                     blockType :net.lugdunon.character.Character.INVENTORY_BLOCK,
  37.                     blockIndex:i
  38.                 };
  39.                 break;
  40.             }
  41.         }
  42.     }
  43.    
  44.     if(!p)
  45.     {
  46.         game.console.log("You have no food.","#F00");
  47.     }
  48.     else
  49.     {
  50.         game.client.sendCommand(
  51.             game.client.buildCommand(
  52.                 "CORE.COMMAND.CONSUME.FOOD",
  53.                 p
  54.             )
  55.         );
  56.     }
  57. }