Dungeon Editor Crashing 1/2 the time on script

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
zadkielmodeler
Posts: 43
Joined: Sat Sep 15, 2012 6:34 am

Re: Dungeon Editor Crashing 1/2 the time on script

Post by zadkielmodeler »

antti wrote:Is there a specific reason why do you want to use destroy instead of setDoorState for example?

Destroying entities should be, in general, your last resort because it is more prone for all sorts of problems where the game might try to do something with an entity that just (possibly even during the same frame) ceased to exist. Basically when destroying entities you need to make sure that nothing (connectors, scripts or anything else) refers to them anymore.

That's a very good thought. I will go with that.
zadkielmodeler
Posts: 43
Joined: Sat Sep 15, 2012 6:34 am

Re: Dungeon Editor Crashing 1/2 the time on script

Post by zadkielmodeler »

I just set them all to setDoorState and it is still crashing.

The function greed() is called when the party steps on a pressure plate, but here is a whole list of the code for the script entity.

Code: Select all

function greedy()


hudPrint("Mimsy Frowns on the Greedy.")
hudPrint("But you shall have more than you ever imagined.")

playSound("goromorg_shield_hit")
playSound("goromorg_shield_break")

prison_secret_door_38:setDoorState("open")
prison_secret_door_39:setDoorState("open")
prison_secret_door_40:setDoorState("open")
prison_secret_door_41:setDoorState("open")
prison_secret_door_42:setDoorState("open")

prison_secret_door_43:setDoorState("open")
prison_secret_door_44:setDoorState("open")
prison_secret_door_45:setDoorState("open")
prison_secret_door_48:setDoorState("open")
prison_secret_door_49:setDoorState("open")
prison_secret_door_50:setDoorState("open")
prison_secret_door_51:setDoorState("open")
prison_secret_door_52:setDoorState("open")



end


function destroyer()

pressure_plate_hidden_48:destroy()
pressure_plate_hidden_47:destroy()
pressure_plate_hidden_46:destroy()
pressure_plate_hidden_45:destroy()


end




function protectionspell()

party:getChampion(1):setCondition("fire_shield", math.huge)
party:getChampion(2):setCondition("fire_shield", math.huge)
party:getChampion(3):setCondition("fire_shield", math.huge)
party:getChampion(4):setCondition("fire_shield", math.huge)
playSound("heal_party")

end



for your reference, destroyer() is triggered by the pressure plates it destroys.
protectionspell() is triggered by a wall button.
User avatar
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: Dungeon Editor Crashing 1/2 the time on script

Post by Diarmuid »

Why are you destroying the pressure plates? To prevent them from activating again? Use Activate Once for all of them, and include a check in the function to prevent the others from triggering:

Code: Select all

greedyActivated = false

function greedy()

if greedyActivated == false then
greedyActivated = true
hudPrint("Mimsy Frowns on the Greedy.")
hudPrint("But you shall have more than you ever imagined.")

playSound("goromorg_shield_hit")
playSound("goromorg_shield_break")

prison_secret_door_38:setDoorState("open")
prison_secret_door_39:setDoorState("open")
prison_secret_door_40:setDoorState("open")
prison_secret_door_41:setDoorState("open")
prison_secret_door_42:setDoorState("open")

prison_secret_door_43:setDoorState("open")
prison_secret_door_44:setDoorState("open")
prison_secret_door_45:setDoorState("open")
prison_secret_door_48:setDoorState("open")
prison_secret_door_49:setDoorState("open")
prison_secret_door_50:setDoorState("open")
prison_secret_door_51:setDoorState("open")
prison_secret_door_52:setDoorState("open")


end
end


function destroyer()

pressure_plate_hidden_48:destroy()
pressure_plate_hidden_47:destroy()
pressure_plate_hidden_46:destroy()
pressure_plate_hidden_45:destroy()


end




function protectionspell()

party:getChampion(1):setCondition("fire_shield", math.huge)
party:getChampion(2):setCondition("fire_shield", math.huge)
party:getChampion(3):setCondition("fire_shield", math.huge)
party:getChampion(4):setCondition("fire_shield", math.huge)
playSound("heal_party")

end



User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Dungeon Editor Crashing 1/2 the time on script

Post by Komag »

destroying plates as you step on them is the culprit methinks. link to a very short timer (0.01s) which THEN destroys the plates, will work fine then
Finished Dungeons - complete mods to play
Post Reply