Discussion:
[Pipmak-Devel] new features in Pipmak
Aidan Gauland
2008-08-03 02:32:45 UTC
Permalink
Hello,

I have reached a point with my game where I can't think of a way to do what
I want with Pipmak's current capabilities.

1.
Problem: Running Lua code immediately after a certain sound stops playing.

Specific instance: In node 122, I want to make the a button pulse to a
heartbeat sound, which is started by moving the mouse over a hotspot, and then
started again when the sound stops playing. I could use Pipmak schedule, but
I'd have to hard-code the duration of the sound file, and, besides, that would
leave a little more room for accumulated time-sync errors.

Possible Solution: Giving sounds something like the onenternode handler for nodes.

2.
Problem: Restoring engine settings from variables in the state table (specific
to a particular Pipmak project file).

Specific instance: I have a settings node (121), but the settings don't
persist between sessions (i.e. they're lost when you save and resume a game).

Possible Solution: Adding a handler equivelant to onopenproject that is run
when opening a saved game.

Would anyone else find features like these useful? Could these be easily
implemented in Pipmak? Do we just have too much spare time on our hands? :)

-Aidan
Andrea Viarengo
2008-09-01 12:35:53 UTC
Permalink
Hi Aidan,

Running Lua code immediately after a certain sound stops playing.
I think that adding this possibility can be very useful!

It would be useful also if someone would to concatenate different sounds
(when finish one, then start another).
For example, some time ago I tried to add voice messages, and I didn't want
to record a sound for each message,
but I wanted to compose the message using a dictionary of words...(like
TomTom do....)
So the message "the door is closed" was composed by 4 sounds played in
sequence "the" "door" "is" "closed",
but this is difficult with actual pipmak sound APIs.

One possible implementation could be adding the method "onsoundstop"

mysound = sound "mysound.ogg"
mysound:onsoundstop (
function ()
....
end
)

Another implementation:

onsoundstop( function(sound)
if sound:getfilename() == "sound1.ogg" then ..... end
if sound:getfilename() == "sound2.ogg" then ..... end
end
)

offcourse adding also the method getfilename()
Post by Aidan Gauland
2.
Problem: Restoring engine settings from variables in the state table (specific
to a particular Pipmak project file).
I think that the simple way should be add the possibility to read/write text
file....I asked to add this to Pipmak some time ago,
but Christian have an hard position about that.....
Off course, if you really want, you can use lua loadlib function and write
a DLL or SO lib file to add file read/write API.
I have already writen a DLL to do this (sorry just for Windows....), if you
need it I can send you.


Bye,

Andrea
Aidan Gauland
2008-09-02 09:04:22 UTC
Permalink
Post by Andrea Viarengo
Hi Aidan,
Running Lua code immediately after a certain sound stops playing.
I think that adding this possibility can be very useful!
It would be useful also if someone would to concatenate different sounds
(when finish one, then start another).
For example, some time ago I tried to add voice messages, and I didn't
want to record a sound for each message,
but I wanted to compose the message using a dictionary of words...(like
TomTom do....)
So the message "the door is closed" was composed by 4 sounds played in
sequence "the" "door" "is" "closed",
but this is difficult with actual pipmak sound APIs.
One possible implementation could be adding the method "onsoundstop"
mysound = sound "mysound.ogg"
mysound:onsoundstop (
function ()
....
end
)
onsoundstop( function(sound)
if sound:getfilename() == "sound1.ogg" then ..... end
if sound:getfilename() == "sound2.ogg" then ..... end
end
)
offcourse adding also the method getfilename()
I like the first one. No idea where to start with putting this in Pipmak
though. It would probably be pretty simple once I get started.
Post by Andrea Viarengo
2.
Problem: Restoring engine settings from variables in the state table (specific
to a particular Pipmak project file).
I think that the simple way should be add the possibility to read/write
text file....I asked to add this to Pipmak some time ago,
but Christian have an hard position about that.....
Off course, if you really want, you can use lua loadlib function and
write a DLL or SO lib file to add file read/write API.
I have already writen a DLL to do this (sorry just for Windows....), if
you need it I can send you.
I don't need an IO API, I just need a way of triggering the execution of Lua
code when the user opens a saved game for that particular project file.
Post by Andrea Viarengo
Bye,
Andrea
Christian Walther
2008-10-05 10:29:08 UTC
Permalink
Post by Aidan Gauland
1.
Problem: Running Lua code immediately after a certain sound stops playing.
Specific instance: In node 122, I want to make the a button pulse to a
heartbeat sound, which is started by moving the mouse over a hotspot, and then
started again when the sound stops playing. I could use Pipmak schedule, but
I'd have to hard-code the duration of the sound file, and, besides, that would
leave a little more room for accumulated time-sync errors.
Possible Solution: Giving sounds something like the onenternode handler for nodes.
That sounds like a good idea. To implement it, however, it seems that
you'd have to poll OpenAL whether the sound is still playing, and you
could just as well do that directly from Lua (sound:playing() method).

How about adding a "duration" method to sounds, so that you could query
the duration and use pipmak.schedule? That should be trivial.

Neither of these approaches would be accurate enough for seamless
concatenation of sounds, due to Pipmak's synchronous frame-by-frame
design. For that, you'd have to queue the sound buffers into the same
OpenAL source, while currently every Pipmak sound has its own source (so
that sounds can play concurrently).
Post by Aidan Gauland
2.
Problem: Restoring engine settings from variables in the state table (specific
to a particular Pipmak project file).
Specific instance: I have a settings node (121), but the settings don't
persist between sessions (i.e. they're lost when you save and resume a game).
Possible Solution: Adding a handler equivelant to onopenproject that is run
when opening a saved game.
That should be easy to add, but can you elaborate a bit on how you'd use
it? I'm not convinced there's no bug involved or there isn't an easier
way of achieving your goal.

Engine settings should be restored automatically from saved game files
(if they aren't, that's a bug). For your own custom settings, how is
restoring them to the state table not sufficient, what exactly would you
need to do in that hypothetical "onloadsavedgame" handler?

-Christian
Aidan Gauland
2008-10-05 22:07:53 UTC
Permalink
Post by Christian Walther
How about adding a "duration" method to sounds, so that you could query
the duration and use pipmak.schedule? That should be trivial.
That should work just fine for what I want to do, since I don't need
*seamless* concatenation of sounds.
Post by Christian Walther
Neither of these approaches would be accurate enough for seamless
concatenation of sounds, due to Pipmak's synchronous frame-by-frame
design. For that, you'd have to queue the sound buffers into the same
OpenAL source, while currently every Pipmak sound has its own source (so
that sounds can play concurrently).
That should be easy to add, but can you elaborate a bit on how you'd use
it? I'm not convinced there's no bug involved or there isn't an easier
way of achieving your goal.
Engine settings should be restored automatically from saved game files
(if they aren't, that's a bug). For your own custom settings, how is
restoring them to the state table not sufficient, what exactly would you
need to do in that hypothetical "onloadsavedgame" handler?
Maybe I should explain it in a different way: parts of the engine state that
aren't game-specific (i.e. joystick speed, screen resolution, mouse mode,
etc.) don't get saved. So I was thinking of saving the user-specified values
for these variables in the state table, but then there's no way to
automatically change the engine state when a saved game is loaded.

So, basically, I just want a way to save the *entire* engine state in a saved
game file.
Christian Walther
2008-10-07 04:59:34 UTC
Permalink
Post by Aidan Gauland
Post by Christian Walther
How about adding a "duration" method to sounds, so that you could query
the duration and use pipmak.schedule? That should be trivial.
That should work just fine for what I want to do, since I don't need
*seamless* concatenation of sounds.
Good, I'll add that when I get around to it.
Post by Aidan Gauland
Maybe I should explain it in a different way: parts of the engine state that
aren't game-specific (i.e. joystick speed, screen resolution, mouse mode,
etc.) don't get saved.
That must be a bug. They're supposed to be saved. I'll see if I can
reproduce it.

-Christian
Christian Walther
2008-10-07 18:42:07 UTC
Permalink
Post by Christian Walther
How about adding a "duration" method to sounds, so that you could query
the duration and use pipmak.schedule?
This is in SVN as r204 (barely tested).
parts of the engine state ... don't get saved.
I'll see if I can reproduce it.
I can't - seems to work properly for me, in the case I tested. Could I
have a look at one of your saved game files (preferably one from the
demo project, if you can reproduce it there)? Here's one of mine to
test, it should set the video mode to fullscreen 1024x640, joystick
speed to 16, mouse mode to direct, and other settings as follows (this
is its deserialized form):

{
["overlays"] = {
[1] = 50
}
["path"] = "/Users/cwalther/Documents/Mac OS
X/Pipmak/trunk/demo/Demo.pipmak"
["el"] = -2.1995887756348
["fov"] = 45
["w"] = 1024
["az"] = 11.344421386719
["state"] = {
["lamp1on"] = false
["welcomed"] = true
["keyinhouse"] = true
["lamp2on"] = false
["doorisopen"] = false
["bridgepos"] = 0
["inventory"] = {
[1] = "note"
}
["lamp4on"] = false
["lamp3on"] = false
}
["h"] = 640
["title"] = "Pipmak Demo"
["joyspeed"] = 16
["full"] = true
["mouse"] = 1
["node"] = 2
["texfilter"] = 9729
}

-Christian
Aidan Gauland
2008-10-07 08:58:26 UTC
Permalink
Post by Christian Walther
Post by Aidan Gauland
Post by Christian Walther
How about adding a "duration" method to sounds, so that you could query
the duration and use pipmak.schedule? That should be trivial.
That should work just fine for what I want to do, since I don't need
*seamless* concatenation of sounds.
Good, I'll add that when I get around to it.
Post by Aidan Gauland
Maybe I should explain it in a different way: parts of the engine state that
aren't game-specific (i.e. joystick speed, screen resolution, mouse mode,
etc.) don't get saved.
That must be a bug. They're supposed to be saved. I'll see if I can
reproduce it.
Hmmmm, now I'm feeling REALLY stupid. I just realised that I've never tried
this! :-/ I hope I didn't make you waste any time.
Christian Walther
2008-10-12 08:58:39 UTC
Permalink
Post by Aidan Gauland
Hmmmm, now I'm feeling REALLY stupid. I just realised that I've never tried
this! :-/ I hope I didn't make you waste any time.
So it works for you too? All the better. No worries, I'll file this as a
success under "regression testing". ;)

-Christian

Loading...