Bug in Defense of Plainswood

I run this code on Lua and it passes. I build only one fence several times and ogre coming from bottom entrance do not kill any villagers. Maybe it’s not bug but “feature”:

    self:moveXY(40, 48)
    self:buildXY("fence", 40,52)

In case if i just build only one fence without loop bottom ogre kills all villages.
Even this case pass test:

for i=0,1 do
    self:moveXY(40, 48)
    self:buildXY("fence", 40,52)

Javascript code breaks too:

 //if use i < 1 it works properly
 for (var i=0; i < 2; ++i) { 
    this.buildXY("fence", 40,52);

You need to have the command somewhere in your code to build the second fence at the second location. Your current code only builds multiple fences at x=40, y=52. Loops aren’t even needed on this level, as long as you build both fences. Really all you need to do is issue 2 commands, one for each fence you build. Good luck, message me if you need future help!

I know but i do not understand why that bug can happen - if i build only one fence twice mission still completes even if ogre coming from bottom entrance enter village he does not attack anybody(Mission always complete after 101 frame). I guess that should not happen and that’s some strange bug. If i build fence only once i lose because he kills some villagers

1 Like