lua:scripting:examples:findtargets
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
lua:scripting:examples:findtargets [2024/07/04 21:32] – created astark | lua:scripting:examples:findtargets [2024/07/04 21:36] (current) – astark | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Targeting Characters ====== | ||
+ | |||
+ | This function will loop through players in the room and look for a non-cleric/ | ||
+ | |||
<code lua> | <code lua> | ||
function getTargets() | function getTargets() | ||
Line 25: | Line 29: | ||
end | end | ||
end | end | ||
+ | |||
</ | </ | ||
+ | |||
+ | ====== Using the targets ====== | ||
+ | |||
+ | FIrst we call the ' | ||
+ | |||
+ | <code lua> | ||
+ | getTargets() | ||
+ | |||
+ | if target then | ||
+ | targetHp = target.hp / target.maxhp * 100 | ||
+ | end | ||
+ | |||
+ | if healer then | ||
+ | healerHp = healer.hp / healer.maxhp * 100 | ||
+ | end | ||
+ | |||
+ | -- Re-target in case of rescue | ||
+ | if rand(20) and not(target == nil) then | ||
+ | mdo(" | ||
+ | end | ||
+ | |||
+ | if targetHp <20 or healerHp <20 then | ||
+ | mdo(" | ||
+ | mdo(" | ||
+ | lag = lag + 2 | ||
+ | return | ||
+ | elseif targetHp <90 then | ||
+ | mdo(" | ||
+ | end | ||
+ | |||
+ | </ | ||
+ | |||
lua/scripting/examples/findtargets.1720128728.txt.gz · Last modified: 2024/07/04 21:32 by astark