Sorry that I did not get back to you sooner, i was busy. I'll try to take a look at these lua functions using my tests and see what i find and report back.
UPDATE:
Ok, Titi had changed the method for toggling hunger to use a different name. It seems like using invalid (unknown) functions in the LUA script causes the script to STOP processing once it hits a function that is unknown. Anyways the function word 'hunger' was changed to consume. Here is the updated scenario:
<?xml version="1.0" standalone="yes" ?>
<scenario>
<difficulty value="3"/>
<players>
<player control="human" faction="tech" team="1"/>
<player control="cpu" faction="tech" team="1"/>
<player control="cpu" faction="tech" team="1"/>
<player control="cpu" faction="tech" team="1"/>
</players>
<map value="in_the_forest"/>
<tileset value="forest"/>
<tech-tree value="megapack"/>
<default-resources value="false"/>
<default-units value="false"/>
<default-victory-conditions value="true"/>
<scripts>
<startup>
print( 'Test, START of Storming Test' )
--disable AI
disableAi(1)
disableAi(2)
disableAi(3)
disableConsume(0)
print( 'Test - A1' )
unitA = 'guard'
unitB = 'castle'
captureTheFlagSeconds = 15
print( 'Test - A2' )
DisplayFormattedText('You have %s seconds to move the %s into the %s!', captureTheFlagSeconds,unitA, unitB)
print( 'Test - B' )
for i=0, 3 do
print( 'Is AI enabled for faction index: ' .. i .. ', ' .. tostring( getAiEnabled(i)) )
print( 'Is hunger enabled for faction index: ' .. i .. ', ' .. tostring( getConsumeEnabled(i)) )
end
print( 'Test - C' )
startPerformanceTimer()
print( 'Test - D' )
--allied units
--createUnit('farm', 0, startLocation(2))
createUnit(unitB, 1, startLocation(2))
castleUnit= lastCreatedUnit()
createUnit('worker', 1, startLocation(2))
print( 'Test - E' )
for i=1, 5 do
createUnit('swordman', 1, startLocation(2))
end
print( 'Test - F' )
giveResource('gold', 0, 1000);
giveResource('wood', 0, 1000);
giveResource('food', 0, 1000);
giveResource('food', 1, 5);
--player units
createUnit('battle_machine', 0, startLocation(2))
battle_machine= lastCreatedUnit()
createUnit(unitA, 0, startLocation(2))
guard= lastCreatedUnit()
for i=1, 3 do
createUnit('archer', 0, startLocation(2))
test = lastCreatedUnit()
giveAttackCommand(test, castleUnit)
end
for i=1, 10 do
createUnit('swordman', 0, startLocation(1))
givePositionCommand(lastCreatedUnit(), 'attack', startLocation(1))
end
cell_event1 = registerCellTriggerEventForUnitToUnit(guard,castleUnit)
print( 'cell_event1 = ' .. cell_event1 )
cell_event2 = registerCellTriggerEventForUnitToUnit(battle_machine,castleUnit)
print( 'cell_event2 = ' .. cell_event2 )
timer_event1 = startTimerEvent()
print( 'timer_event1 = ' .. timer_event1 )
</startup>
<unitCreated>
</unitCreated>
<unitDied>
enableHunger(0)
enableAi(1)
for i=0, 3 do
print( 'Is AI enabled for faction index: ' .. i .. ', ' .. tostring( getAiEnabled(i)) )
print( 'Is hunger enabled for faction index: ' .. i .. ', ' .. tostring( getHungerEnabled(i)) )
end
endPerformanceTimer()
clearDisplayText()
setDisplayText(string.format('Performance, updateFPS: %d, RenderFPS: %d', getPerformanceTimerResults()[1],getPerformanceTimerResults()[2]))
</unitDied>
<cellTriggerEvent>
--print('Cell Event ' .. triggeredCellEventId() )
print( 'In cell event triggeredCellEventId = ' .. triggeredCellEventId() .. ' cell_event1 = ' .. cell_event1 .. ' cell_event2 = ' .. cell_event2 )
if triggeredCellEventId() == cell_event1 or triggeredCellEventId() == cell_event2 then
clearDisplayText()
DisplayFormattedText('You captured the FLAG!')
stopTimerEvent(timer_event1)
unregisterCellTriggerEvent(cell_event1)
unregisterCellTriggerEvent(cell_event2)
end
</cellTriggerEvent>
<timerTriggerEvent>
--print('Timer Event ' .. triggeredTimerEventId() )
--print( 'In timer event triggeredTimerEventId = ' .. triggeredTimerEventId() .. ' timer_event1 = ' .. timer_event1 )
if triggeredTimerEventId() == timer_event1 then
if timerEventSecondsElapsed(triggeredTimerEventId()) >= captureTheFlagSeconds then
print( 'In timer event triggeredTimerEventId = ' .. triggeredTimerEventId() .. ' timer_event1 = ' .. timer_event1 .. ' seconds elapsed = ' .. timerEventSecondsElapsed(triggeredTimerEventId()) )
clearDisplayText()
DisplayFormattedText('Your time ran out of time to capture the FLAG!')
stopTimerEvent(timer_event1)
unregisterCellTriggerEvent(cell_event1)
unregisterCellTriggerEvent(cell_event2)
end
end
</timerTriggerEvent>
</scripts>
</scenario>