Toggle search
Search
Toggle menu
Toggle personal menu
Editing
Modding/Templates/Instruction
From Desynced Wiki
Read
Edit
Edit source
View history
Page
Discussion
More actions
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
__FORCETOC__ This mod template creates a new behavior instruction. == Code == === def.json === Content<syntaxhighlight lang="json"> { "id": "ModTemplateInstruction", "name": "Mod Template Instruction", "version_name": "1.0", "version_code": 1, "author": "The Desynced Team", "homepage": "https://www.desyncedgame.com/", "description": "Mod Template Instruction", "packages": { "Data": { "name": "Data", "entry": "data.lua", "dependencies": [ "Main/Data" ], "type": "Addon" } } } </syntaxhighlight> === data.lua === Content<syntaxhighlight lang="lua"> local package = ... -- files loaded when mod is initializing package.includes = { "instructions.lua", } -- called when mod is initializing function package:init() end </syntaxhighlight> === instructions.lua === Content<syntaxhighlight lang="lua"> -- Local references for shorter names and avoiding global lookup on every use local Get, GetNum, GetId, GetEntity, AreEqual, Set = InstGet, InstGetNum, InstGetId, InstGetEntity, InstAreEqual, InstSet data.instructions.mod_add_one = { func = function(comp, state, cause, from, to) local r = Tool.NewRegisterObject(Get(comp, state, from)) -- copy to avoid changing from r.num = r.num + 1 Set(comp, state, to, r) end, args = { { "in", "From", nil, "num" }, { "out", "To" }, }, name = "Add One [MOD]", desc = "Adds one to a number", category = "Math", icon = "Main/skin/Icons/Special/Commands/Add Numbers.png", } </syntaxhighlight> {{ModdingNav}}
Summary:
Please note that all contributions to Desynced Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Desynced Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:ModdingNav
(
edit
)
Template:Navbox
(
edit
)