v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

Template:Scriptdata/doc

From Dwarf Fortress Wiki
< Template:Scriptdata
Revision as of 03:28, 10 January 2025 by DPhKraken (talk | contribs) (Updated for new template features)
Jump to navigation Jump to search

Displays scripts from the Page name/script directory.

Derived from Template:Gamedata, with a few changes specific to displaying syntax highlighting.

Can be given a custom script to display instead:

  • |script= defines the content of the custom entry.
  • Automatically applies <syntaxhighlight lang="lua" line> to entries.
  • |line= changes the starting line (defaults to 1).

Example of a custom script that uses all parameters:

{{Scriptdata
|title=Identity language
|line=12
|script=
languages.GEN_IDENTITY=function()
    -- just to demonstrate the absolute most basic method of generating one of these
    -- also so that you can just mod stuff to use GEN_IDENTITY
    local tbl={}
    local unempty = function(str1, str2) 
        return str1=='' and str2 or str1
    end
    for k,v in ipairs(world.language.word) do
        local str=''
        str=unempty(str,v.NOUN_SING)
        str=unempty(str,v.ADJ)
        str=unempty(str,v.VERB_FIRST_PRES)
        str=unempty(str,string.lower(v.token))
        tbl[v.token]=str
    end
    return tbl
end
}}

As Lua scripting has not been released to the public, the {{raw}} template cannot fetch scripts from DFRawFunctions. Preliminary scripts have been provided by User:Putnam4315.

CancelHideAbout

Rating Template:Scriptdata/doc