Thread: Manual Questions
Status: Alpha
Brought to you by:
cwalther
From: chikitin <cs...@gm...> - 2009-04-03 15:49:26
|
Hi, I have a few questions regarding the manual. 1. In the pipmak demo I want pipmak to show a text reaching the end of game in the middle of screen, say "Congratulations, you can now advance to level 2." I am on windows. Should I use image:drawtext to do this? if so how? or I should use it as slide? In other words, creating an image file showing/displaying the text, "congratulations" and then having pipmak display that in particular even. I appreciate it if you could give me some insight in the method as well. 2. node:getcurrentnode() returns the number of the current background node. Is there any command that returns the the number of the last visited node? 3. I am going to use print.pipmak for debugghing. The following code give me an error: local junk=1 // also without local, ie, global print.pipmak( "junk is " , junk) it gives me the following error: attemp to index global "print' ( a function value) what am I doing wrong? 4. I use the pipmak.gotnode() to go to a particular node. How can I ask pipmak to say go to node 99 after 10 seconds? The following doesn't work: pipmak.gotonode(99,10) Thanks in advance, cs -- View this message in context: http://www.nabble.com/Manual-Questions-tp22871180p22871180.html Sent from the pipmak-users mailing list archive at Nabble.com. |
From: Christian W. <cwa...@gm...> - 2009-04-03 19:00:43
|
> 1. In the pipmak demo I want pipmak to show a text reaching the end > of game > in the middle of screen, say > > > "Congratulations, you can now advance to level 2." > > > I am on windows. Should I use image:drawtext to do this? if so how? > > or I should use it as slide? In other words, creating an image file > showing/displaying the text, "congratulations" and then having pipmak > display that in particular even. You can do either (or even both at the same time). It depends on what exactly you want to do, there are a lot of combinations. If you want to display the "congratulations" box on a screen of its own, you can make it a separate slide. If you want to display it on top of a panorama, make it a slide with transparency (scaled to fit the screen) or a panel (kept at screen resolution) and display it as an overlay. If you want to display it on top of one particular slide, you can make it a patch on that slide node. If you are satisfied with Pipmak's text rendering and don't need any fancy effects on the text, or want to be able to change the text easily, you can use image:drawtext. Otherwise, you draw the text yourself in a graphics program and incorporate the result as an image. Here's a working example of a slide with a background picture and a patch containing drawn text (using a built-in image and font for demonstration, you will want to use your own image and perhaps your own font): -------- slide "../resources/missing.png" patch { x = 0, y = 50, image = pipmak.newimage(128, 20):color(1, .5, 0):drawtext(64, 0, "congratulations", "../resources/Vera.ttf", 16, pipmak.center) } -------- You could also draw the text directly on the background image: -------- local img = pipmak.newimage("../resources/missing.png") img:color(1, .5, 0):drawtext(64, 50, "congratulations", "../resources/ Vera.ttf", 16, pipmak.center) slide (img) -------- Or even create the whole background image programmatically: -------- slide (pipmak.newimage(640, 480):color(1, .8, .5):fill(150, 200, 340, 80):color(.4, .2, 0):drawtext(320, 210, "congratulations", "../ resources/VeraBd.ttf", 24, pipmak.center)) -------- Does that help? I admit that this is all a bit complicated and low- level, that's why Andrea has created a more user-friendly text display system on top of it that will be integrated into the next version of Pipmak: http://thread.gmane.org/gmane.games.devel.pipmak.user/454 > 2. node:getcurrentnode() returns the number of the current > background node. > Is there any command that returns the the number of the last visited > node? No. You need to keep track of that yourself if you need it, by adding an onenternode handler to every node that takes the node number and appends it to some list in the state table, or something. You could put that into its own file and include it in all the nodes using pipmak.dofile() to avoid duplication. > 3. I am going to use print.pipmak for debugghing. The following code > give me > an error: > > > local junk=1 // also without local, ie, global > > print.pipmak( "junk is " , junk) > > it gives me the following error: attemp to index global "print' ( a > function > value) > > > what am I doing wrong? What you want is "pipmak.print", not "print.pipmak". The function that's stored under the name "print" in the table "pipmak". What you're trying here is to get the entry named "pipmak" in the global variable "print", which doesn't work because "print" is not a table but a function (one that prints to standard output, which is of limited use in Pipmak). > 4. I use the pipmak.gotnode() to go to a particular node. How can I > ask > pipmak to say go to node 99 after 10 seconds? The following doesn't > work: > > pipmak.gotonode(99,10) pipmak.schedule(10, function() pipmak.gotonode(99) end) > -Christian |
From: chikitin <cs...@gm...> - 2009-04-04 00:53:51
|
Thanks much for the answers. Unforntunatly it seems none of the methods that you describe for for me. I want pipmak as soon as leaves a specific node, show the small fram in the middle of the page and start over the game. well, I supposed something like this work: img = pipmak.newimage("congratulations.jpg") // picture file is in the node folder onleavenode( function slide(img) end ) but this gives me an error:attemp to call global slide ( a nil value). thanks in advance, cs Christian Walther wrote: > >> 1. In the pipmak demo I want pipmak to show a text reaching the end >> of game >> in the middle of screen, say >> >> >> "Congratulations, you can now advance to level 2." >> >> >> I am on windows. Should I use image:drawtext to do this? if so how? >> >> or I should use it as slide? In other words, creating an image file >> showing/displaying the text, "congratulations" and then having pipmak >> display that in particular even. > > You can do either (or even both at the same time). It depends on what > exactly you want to do, there are a lot of combinations. > > If you want to display the "congratulations" box on a screen of its > own, you can make it a separate slide. If you want to display it on > top of a panorama, make it a slide with transparency (scaled to fit > the screen) or a panel (kept at screen resolution) and display it as > an overlay. If you want to display it on top of one particular slide, > you can make it a patch on that slide node. > > If you are satisfied with Pipmak's text rendering and don't need any > fancy effects on the text, or want to be able to change the text > easily, you can use image:drawtext. Otherwise, you draw the text > yourself in a graphics program and incorporate the result as an image. > > Here's a working example of a slide with a background picture and a > patch containing drawn text (using a built-in image and font for > demonstration, you will want to use your own image and perhaps your > own font): > > -------- > slide "../resources/missing.png" > > patch { > x = 0, y = 50, > image = pipmak.newimage(128, 20):color(1, .5, 0):drawtext(64, 0, > "congratulations", "../resources/Vera.ttf", 16, pipmak.center) > } > -------- > > You could also draw the text directly on the background image: > > -------- > local img = pipmak.newimage("../resources/missing.png") > > img:color(1, .5, 0):drawtext(64, 50, "congratulations", "../resources/ > Vera.ttf", 16, pipmak.center) > > slide (img) > -------- > > Or even create the whole background image programmatically: > > -------- > slide (pipmak.newimage(640, 480):color(1, .8, .5):fill(150, 200, 340, > 80):color(.4, .2, 0):drawtext(320, 210, "congratulations", "../ > resources/VeraBd.ttf", 24, pipmak.center)) > -------- > > Does that help? I admit that this is all a bit complicated and low- > level, that's why Andrea has created a more user-friendly text display > system on top of it that will be integrated into the next version of > Pipmak: http://thread.gmane.org/gmane.games.devel.pipmak.user/454 > > >> 2. node:getcurrentnode() returns the number of the current >> background node. >> Is there any command that returns the the number of the last visited >> node? > > No. You need to keep track of that yourself if you need it, by adding > an onenternode handler to every node that takes the node number and > appends it to some list in the state table, or something. You could > put that into its own file and include it in all the nodes using > pipmak.dofile() to avoid duplication. > > >> 3. I am going to use print.pipmak for debugghing. The following code >> give me >> an error: >> >> >> local junk=1 // also without local, ie, global >> >> print.pipmak( "junk is " , junk) >> >> it gives me the following error: attemp to index global "print' ( a >> function >> value) >> >> >> what am I doing wrong? > > What you want is "pipmak.print", not "print.pipmak". The function > that's stored under the name "print" in the table "pipmak". What > you're trying here is to get the entry named "pipmak" in the global > variable "print", which doesn't work because "print" is not a table > but a function (one that prints to standard output, which is of > limited use in Pipmak). > > >> 4. I use the pipmak.gotnode() to go to a particular node. How can I >> ask >> pipmak to say go to node 99 after 10 seconds? The following doesn't >> work: >> >> pipmak.gotonode(99,10) > > pipmak.schedule(10, function() pipmak.gotonode(99) end) >> > > > -Christian > > ------------------------------------------------------------------------------ > _______________________________________________ > Pipmak-Users mailing list > Pip...@li... > news://news.gmane.org/gmane.games.devel.pipmak.user > https://lists.sourceforge.net/lists/listinfo/pipmak-users > > -- View this message in context: http://www.nabble.com/Manual-Questions-tp22871180p22878816.html Sent from the pipmak-users mailing list archive at Nabble.com. |
From: Christian W. <cwa...@gm...> - 2009-04-04 12:40:37
|
> I want pipmak as soon as leaves a specific node, show the small fram > in the > middle of the page and start over the game. well, I supposed > something like > this work: > > img = pipmak.newimage("congratulations.jpg") // picture file is in > the node > folder > > onleavenode( > function > > slide(img) > > end > ) > > but this gives me an error:attemp to call global slide ( a nil value). "slide" is not a function that you can call at any time to create a slide node out of thin air. It is only used at the top level of a node.lua file to describe that particular node, and is only defined at the time the node.lua file is read. It is technically a function but you shouldn't think of it as one, rather as a statement in a declarative node description language. (I know that statements like the 'local img = something; slide (img)' I proposed blur that notion, that's why I consider them inelegant and confusing. The slide statement is really intended to be used only as 'slide "imagename"' or 'slide {"imagename", more stuff}'.) I'm a bit confused by your desire to display a third node when the player moves from one node to another (rather than at some other time determined by your game code). Do you want the move to be canceled and the popup displayed above the old node, or should it be displayed on top of the new node? (Are there several possibilities of what the new node can be? If there's only one, it would seem more natural to me to do this in the code that triggers the leaving than in the onleavenode handler. Or in the new node on entering.) Here's how displaying it on top of the new node should work: onleavenode( function() pipmak.overlaynode(123) -- node 123 is your popup end ) -Christian |
From: Christian W. <cwa...@gm...> - 2009-04-04 12:46:48
|
Christian Walther wrote: >> but this gives me an error:attemp to call global slide ( a nil >> value). > > "slide" is not a function that you can call at any time to create a > slide node out of thin air. PS: It occurs to me - perhaps I wasn't clear enough about this: The code examples I gave in yesterday's message (those between --------) were complete node.lua files, not code snippets that you paste at some point into the code of another node. -Christian |
From: chikitin <cs...@gm...> - 2009-04-07 21:44:50
|
Thanks very much Christian. cs -- View this message in context: http://www.nabble.com/Manual-Questions-tp22871180p22938957.html Sent from the pipmak-users mailing list archive at Nabble.com. |