×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Lua
Posted by: Quentin Gasparotto
Added: Jun 26, 2016 12:43 PM
Views: 5
Tags: lua
For taking or droping a ressource
  1.     local sight = IA:GetSightAt(0);
  2.  
  3.     for i=FOOD, THYSTAME do
  4.         local present = sight:GetNbOf(i);
  5.         local need = IA:GetNbNeededRessources(i);
  6.  
  7.         if (present > 0) then
  8.             if (need > 0) then
  9.                 if (need - present < 0) then
  10.                     return doAction(TAKE, Inventory.GetNameOf(i));
  11.                 elseif (need - present > 0) then
  12.                     return doAction(DROP, Inventory.GetNameOf(i));
  13.                 end
  14.             else
  15.                 return doAction(TAKE, Inventory.GetNameOf(i));
  16.             end
  17.         end
  18.     end
  19.