One of the many pastimes of people on RockMonkey is the creation of Wiki Games (such as RestlessWorld and Wiki Bridge Puzzle). To assist in the creation of Wiki Games, I have created this page.
1. General Design Tips
- When designing a wiki-based adventure (or other) game, use the Wanted Pages list to determine which links you have not yet 'finished'. When testing a WikiGame on behalf of the creator, do not 'create' missing pages (unless invited to), because this makes it very difficult for them to find and 'fix' missing pages.
- Sketch out a design on paper before you start: outline what the game will be about and how it will be fulfilled.
- Avoid making 'Game Over' situations where it is not possible that the player will have been given any warning beforehand. (Restless Boy - this is no fun)
2. Advanced WikiGame Tools
2.1. Inventory Management
- Thanks to a plug-in I've written, it is now possible to 'give' your players 'items' which they will carry around until relieved of them.
- To give your player an item, simply include a line like in your code. If the player does not already have the item, they will be told that they now do, and it will be added to their inventory (shown at the side of the window). To see this in action, and to examine a code example, visit Wiki Game Toolkit Demo Pickup and WikiGameToolkitDemoPickup2.
- To force your player to lose an item, simple add a line like in your code. If the player has the item, they will be informed that they no longer have it and it will be removed from their inventory. To see this working, visit Wiki Game Toolkit Demo Drop and WikiGameToolkitDemoDrop2.
- To show a link only if a player has a certain item or at least one of a number of items, use: For more complex examples of usage, see Wiki Game Toolkit Demo Has One.
- To show a link only if a player does not has a certain item or at least one of a number of items, use: For more complex examples of usage, see Wiki Game Toolkit Demo Has None.
- To show a link only if a player has all of the items in a set, use: This works a lot like ""Inv Has One"", but the link is only shown if the player has every item in the slash-separated list.
- Do not make a WikiGame in which it is possible to entirely 'get stuck' if you do not have a certain item. Death and other 'Game Over' conditions are fine, but please include a 'Try Again' link back to the front page of your game.
- Remember to add lines to the front page of your game to force your players to 'drop' all of the items that feature in your game, before they start, otherwise they'll be able to cheat very easily. Cheating is still possible - as in any WikiGame - but if you follow these guidelines then it can't be done 'accidently'.
2.2. TokensTokens are a kind of semi-persistent variable: a named token that can be assigned a value that can be retrieved later. They can basically be used for all the same things as objects (above) can be used for, but also a lot more, too.
- To set a token, use the following syntax: This will set the value of the token "myTokenName" to "fred". You can store pretty much any kind of data in a token, but the thing they're most useful for storing is numbers.
- To display the value of a token, use: If the previous code had been executed, this would output the word "fred" to the screen.
- If you've put a numerical value into a token, you can do simple mathematical operations upon it. This code will increment the value of the "myValue" token by 5: And the following code will decrement it by 3: See the code that manages the scoring mechanism in Wiki Scissors Stone Paper an example of this.
- You can also use SetToken to generate random numbers: The code shown above will generate a random number between 1 and 6 (inclusive) and put it into the token called "myValue". If you then entered the following code: You would increment the value by another random number between one and six - this accurately simulates the rolling of two six-sided dice.
- Coming soon: The ability to duplicate token values and set token values in relation to one another.
2.3. Conditional LogicWe've already seen that we can use """Inv Has One""", """Inv Has None""" and """Inv Has All""" to test whether a player is carrying a particular object or objects (see code in Troma Night Adventure for examples of this). What's more useful is the ability to integrate more complex logic into your Wiki Games:
- You can test the value of a token, the state of the inventory, or the currently logged-in user, using the Test directive. The result of the Test is executed immediately. The syntax is: It is also possible to add an 'else' clause, which will be executed if the expression evaluates to false, using:
- Expressions are written in the form "1 = 2". For example, the following code: Will always print out "One is not equal to two!", because the expression "1 = 2" will always evaluate to false. However, the code: Will always return "Yay; they're the same!", because "1 = 1" will always evaluate to true.
- Valid operators for use in expressions are = (equal to), < (less than), and > (greater than).
- You can substitute a token value in place of a literal in an expression using the getToken function, as shown below: This snippet of code will print out "You got over fifty points!" is the value in the "playerScore" variable is greater than 50, and "You got fifty or less points!" otherwise. Be advised that it is not sensible to increment a player's score "on the fly" during a game, as they may (accidently or deliberately) press the "refresh" button on their browser to increment their score again! Better to set a series of tokens for each "achievement" they have managed on their journey, and add up a score at the end (see TromaNight230 - the Troma Night Adventure score page, for an example of this).
- You can even compare tokens to one another, e.g.
- You can use a Test code block to execute other syntax blocks (for example, """SetToken""" or images), but this is a nightmare to get your head around. Look at example code in, for example, Wiki Scissors Stone Paper for an example, and look at the following code block (notice use of ~(, ~, and }~ inside the "then" block):
- You can also use all the usual boolean operators (and, or, and not [expressed an a preceeding exclamation mark]). For example:
- Other constructs that can be used in an expression include isUser("""UserName"""), which evaluates to 'true' if the player is logged in as the specified user name, hasItem("""ItemName"""), which evaluates to true if the player has the specified item in thier inventory, and countItems("""ItemOne"""/"""ItemTwo"""/"""ItemThree"""), which evaluates to the number of items from the slash-seperated list that the player has. In the example (countItems("""ItemOne"""/"""ItemTwo"""/"""ItemThree""")), this would evaluate to 3 only if the player had """ItemOne""", """ItemTwo""", and """ItemThree"""; to 2 if he had only 2 of them, and so on.
- Do not try to embed a Test block within a Test block. If you need this kind of multi-level functionality, you will need to set a temporary token and test for it later, in a seperate test block.
- Tip 1: Remember that Test blocks, like """SetToken""" and the like, will print out a blank line on the resulting page if you put them on a line by themselves (which could leave giveaway 'gaps' on your page, indicating that code is being run). To alleviate this, try to put code blocks (series' of Tests, etc) on the same line.
- Tip 2: The whitespace in Test expressions is necessary. Sorry.