Help:Setting up cargo for your game

From Mizuumi Wiki
Jump to navigation Jump to search

Why should I use Cargo?

Cargo is basically an SQL database for MediaWiki editors to query data from other pages which have stored data. This allows you to store data in one place instead of manually editing multiple pages if they are supposed to refer to the same data. The most obvious example would be character stats on individual character pages and then a comparison table on a systems or mechanics page. It's neat.

Sample Setup

For this example, we be creating a simple data table.

  1. Create the template you had in mind. In this case, it's simply a table that displays data values. You can even use a preexisting template that has already been set up. Here, we have parameters of various types.
    {| class="wikitable" style="text-align:center;"
    |+ {{{name}}} Data
    |-
    ! Health !! Walk Speed !! Dash Type !! Jump Duration
    |-
    | {{{health}}} || {{{walkSpeed}}} || {{{dashType}}} || {{{jumpDuration}}}
    |}
  2. We will add the cargo_declare section. This tells cargo that a table is declared to this template. No values are stored in cargo yet.
    Note that this section must be place within <noinclude> tags before the upcoming cargo_store bit.
    {{#cargo_declare:
    _table=CargoDemo
    | charaName = String
    | health = Integer
    | walkSpeed = Float
    | dashType = String
    | jumpDuration = Integer
    }}
  3. We want to store the values with cargo_store. This tells cargo to store values whenever this template is called. Essentially, you mirror all values used in the template here.
    Make sure to put this in <includeonly> tags after the cargo_declare bit.
    {{#cargo_store:
    _table=CargoDemo
    | charaName = {{{name}}}
    | health = {{{health}}}
    | walkSpeed = {{{walkSpeed}}}
    | dashType = {{{dashType}}}
    | jumpDuration = {{{jumpDuration}}}
    }}
  4. Now that your template is cargo ready, you now need a Bureaucrat or Admin to create the table for you. All they need to do is click on "Create data table" and then "OK".
    Help Cargo CreateTable.png
  5. Implement your templates on the pages you want. If you're working with a preexisting template, then you can skip this part as long as it was used correctly. We will implement the data on the Demo Data subpage for this example.
    {{CargoDemo
    | name = John
    | health = 120
    | walkSpeed = 0.80
    | dashType = Step
    | jumpDuration = 40
    }}
    
    {{CargoDemo
    | name = Rose
    | health = 90
    | walkSpeed = 1.20
    | dashType = Run
    | jumpDuration = 45
    }}
    
    {{CargoDemo
    | name = Jade
    | health = 110
    | walkSpeed = 0.95
    | dashType = Step
    | jumpDuration = 36
    }}
    
    {{CargoDemo
    | name = Dave
    | health = 100
    | walkSpeed = 0.95
    | dashType = Run
    | jumpDuration = 38
    }}
    
  6. Finally, we can now use this data on other pages with cargo_query. This is especially useful if you want to have a character comparison table on a systems or mechanics page.
    The implemented example can be found at the Demo Query subpage.
    {{#cargo_query:
    tables=CargoDemo
    | fields = charaName = Character, health = Health, walkSpeed = Walk Speed, dashType = Dash Type, jumpDuration = Jump Duration
    | format = table}}
    

End Results

Notes

  • Even though you can, it's best not store and query the same data on the same page. If you do this, data may not sync properly. The data is only stored when the page is saved, but the query will either need to catch up or you will need to manually clear the page's cache via the option "More > Purge Cache" menu next to the top-right search bar.
  • Along the same lines as the previous point, if data ever looks funny/incorrect, purging cache is usually the answer.
  • If you ever change the cargo_store or cargo_declare sections of a template, you will need a admin or bureaucrat to recreate the table.
  • Be wary that documentation requires a bit of extra wikitext to prevent the templates from making invalid table entries. (WIP, will update on this soon.)

Examples