Difference between revisions of "User:Khaim"

From RimWorld Wiki
Jump to navigation Jump to search
(Query example)
(Basic property syntax)
Line 4: Line 4:
 
==How-To: Properties & Queries==
 
==How-To: Properties & Queries==
  
'''MediaWiki references'''
+
===Property Syntax===
* [https://www.semantic-mediawiki.org/wiki/Help:Properties_and_types Properties]
+
 
* [https://www.semantic-mediawiki.org/wiki/Help:Selecting_pages Query syntax]
+
====Adding properties to pages====
* [https://www.semantic-mediawiki.org/wiki/Help:Displaying_information Display syntax]
+
 
* [https://www.semantic-mediawiki.org/wiki/Help:Result_formats Result formats]
+
* Basic syntax: <tt><nowiki>[[Example property::value]]</nowiki></tt>
 +
** How this looks on the page depends on the property's ''type''. The default type is [[Special:Types/Page|Page]], which will display this the same as <nowiki>[[value]]</nowiki>, i.e. the text 'value' which links to the wikipage 'value'.
 +
** Properties with the [[Special:Types/Number|Number]] type - very common on this wiki - will not add a link. They will just display as 'value'.
 +
* Alternate display text: <tt><nowiki>[[Example property::value|alt-text]]</nowiki></tt>
 +
** Displays as either <nowiki>[[value|alt-text]]</nowiki>, for page links; or 'alt-text', for numbers.
 +
* Set property without displaying anything: <tt><nowiki>[[Example property::value| ]]</nowiki></tt>
 +
** The space is required.
 +
 
 +
If you add a property to a page, check that it's defined! If it isn't, the wiki will use the defaults, which are terrible. In this case you should create the property page yourself.
 +
 
 +
====Defining Properties====
  
===Property Syntax===
+
Property is defined by special pages with the '''Property:''' prefix. For example, the "Beauty Base" property is defined by [[Property:Beauty_Base]]. At minimum a property page needs to define its type.
 +
* Basic syntax: <tt><nowiki>[[has property::type| ]]</nowiki></tt>
 +
** On this wiki the type should probably be either 'number' or 'page'.
 +
** This is the exact same syntax as adding a property to a normal page. That's because ''has_type'' is also a property; it's a special built-in property.
 +
* Helper template: <tt><nowiki>{{Property with Page | page = Beauty | type = Number }}</nowiki></tt>
 +
** This sets the type and also displays ''See [[Beauty]]'' to link to the page that describes what this property is.
  
''TODO''
+
A property's page is also a wiki page, so you can add content to it as normal. It's fine to leave it blank.
  
 
===Query Syntax===
 
===Query Syntax===
Line 32: Line 47:
 
Example renders like this:
 
Example renders like this:
 
{{#ask:
 
{{#ask:
[[Skill Base Factor::+]]
+
[[Skill Base Factor::>0.4]]
 
[[Skill Bonus Factor::+]]
 
[[Skill Bonus Factor::+]]
 
| ?Skill Base Factor# = Base
 
| ?Skill Base Factor# = Base
Line 44: Line 59:
  
 
Comments:
 
Comments:
<nowiki>{{#ask:  // Begin a query.
+
<nowiki>{{#ask:  // Begin a query.
 +
 
 
// Everything up to the next | is the query term. This particular example returns pages which:
 
// Everything up to the next | is the query term. This particular example returns pages which:
 
[[Skill Base Factor::>0.4]]  // have the Skill_Base_Factor property, value is >0.4
 
[[Skill Base Factor::>0.4]]  // have the Skill_Base_Factor property, value is >0.4
 
[[Skill Bonus Factor::+]]    // AND have the Skill_Bonus_Factor property, with any value
 
[[Skill Bonus Factor::+]]    // AND have the Skill_Bonus_Factor property, with any value
// Define how the results are displayed.
+
 
//  For a table, the first column is the page name.
+
// Define columns to show. The first column is the page name.
 
| ?Skill Base Factor# = Base  // The second column is the page's Skill_Base_Factor value, with heading 'Base'.
 
| ?Skill Base Factor# = Base  // The second column is the page's Skill_Base_Factor value, with heading 'Base'.
| ?Skill Bonus Factor# = Factor
+
| ?Skill Bonus Factor# = Factor // The third column is Skill_Bonus_Factor, with heading 'Factor'
| format = table  // 'format = broadtable' makes a table as wide as the screen. Optional.
+
| mainlabel = Stat  // The heading for the first column.
| limit  = 100  // Maximum number of pages to return. Optional.
+
 
| mainlabel = Stat  // The heading for the first column (with the page name).
+
// Optional settings.
| sort = Skill Base Factor,Skill Bonus Factor  // Sort by base factor, then bonus factor. Optional.
+
| format = table  // This makes a fitted table. 'format = broadtable' makes a table as wide as the screen.
 +
| limit  = 100  // Maximum number of pages to return.
 +
| sort = Skill Base Factor,Skill Bonus Factor  // Sort by base factor, then bonus factor.
 
| order = desc,desc
 
| order = desc,desc
 
}}</nowiki>
 
}}</nowiki>
 +
 +
===MediaWiki references===
 +
* [https://www.semantic-mediawiki.org/wiki/Help:Properties_and_types Properties]
 +
* [https://www.semantic-mediawiki.org/wiki/Help:Selecting_pages Query syntax]
 +
* [https://www.semantic-mediawiki.org/wiki/Help:Displaying_information Display syntax]
 +
* [https://www.semantic-mediawiki.org/wiki/Help:Result_formats Result formats]
 +
* [https://www.semantic-mediawiki.org/wiki/Help:Special_properties Special properties]

Revision as of 21:35, 15 September 2016

Sandbox

How-To: Properties & Queries

Property Syntax

Adding properties to pages

  • Basic syntax: [[Example property::value]]
    • How this looks on the page depends on the property's type. The default type is Page, which will display this the same as [[value]], i.e. the text 'value' which links to the wikipage 'value'.
    • Properties with the Number type - very common on this wiki - will not add a link. They will just display as 'value'.
  • Alternate display text: [[Example property::value|alt-text]]
    • Displays as either [[value|alt-text]], for page links; or 'alt-text', for numbers.
  • Set property without displaying anything: [[Example property::value| ]]
    • The space is required.

If you add a property to a page, check that it's defined! If it isn't, the wiki will use the defaults, which are terrible. In this case you should create the property page yourself.

Defining Properties

Property is defined by special pages with the Property: prefix. For example, the "Beauty Base" property is defined by Property:Beauty_Base. At minimum a property page needs to define its type.

  • Basic syntax: [[has property::type| ]]
    • On this wiki the type should probably be either 'number' or 'page'.
    • This is the exact same syntax as adding a property to a normal page. That's because has_type is also a property; it's a special built-in property.
  • Helper template: {{Property with Page | page = Beauty | type = Number }}
    • This sets the type and also displays See Beauty to link to the page that describes what this property is.

A property's page is also a wiki page, so you can add content to it as normal. It's fine to leave it blank.

Query Syntax

A query allows you to insert content, usually tables, which dynamically update based on data from other pages.

Example wiki code:

{{#ask:
[[Skill Base Factor::>0.4]]
[[Skill Bonus Factor::+]]
| ?Skill Base Factor# = Base
| ?Skill Bonus Factor# = Factor
| format = table
| limit  = 100
| mainlabel = Stat
| sort = Skill Base Factor,Skill Bonus Factor
| order = desc,desc
}}

Example renders like this:

StatBaseFactor
Pruning Speed0.920.01
Social Impact0.820.0275
Mechanoid Shredding Efficiency0.750.025
Hacking Speed0.750.025
Mech Gestation Speed0.750.025
Butchery Efficiency0.750.025
Arrest Success Chance0.60.075
Negotiation Ability0.40.075
Medical Operation Speed0.40.06
Mechanoid Shredding Speed0.40.06
Butchery Speed0.40.06
Drug Cooking Speed0.40.06
Medical Tend Speed0.40.06

Comments:

{{#ask:   // Begin a query.

// Everything up to the next | is the query term. This particular example returns pages which:
[[Skill Base Factor::>0.4]]  // have the Skill_Base_Factor property, value is >0.4
[[Skill Bonus Factor::+]]    // AND have the Skill_Bonus_Factor property, with any value

// Define columns to show. The first column is the page name.
| ?Skill Base Factor# = Base  // The second column is the page's Skill_Base_Factor value, with heading 'Base'.
| ?Skill Bonus Factor# = Factor  // The third column is Skill_Bonus_Factor, with heading 'Factor'
| mainlabel = Stat  // The heading for the first column.

// Optional settings.
| format = table  // This makes a fitted table. 'format = broadtable' makes a table as wide as the screen.
| limit  = 100  // Maximum number of pages to return.
| sort = Skill Base Factor,Skill Bonus Factor  // Sort by base factor, then bonus factor.
| order = desc,desc
}}

MediaWiki references