Difference between revisions of "Macros"
From LugdunonWiki
(Created page with "==Introduction== ==Set Lighting LOD (Level of Detail)== ==Consume Food==") |
|||
(6 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
+ | {{rewrite|Few examples and little practical information given}} | ||
+ | |||
+ | {{engine}} | ||
+ | |||
==Introduction== | ==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 [mailto://lugdunondev@gmail.com lugdunondev@gmail.com] for review and possible inclusion here, with credit to you! | ||
==Set Lighting LOD (Level of Detail)== | ==Set Lighting LOD (Level of Detail)== | ||
+ | |||
+ | 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== | ==Consume Food== | ||
+ | |||
+ | |||
+ | 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> | ||
+ | |||
+ | [[Category:Modding|Macros]] |
Latest revision as of 16:51, 15 February 2015
|
|
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
- )
- );
- }
- }