Welcome Guest (54.226.5.29)! (Login - Register)
Your Ad Here
Home - FAQs - Forums - Join a Game - Game Index - Links

Data Templates (Topic #22974)

Main Forum (#13) > Site Questions, Suggestions, and Admin Requests (#931) > Site Feature Descriptions (#30486) > Data Templates

Roleplay Market



Subscription Options

You must be logged in to subscribe to this topic by e-mail or to add it to your favorites.



Support RPM through Kachingle or Flattr:


Post Reply
Body
BobTHJ

Owner of the Market
7/21/2008 5:59:28 PM
PostID: 238587
Data Templates are the latest addition to RPM. They allow you to include forms and templates anywhere you can use a smart link, and permit the construction of advanced objects such as self-calculating character sheets.

NOTE: While it is possible to make use of some simple functions of Data Templates without programming knowledge, an understanding of IScript (Roleplay Market's built in scripting language) is needed for more advanced functions.

Data Templates can be inserted into any text in the same manner as a smart link. A data template uses the following format:

<*@TEMPLATE parameter1="value" parameter2="value2" *>


There are presently six different Data Templates:

TEXT
This displays a single-line textbox where a viewer can enter a value. It has six parameters:
default - (optional) display this value in the textbox if no other value is specified (use only when you don't specify the "data" parameter).
script - (optional) execute this IScript whenever the value of this textbox changes.
data - (optional) link this textbox to a specific variable of this topic (the textbox will display the specified variable and will permit the user to edit it)
validate - (optional) An IScript to execute whenver the value of this textbox changes. Only accepts the new value if this script returns other than "nil" (substitute the value entered in the textbox for *val*)
size - (optional) if omitted, or if 1 displays a normal one-line textbox. Otherwise displays a larger scrolling textarea with a number of lines equal to the size.
style - (optional) allows you to apply CSS styles to this data template as if it were an HTML element.
Examples:
A textbox to display on a character sheet that allows the user to track their current HP.:
<*@TEXT data="HP" *>

Here's how it looks:


Same as the above, except this textbox will only allow the user to enter a number:
<*@TEXT data="HP" validate="(IsNumeric *val*)" *>

Here's how it looks:


BUTTON
Creates a button that the user can click to run a script. Three parameters:
text - This is the text to display on the button
script - The IScript to run when a user clicks the button
style - (optional) allows you to apply CSS styles to this data template as if it were an HTML element.

Example:
This button updates its text to a random number each time it is clicked:
<*@BUTTON text="(GetData 22974 dice_button)" script="(SetData 22974 dice_button (Roll 1d6))" *>

Give it a try:


CHOOSE
This displays a drop-down list that the user can choose an option from. There are five parameters:
default - (optional) display this parameter initially (use if you don't specify the "data" parameter)
list - An IScript that returns a list of options for the drop-down list
data - (optional) store the chosen option in this variable
script - (optional) Execute this IScript whenever the value of the drop down list changes.
style - (optional) allows you to apply CSS styles to this data template as if it were an HTML element.

Example:
This drop down lists allows the user to pick a number:
<*@CHOOSE list="(List 1 2 3 4 5)" *>

Looks like:


SHOW
Displays a variable or the results of a script. Has three parameters, you must specify either the script or data parameter:
script - (optional) displays the result of this Iscript
data - (optional) displays the named variable
style - (optional) allows you to apply CSS styles to this data template as if it were an HTML element.

This displays the HP value of this thread (note that when you update the textboxes above this will update to reflect the new value):
<*@SHOW data="HP" *>

Displays as:
8


DISPLAY
This displays a template (a Document, Character, or Template topic) inline in your text. Has four parameters:
template - The ID number of the Document topic to display, or the name of the topic you wish to display (Use the ID number if possible as pages will load faster)
display - (optional) An Iscript. If this evaluates to "nil" the template is not displayed
(variables) - (optional) You can specify any other parameters as variables to pass to the included template.
format - (optional) You can specify the TopicID of a template to display the document using the specified template.

Examples:
First, take a look at template test the template these examples will include. Here is the text of that template:
<*@Show data="the_value"*> <*@Choose list="(List 1 2 3 4 5)" default="4"*>


This displays the template only on a roll of 1 on a 1d2 (refresh the page a few times to see the results):
<*@DISPLAY template="22971" display="(Compare = 1 (Roll 1d2))" *>

Seen here (50% of the time):


This displays a template, but passes a new value for the variable "the_value":
<*@DISPLAY template="22971" the_value="Choose an option:" *>

Displays as:


REPEAT
Repeat works similar to the Display data template, but allows you to display a Document multiple times for each item in a list. It has three parameters:
template - The ID number or name of the Document to display (Again, using an ID number will cause the page to load faster)
list - This is an IScript that returns a list. The Document will be displayed once for each item in the list.
name - (optional) The name of the repeater variable. For each item in the list the value of that item is stored in this variable for use when displaying the Document.

Examples (still using template test from above as the document to display):
This displays the document three times:
<*@REPEAT template="22971" list="(List 1 2 3)" *>

Displays as:
System.InvalidCastException: Specified cast is not valid. at Integrity.IScript.IScriptParser.CollParse(String str, Object context, Scope s) at Integrity.RolePlayMarket.DataTemplate.CollParse(String str) at Integrity.RolePlayMarket.RPMUser.TemplateDisplay(String id)


This displays the document three times, while making "the_value" the repeater variable:
<*@REPEAT template="22971" list="(List first second third)" name="the_value" *>

Displays as:
System.InvalidCastException: Specified cast is not valid. at Integrity.IScript.IScriptParser.CollParse(String str, Object context, Scope s) at Integrity.RolePlayMarket.DataTemplate.CollParse(String str) at Integrity.RolePlayMarket.RPMUser.TemplateDisplay(String id)

  This post last edited on 3/18/2010 7:09:19 PM   Like this post
page  of 1 pages containing 1 items.Items per page:

Home - Control Panel - FAQs - Forums - Join a Game - Create a Game - Game Index - User Directory - Privacy Policy -
System Time: 5/22/2013 6:43:54 AM
RPG,D&D Library