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.

Difference between revisions of "Template:Scriptdata/doc"

From Dwarf Fortress Wiki
Jump to navigation Jump to search
m
m (Post lua release cleanup)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
Displays [[Lua scripting|scripts]] from the ''Page name/script'' directory.  
+
Displays [[:Category:Lua script pages|scripts]] from the ''Page name/script'' directory.
Works as [[Template:Gamedata]], with a few changes:
 
  
*Currently does not support custom entries - the body field was simplified due to interfering with ``<nowiki>{{Code}}</nowiki>``. ``<syntaxhighlight>`` is used now and the functionality might be restorable.
+
Derived from [[Template:Gamedata]], with a few changes specific to displaying syntax highlighting.
*The ``|title=`` cell functions as normal.
+
 
 +
Can be given a custom script to display instead:
 +
 
 +
* ``|script=`` defines the content of the custom entry.
 +
 
 +
* ``|title=`` parameter functions in the same way [[Template:Gamedata]] does so.
 +
 
 +
*Automatically applies ``<syntaxhighlight lang="lua">`` to entries.
 +
 
 +
<!--* ``|line=`` changes the starting line (defaults to 1).-->
 +
 
 +
Example of a custom script that uses all parameters:
 +
 
 +
<nowiki>{{Scriptdata
 +
|title=Identity language
 +
|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
 +
}}</nowiki>
 +
 
 +
{{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
 +
}}
 +
 
 +
Preliminary scripts have been provided by [[User:Putnam3145]].

Latest revision as of 02:03, 27 February 2025

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"> to entries.


Example of a custom script that uses all parameters:

{{Scriptdata
|title=Identity language
|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
}}

Preliminary scripts have been provided by User:Putnam3145.