Difference between revisions of "Macros"

From LugdunonWiki
Jump to: navigation, search
(Set Lighting LOD (Level of Detail))
 
(4 intermediate revisions by one user not shown)
Line 1: Line 1:
 +
{{rewrite|Few examples and little practical information given}}
 +
 +
{{engine}}
 +
 
==Introduction==
 
==Introduction==
  
Line 7: Line 11:
  
  
 +
This macro will cycle through 3 different light maps of differing quality:
  
 +
<syntaxhighlight lang="javascript" line start="100" highlight="5" enclose="div">
 +
function(macro)
 +
{
 +
    var lod=game.getCurrentGameState().environment.getLOD()+1;
 +
   
 +
    if(lod > 3)
 +
    {
 +
        lod=1;
 +
    }
 +
       
 +
    game.getCurrentGameState().environment.setLOD(lod);
 +
   
 +
    game.console.log("Lighting LOD (Level of Detail) is now: "+lod);
 +
}
 +
</syntaxhighlight>
  
 +
==Consume Food==
  
<syntaxhighlight lang="javascript" line start="100" highlight="5" enclose="div">
 
  
 +
This macro will search your action bar and inventory for food, and attempt to consume the first food item it finds:
 +
 +
<syntaxhighlight lang="javascript" line start="100" highlight="5" enclose="div">
 +
function(macro)
 +
{
 +
    var p;
 +
    var i;
 +
    var ii;
 +
   
 +
    for(i=0;i<net.lugdunon.character.Character.ACTION_PLAY_SIZE;i++)
 +
    {
 +
        ii=game.player.getInventoryItem(
 +
            net.lugdunon.character.Character.ACTION_PLAY_BLOCK,
 +
            i
 +
        );
 +
       
 +
        if(ii && ii.itemDef && (ii.itemDef.getItemType() == "FOOD"))
 +
        {
 +
            p={
 +
                blockType :net.lugdunon.character.Character.ACTION_PLAY_BLOCK,
 +
                blockIndex:i
 +
            };
 +
            break;
 +
        }
 +
    }
 +
   
 +
    if(!p)
 +
    {
 +
        for(i=0;i<net.lugdunon.character.Character.INVENTORY_SIZE;i++)
 +
        {
 +
            ii=game.player.getInventoryItem(
 +
                net.lugdunon.character.Character.INVENTORY_BLOCK,
 +
                i
 +
            );
 +
           
 +
            if(ii && ii.itemDef && (ii.itemDef.getItemType() == "FOOD"))
 +
            {
 +
                p={
 +
                    blockType :net.lugdunon.character.Character.INVENTORY_BLOCK,
 +
                    blockIndex:i
 +
                };
 +
                break;
 +
            }
 +
        }
 +
    }
 +
   
 +
    if(!p)
 +
    {
 +
        game.console.log("You have no food.","#F00");
 +
    }
 +
    else
 +
    {
 +
        game.client.sendCommand(
 +
            game.client.buildCommand(
 +
                "CORE.COMMAND.CONSUME.FOOD",
 +
                p
 +
            )
 +
        );
 +
    }
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==Consume Food==
+
[[Category:Modding|Macros]]

Latest revision as of 16:51, 15 February 2015

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. }