Difference between revisions of "Macros"
From LugdunonWiki
(→Set Lighting LOD (Level of Detail)) |
(→Consume Food) |
||
Line 29: | Line 29: | ||
− | + | 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"> | <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> |
Revision as of 18:38, 13 October 2013
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:
- 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);
- }
Consume Food
This macro will search your action bar and inventory for food, and attempt to consume the first food item it finds:
- 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
- )
- );
- }
- }