A Pipmak project consists of a number of folders called nodes, which typically contain a series of image files, such as JPEGs or PNGs, which form the background of the node. There is also an image which looks like several colored blotches. This is the hotspot map, usually a PNG file. Finally, there is also a Lua file called node.lua. These node folders are simply named with a number. If you examine each of the nodes in demo.pipmak you will get a clearer idea of how this works. There are many ways you can make the images necessary for a Pipmak project, including using a 3D modelling and rendering program.
The 3D program Bryce is ideal for starting off making Pipmak games. Within a short space of time you can build up a simple scene which has the mood of a Myst game. There are plenty of resources on the internet to help you get to grips with Bryce, so that you will be able to follow these instructions…
To start with, create a new document in Bryce, with a rendering resolution of 1024 x 1024 pixels.
Now, build up a scene in Bryce. You might build the scene with the terrains and 3D shapes in Bryce or import models. There are many 3D models available, these examples use some from Stonemason, Helmut Schaub, Joe Kurz, Morphtactic and others in Daz, Renderosity and PlanIT 3D. Many models are available for free from these sites.
The scene is starting to take shape; the camera has been selected using the small arrow at the bottom of the screen (at the end of the row of object selectors) and choosing Select Camera.
Set up the camera using the rotate settings and field of view described in the "How to make cubic panoramas in different rendering applications" part of this Wiki.
You should now be ready to render your views. It's a good idea to save the views on the bookmark bar at the top left of the screen. Render the North, South, East, West, Up and Down images and copy them into a folder which can be placed in your Pipmak project
Did you know that Pipmak can automatically open your project? When you start Pipmak, it hunts for a .pipmak file or a directory which name enda with the suffix ".pipmak" in the some directory of the Pipmak executable; for example my project folder is called "Eternity.pipmak" so my project is automatically loaded when I launch pipmak.exe.
From the version 0.2.6 a button on the start up Pipmak menu lets you create a skeleton project, click it. Now you should open the main.lua file with one of the program listed in [Lua_Editors] page.
Global properties of a project are specified in the Lua file main.lua that sits at the top level of the project, next to the node folders. A project needs a title, which is displayed in the window title bar and which is used to identify to what project a saved game belongs. Additionally, Pipmak needs to know which node to show when the project is opened. These properties are specified by the following statements in main.lua, where title is a string and nodeid is a node number:
title title
startnode (nodeid)
Currently, the title may only contain ASCII characters. Any accented letters or other special characters will be replaced by question marks. Optionally, you can specify which version of Pipmak you used when designing the project, by writing
version (version)
in main.lua. Version is a decimal number with the major version number as integer part and the minor and sub-minor version numbers as the first and second decimal place. The user then gets a warning if his version of Pipmak is older or significantly newer than the version specified in the project. The general rule is that a new version of Pipmak will get a new minor version number if it introduces incompatibilities with projects made for the last version, while only the sub-minor revision number is incremented if older projects continue to work. Lua code that should be executed every time the project is opened can be placed in an openproject handler in main.lua:
onopenproject (
function()
--do something
end
)
This is the place to initialize the game state stored in the state table (see section 3.1 “Storing Game State”). While it will currently work placing such code directly in main.lua, this is deprecated because main.lua may also be run on other occasions in a future version. By default most of the keys do a particular function, useful for the development but not suitable for the game play. For customizing the key bindings just add this code in a specified node or in main.lua:
onkeydown (
function(key)
if key == string.byte(" ") then
if (pipmak.getmousemode() == pipmak.joystick) then
pipmak.setmousemode(pipmak.direct)
else
pipmak.setmousemode(pipmak.joystick)
end
return true
elseif key == pipmak.key_esc then
pipmak.gotonode(2)
pipmak.setstandardcursor(pipmak.arrow)
return true
else
return false
end
end
)
Above is only an example, refer to reference.pdf for the other key names.
Contents of node.lua: Slide is a fixed background image that fit the screen.
Slide {"background.jpg"}
Cube has the behaver of a 360° panorama using 6 seamless picture.
Cube {"front.jpg", "left.jpg", "back.jpg", "right.jpg", "up.jpg", "down.jpg"}
Panel is frame of specific size not resized to fit the screen, but is shown at a given location instead.
Panel {"picture.jpg", width=128, height=64, x=32, y=28}
Hotspot Map An hotspot map is a picture of any size but 256 color indexed stretched to fit the node. The number of the color spot is related of the index color of the palette.
Hotspotmap "hotspotmap.jpg"
Lua code that should be executed every time a certain node is entered can be placed in a function set as an enternode handler in the corresponding node.lua:
onenternode (function)
Uses of enternode handlers include initializing local state variables, starting timers (see section 3.10 “Timing”) to do background animation, or displaying overlays (see section 3.6 6 “Nodes”). You can define multiple enternode handlers, they will be called in the order of their definition when the node is entered. While it will currently work placing such code directly in node.lua, this is deprecated because node.lua may also be run on other occasions in a future version. To run some Lua code on leaving a node, use leavenode handlers:
onleavenode (function)
The enternode handlers are also called when nodes are entered during the process of loading a saved game. If this is a problem because some of the initializations done in the enternode handler are already in effect in the state loaded from the saved game file and should not be redone, set a flag in the state table at the end of the enternode handler and clear it in the leavenode handler. Then check that flag at the beginning of the enternode handler and skip the initialization if it is already set, indicating that we are coming from a saved game rather than another node. When several nodes are displayed simultaneously (see section 3.6.1 “The Node Stack”), mouseenter and mouseleave handlers allow you to track on which one the mouse pointer currently is:
onmouseenter (function(node))
onmouseleave (function(node))
The mouse is considered to be inside an overlay node when either the background of that node is opaque or less than half transparent at the mouse location, or when it has a control under the mouse location. (So, to make a node that’s more than half transparent catch mouseenter and mouseleave events, cover it with a dummy hotspot or handle.)
Draw your node with this possible button:
hotspot | handle {
[x = x, y = y,] --only for handles on flat nodes
[az = az, el = el,] --only for handles on panos
[w = width, h = height,] --only for handles
target = nodeid,
[effect = function,]
| effect = { function, argument, ... },
[cursor = cursor,]
[enabled = boolean],
Below is the code that chage:
onmousedown=function(self) pipmak.gotonode(2)end
}
As below, but use this code
onmousedown = function(self) pipmak.thisnode():closeoverlay() end )
Save game:
onmosedown = function(self) pipmak.savegame() end )
Load game:
onmousedown = function(self) pipmak.loadgame() end)
Option:
use raget = n. Below are explained how to build an option screen
Quit:
onmousedown = function(self) pipmak.quit() end)