En:OnUnitActionWithItem
Материал из Pocket Fallout для КПК на PDA PC PPC Mobile.
Содержание |
[править]
Syntax
function OnUnitActionWithItem(unit_name : String, item_name : String) : Boolean
[править]
Description
Called when unit with name <unit_name> does action with item with name <item_name> from inventory.
[править]
Parameters
[править]
Result
The function returns :
- true - action can be done;
- false - action can't be done.
Data type - Boolean
[править]
Example
function OnUnitActionWithItem(unit_name, item_name)
var bot = CreateObject("MapObject");
var hero = CreateObject("MapObject");
bot.GetObjectByName(unit_name);
hero.GetObjectByName("hero");
if (item_name == "apple") Then // If unit eats apple
// Add by current health 10 (ten) lives
var old_health = bot.GetUnitParam(UnitParam.Health);
bot.SetUnitParam(UnitParam.Health, old_health + 10);
hero.DeleteItemFromInventory(item_name);
if (unit_name == "hero") Then
// This message by index from messages.txt file
AddStringMessageByIndex(1000);
endif
endif
hero.Free();
bot.Free();
return true;
endfunction
[править]