Page 1 of 1
Spawner /light source questions
Posted: Thu Oct 11, 2012 5:49 pm
by SpiderFighter
I'm building a puzzle that uses pressure plates to turn on and off lights. I've noticed that there is no option to disable light sources, so I have the plate (working with only one so far for proof of concept) hooked up to a spawner which, in turn, spawns the light. Yet, I still can't figure out how to turn that light off (remove) again. Two questions: 1) Is it possible to remove a spawner in-game? 2)Hmmm...I'm assuming that, even if I could remove the spawner, the spawned entity would remain behind anyway, so I'm back to wondering if there's a way to remove the light again?
I'm sure I'm not seeing something incredibly simple. I'm blaming lack of sleep and too much Korean techno throughout the night (Yeah, I don't know why, either.

Re: Spawner /light source questions
Posted: Thu Oct 11, 2012 6:06 pm
by Grimwold
possibly it undocumented as it was added late on in editor development, but there is the command destroy()
so you would call something like
light_object_1:destroy()
Or
spawner_1:destroy()
if it's a spawned object then to find it's name you may need to use
for i in entitiesAt(lvl,x,y) do and when you find the light object do i:destroy()
a very quick example from the code I've just written
Code: Select all
function isValidTarget(L,X,Y)
spawn("spawner", L, X, Y, 0, "probe"):setSpawnedEntity("teleport_probe"):activate()
for j in entitiesAt(L,X,Y) do
if j.name == "teleport_probe"
then
-- hudPrint("probe here")
probe:destroy()
j:destroy()
return true
end
end
probe:destroy()
return false
end
Re: Spawner /light source questions
Posted: Thu Oct 11, 2012 6:47 pm
by Kuningas
I thought light sources could be turned on or off -- I have a vague memory of trying this at some point. I need to investigate.
Re: Spawner /light source questions
Posted: Thu Oct 11, 2012 7:34 pm
by Komag
their "lifespan" can be changed to something very short, and then they die of natural causes within, like 1/10 of a second.
Re: Spawner /light source questions
Posted: Thu Oct 11, 2012 9:29 pm
by SpiderFighter
Thanks for checking this out for me. Grim, great work. I wound up going a bit of a diferent route this time, but there will be three other puzzles involving light throughout the mod, so I will definitely be checking out your script. I didn't even know about the "destroy" command; very handy, that!
Komag and Kuningas, good to know. While the lifespan doesn't matter for the puzzle I'm working on, I can certainly use that to my advantage later on.
Thanks, guys! Please feel free to check out the mod...the light puzzle in question appears on level 4 (albeit in an extremely simple form. The version in my head will appear later on in the mod).
viewtopic.php?f=14&t=3638&p=37159#p37159
Re: Spawner /light source questions
Posted: Fri Oct 12, 2012 5:14 pm
by SpiderFighter
Gah. I've been playing with this for almost two hours, and I the best I can do is get it to do nothing (the worst is crashing, which I can also do). I need Remedial Scripting.
Thanks for the effort, guys. I'm sorry it was lost on me; also because it means my dungeons will never be as exciting as the ones in my head.
Re: Spawner /light source questions
Posted: Fri Oct 12, 2012 5:59 pm
by Kuningas
SpiderFighter wrote:Gah. I've been playing with this for almost two hours, and I the best I can do is get it to do nothing (the worst is crashing, which I can also do). I need Remedial Scripting.
Thanks for the effort, guys. I'm sorry it was lost on me; also because it means my dungeons will never be as exciting as the ones in my head.
Nononono, don't lose faith! I'mma take a look at the problem -- I did say I was going to investigate and then forgot about it. I'll be back in a jiffy.
Inspiring story: I worked about 5 hours on a "put three items on alcoves and a door opens" -script around wednesday. I finally pulled it off (thanks to Grimwold here, I can't thank him enough), and no I'm scripting door puzzles like a pro! (Well, maybe not a pro, but they feel relatively simple to me nowadays.)
UUHHhhh... I think I've got something wrong, because I just hooked pressure plates straight to light sources (temple ceiling lamps), and sure enough, there was an activate and deactivate option. Meaning, if I step on the pressure plate, the light goes on, and if I step off it goes out. Was this what you were trying, or have I understood something wrong? Because I am getting a feeling you meant something else, this is suspiciously easy (or it is just the simple answer we tend to miss easily)
Re: Spawner /light source questions
Posted: Fri Oct 12, 2012 6:10 pm
by SpiderFighter
Kuningas wrote:
Inspiring story: I worked about 5 hours on a "put three items on alcoves and a door opens" -script around wednesday. I finally pulled it off (thanks to Grimwold here, I can't thank him enough), and no I'm scripting door puzzles like a pro! (Well, maybe not a pro, but they feel relatively simple to me nowadays.)
UUHHhhh... I think I've got something wrong, because I just hooked pressure plates straight to light sources (temple ceiling lamps), and sure enough, there was an activate and deactivate option. Meaning, if I step on the pressure plate, the light goes on, and if I step off it goes out. Was this what you were trying, or have I understood something wrong? Because I am getting a feeling you meant something else, this is suspiciously easy (or it is just the simple answer we tend to miss easily)
Thanks for the inspiration. And for the boost.
As for the plate issue...lemme check it on my own map, and I'll be right back.
Ummmm..ok. I have NO idea what happened, but I'm swearing that I had no way of...oh hell, maybe it was lack of sleep. I honestly have no idea how I missed something so simple..I just plain didn't see the option; in fact, I'd swear it wasn't there. Odd.
Thanks for making me take another look (and for setting it up yourself!) I can't thank you enough.
Re: Spawner /light source questions
Posted: Fri Oct 12, 2012 6:42 pm
by Kuningas
SpiderFighter wrote:
Thanks for the inspiration. And for the boost.
As for the plate issue...lemme check it on my own map, and I'll be right back.
Ummmm..ok. I have NO idea what happened, but I'm swearing that I had no way of...oh hell, maybe it was lack of sleep. I honestly have no idea how I missed something so simple..I just plain didn't see the option; in fact, I'd swear it wasn't there. Odd.
Thanks for making me take another look (and for setting it up yourself!) I can't thank you enough.
No problem, I'm just happy I can (finally!) start giving back to the community even if it is little. : D I'm sure I'll still be asking questions a lot, though.
Re: Spawner /light source questions
Posted: Fri Oct 12, 2012 11:07 pm
by SpiderFighter
Now the sky is the limit. I still don't know how I missed that. Good thing I was only editing and not driving! In any case, I just finished a pretty cool "chasing lughts" sequence down a hallway...pretty eerie looking. For me, lighting is the key to setting a mood. Thanks again for making me look twice.
