Grimfan wrote:Okay. I want to check if all the monsters in a level are dead so I can open a door. Will this work?
Code: Select all
for e in self.go.map:allEntities() do
if e.monster == 0 then
door_1.door:open()
This won't work for a couple reasons: first, "e.monster" cannot
possibly be 0, it will either be nil or a component. Presumably you wanted nil there instead of 0. Second, your logic is inverted: you have it opening the door if ANY entity on the level does not have a MonsterComponent. Also, it's entirely possible to have a MonsterComponent not named "monster", but this is probably not a concern. Here's the code you probably wanted:
Code: Select all
for e in self.go.map:allEntities() do
if e.monster then
return
end
end
door_1.door:open()
This iterates through all GameObjects on the map, and aborts if it finds one with a component named "monster". If none of the objects on the level have such a component, it will open the door.
Grimfan wrote:Hell all, I was wondering if there was a method to spawn a beacon holding it's particular element? I know that in LoG1 to make some assets act like an alcove it required a little dirty work, but since the beacons can already hold particular objects, I believe all that would be needed is to spawn it over the beacon and then do xy and z to get it to trigger properly; unfortunately, I'm more of an artistically driven person so figuring this out through lua scripting is akin to me driving into a brick wall. I'll appreciate any and all help that you all can give.
http://www.grimrock.net/modding/scripti ... tComponent
Just use:
Code: Select all
beacon_air_1.socket:addItem(spawn("essence_air").item)