run script upon save game load? FX lights issue, LightSource
Re: run script upon save game load? FX lights issue, LightSo
I have a question related to this one here. I'm using looping sound effects in my dungeon and I want them to stay (for example a fire with an appropriate sound effect). I can trigger the sounds with a hidden pressure plate, but reloading a save game removes them. Is there really no way to play a looping sound by simply placing it or tying it to a model for example? Either that or a reliable way to run a script function each time the player loads a game would be very helpful. Any suggestions? Anything I missed?
- SpiderFighter
- Posts: 789
- Joined: Thu Apr 12, 2012 4:15 pm
Re: run script upon save game load? FX lights issue, LightSo
Yep. My method, as well. Never had a problem after doing this.aaneton wrote:I figured out the light save problem by creating lights as objects.
Objects.lua
example red floor light:Now you can place (and spawn) light objects in editor, and of course destroy when needed to be off.Code: Select all
defineObject{ name = "red_floor_light", class = "LightSource", lightPosition = vec(0.5, 0.5, 0), lightRange = 6, lightColor = vec(1, 0, 0), brightness = 60, castShadow = true, placement = "floor", editorIcon = 88, }
Re: run script upon save game load? FX lights issue, LightSo
Maybe you can create a custom monster that is invisible and blind and invulnerable and stick him in the wall or something and make his idle sound be the sound you wantPhitt wrote:I have a question related to this one here. I'm using looping sound effects in my dungeon and I want them to stay (for example a fire with an appropriate sound effect). I can trigger the sounds with a hidden pressure plate, but reloading a save game removes them. Is there really no way to play a looping sound by simply placing it or tying it to a model for example? Either that or a reliable way to run a script function each time the player loads a game would be very helpful. Any suggestions? Anything I missed?
Finished Dungeons - complete mods to play
Re: run script upon save game load? FX lights issue, LightSo
Hmm...that's quite the effort for something as simple as a sound effect and the sound would come from the monster in the wall, not from the source in game. Plus it would noticeably hurt performance as I would like to add ~20-30 looping sounds to one level (hope they really stop playing and are not only muted after the player leaves their max distance, otherwise I'll face other problems...). Thanks for the suggestion though, any other ideas?Komag wrote:Maybe you can create a custom monster that is invisible and blind and invulnerable and stick him in the wall or something and make his idle sound be the sound you wantPhitt wrote:I have a question related to this one here. I'm using looping sound effects in my dungeon and I want them to stay (for example a fire with an appropriate sound effect). I can trigger the sounds with a hidden pressure plate, but reloading a save game removes them. Is there really no way to play a looping sound by simply placing it or tying it to a model for example? Either that or a reliable way to run a script function each time the player loads a game would be very helpful. Any suggestions? Anything I missed?
Wish there was an onLoad function and also wish you could simply place sounds just like any other object.
Re: run script upon save game load? FX lights issue, LightSo
What about the Grimrock quantum blue lighted teleportation ? Just kidding, but to explain in an easy but less accurate way : Effects that are temporary cannot be saved. because it's complicated.HaunterV wrote:That sounds like witch talk to me. Keep the quantum mechanics or star trek teleportation pattern talk out of grimrock!petri wrote:FX objects are meant to be used for short unimportant effects that need not persist across save games (persisting the state of particle effects would make the save game system much more complex because each individual particle would need to be saved).
The Lurker
Re: run script upon save game load? FX lights issue, LightSo
What about an effect like the torch ? I don't know if it's hard scripted or not but a wall torch play a looping sound.Phitt wrote:Hmm...that's quite the effort for something as simple as a sound effect and the sound would come from the monster in the wall, not from the source in game. Plus it would noticeably hurt performance as I would like to add ~20-30 looping sounds to one level (hope they really stop playing and are not only muted after the player leaves their max distance, otherwise I'll face other problems...). Thanks for the suggestion though, any other ideas?Komag wrote:Maybe you can create a custom monster that is invisible and blind and invulnerable and stick him in the wall or something and make his idle sound be the sound you wantPhitt wrote:I have a question related to this one here. I'm using looping sound effects in my dungeon and I want them to stay (for example a fire with an appropriate sound effect). I can trigger the sounds with a hidden pressure plate, but reloading a save game removes them. Is there really no way to play a looping sound by simply placing it or tying it to a model for example? Either that or a reliable way to run a script function each time the player loads a game would be very helpful. Any suggestions? Anything I missed?
Wish there was an onLoad function and also wish you could simply place sounds just like any other object.
The Lurker
Re: run script upon save game load? FX lights issue, LightSo
Couldn't find anything useful in the torch item or torch holder object definitions, seems like the sound is hardcoded. Same for the healing crystal or teleporter btw.J. Trudel wrote: What about an effect like the torch ? I don't know if it's hard scripted or not but a wall torch play a looping sound.
Re: run script upon save game load? FX lights issue, LightSo
Maybe a ticking script that checks for the presence of an FX light you created (since they die with reloads), such as
findEntity("checkThisFX")
you would need to create the FX light, perhaps at dungeon start. You could do it in a script like this
Then you have a different script running to make sure that light still exists (because if it doesn't, that means there has been a reload), something like this:
except of course you would replace the prints with whatever you want to do. In the case of the light still being there, you probably don't want to do anything, so you would actually just have the script like this:
You then set up a Timer with something like 1 or 2 seconds and have it constantly tick forever and ever, always running lookForFX() function. If you set the timer too low, like 0.1 seconds, it will tax the system. Too high, like 5 seconds, and the player could reload and be walking around for a few seconds before your script turns back on the sounds.
findEntity("checkThisFX")
you would need to create the FX light, perhaps at dungeon start. You could do it in a script like this
Code: Select all
function makeCheckFX()
local makeFX = spawn("fx", party.level, party.x, party.y, 0, "checkThisFX")
makeFX:setLight(1, 0, 0, 1, 1, 6000000, false)
end
makeCheckFX()
Code: Select all
function lookForFX()
if findEntity("checkThisFX") == "nil" then
print("the little light is GONE! There must have been a reload")
else
print("the little light is still there")
end
end
Code: Select all
function lookForFX()
if findEntity("checkThisFX") == "nil" then
doStuff blah blah blah (turn back on sounds you want)
end
end
Finished Dungeons - complete mods to play
Re: run script upon save game load? FX lights issue, LightSo
I agree, both these things are needed for many reasons.Phitt wrote:Wish there was an onLoad function and also wish you could simply place sounds just like any other object.
Re: run script upon save game load? FX lights issue, LightSo
Nice idea, unfortunately the entity still exists on reload. Tried with a particle system instead of a light, no luck. Here is the code I use, but I'm pretty sure it's not the fault of the code as it returns 'ok' so it creates and finds the entity...but also after reload, even after exiting the game and reloading. Setup is a pressure plate at the beginning of level 4 (set to activate once) which triggers makeDummyFX, lev4sounds and a timer with a 1 second interval which constantly triggers lookForFX.Komag wrote:Maybe a ticking script that checks for the presence of an FX light you created [...]
Code: Select all
function makeDummyFX()
local makeFX = spawn("fx", party.level, party.x, party.y, 0, "FXDummy")
makeFX:setParticleSystem("earthquake_dust")
end
function lookForFX()
if findEntity("FXDummy") == "nil" then
makeDummyFX()
lev4sounds()
print("reload")
else
print("ok")
end
end
function lev4sounds()
playSoundAt("mine_volcano_fire",4,23,21)
end