Ask Tutorial

From RimWorld Wiki
Revision as of 20:09, 28 March 2022 by Ickputzdirwech (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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 for the query:

{{#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
}}

Wiki code on Mechanoid Disassembly Efficiency:

[[Skill Base Factor::0.75|75%]] plus [[Skill Bonus Factor::0.025|2.5%]] per skill level.

(Similar wiki code is on the other pages.)

Query output:

StatBaseFactor
Reading Speed10.02
Pruning Speed0.920.01
Social Impact0.820.0275
Mech Repair Speed0.80.1
Subcore Encoding Speed0.750.1
Butchery Efficiency0.750.025
Mechanoid Shredding Efficiency0.750.025
Hacking Speed0.750.025
Mech Gestation Speed0.750.025
Arrest Success Chance0.60.075
Negotiation Ability0.40.075
Medical Tend Speed0.40.06
Medical Operation Speed0.40.06
Mechanoid Shredding Speed0.40.06
Butchery Speed0.40.06
Drug Cooking 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