Skip to content
User Avatar
#1324
Auto-translated
thank you, it helped.

Added 7 minutes ago
well, and (I really hope) the last question for today:

Dear RedHeavenHero - here is a slightly modified version of your function for transforming human dwellings.
Basically, I would like all this magnificence to start working when a small and modest variable, let's call it 'dwel' in the script, is equal to a proud and rebellious one (dwel = 1). However, due to my slow thinking and complete lack of knowledge of these script functions, I cannot seem to control and subdue the rebellious loop with 'for' and so on. I am attaching the code of the current function and hope for your prompt help. =)
function starthut()
if dwel == 1 then
for i,hut in GetObjectNamesByType('PEASANT_HUT') do
SetObjectEnabled(hut, nil)
Trigger(4, hut, 'replace_hut')
end
end
end
startThread(starthut)

function replace_hut(hero, hut)
if hero == 'Berein' and dwel == 1 then
Trigger(4, hut, nil)
SetObjectEnabled(hut, 1)
ReplaceDwelling(hut, 4)
sleep (1)
MakeHeroInteractWithObject (hero , hut)
end
end

----------------------------------------

function starthut2()
if dwel == 1 then
for i,hut2 in GetObjectNamesByType('ARCHERS_HOUSE') do
SetObjectEnabled(hut2, nil)
Trigger(4, hut2, 'replace_hut2')
end
end
end
startThread(starthut2)

function replace_hut2(hero, hut2)
if hero == 'Berein' and dwel == 1 then
Trigger(4, hut2, nil)
SetObjectEnabled(hut2, 1)
ReplaceDwelling(hut2, 4)
sleep (1)
MakeHeroInteractWithObject (hero , hut2)
end
end

----------------------------------------

function starthut3()
if dwel == 1 then
for i,hut3 in GetObjectNamesByType('BARRACKS') do
SetObjectEnabled(hut3, nil)
Trigger(4, hut3, 'replace_hut3')
end
end
end
startThread(starthut3)

function replace_hut3( hero , hut3)
if hero == 'Berein' and dwel == 1 then
Trigger(4, hut3, nil)
SetObjectEnabled(hut3, 1)
ReplaceDwelling(hut3, 4)
sleep (1)
MakeHeroInteractWithObject (hero , hut3)
end
end
--------------------------------------

function starthut4()
if dwel == 1 then
for i,hut4 in GetObjectNamesByType('HEAVEN_MILITARY_POST') do
SetObjectEnabled(hut4, nil)
Trigger(4, hut4, 'replace_hut4')
end
end
end
startThread(starthut4)

function replace_hut4(hero, hut4)
if hero == 'Berein' and dwel == 1 then
Trigger(4, hut4, nil)
SetObjectEnabled(hut4, 1)
ReplaceDwelling(hut4, 4)
sleep (1)
MakeHeroInteractWithObject (hero , hut4)
end
end

Whatever

Statistics

Welcome our newest member: wayal