Modding tutorial

Post Reply
kahrl
Member
Posts: 236
Joined: Fri Sep 02, 2011 07:51
Location: Rös̓̇chenhof

Modding tutorial

by kahrl » Post

With the advent (hah!) of the new Lua-based modding API, I think we should put some tutorials into the wiki. I'd like to hear your ideas about what they could be about. (Please don't suggest anything that would require significant changes on the C++ side, I expect such a tutorial to become out of date very quickly.)

Here's a start, but feel free to go in a completely different direction.
Note, I've often only thought about what concept the tutorial will be about, but still need to come up with a fun way to demonstrate it.

Mandatory
Every modder should read these.
  1. Getting started: This will give some basic information, show how a mod directory is set up, and define a new node type.
  2. Terminology: Gives an overview of the modding terminology, and some initial insights into the game engine.
Beginner
The beginner tutorials will explain one simple concept at a time, and don't go into much detail.
  1. Nodes: This will continue the "Getting started" tutorial and explore some of the simpler settings for nodes.
  2. Inventory: Explains itemstrings, and how to customize the give_initial_stuff mod.
  3. Crafting: This will show how to define new crafting recipes.
  4. Tools: This will show how to define new tools and their digging properties.
  5. Items: This tutorial demonstrates how to define a craftitem and explains the callbacks.
  6. Commands: This shows how to define a simple new server command. Not sure what this could be about. Maybe a /lightning command that damages all players? :O
  7. ...
Intermediate
These tutorials could explain more difficult concepts or expand on the info in the beginner tutorials.
  1. Engine details: Not directly a tutorial, but explains some of the engine details that don't fit into the "beginner" section, like active blocks and so on.
  2. ABMs: Shows a very simple ABM. Maybe one that converts cobble next to water to mossy cobble?
  3. Entities: This tutorial shows how Lua entities work. Again, what could it be about?
  4. Buckets: This will explain (in detail) how the existing bucket example works.
  5. Mapgen: How to run a callback each time a new mapblock has been generated, and do some fun stuff with it.
  6. Node parameters: Explains what nodes' param1 and param2 do. Maybe multiple parts, one for param1 = light value, one for param1 = facedir, another one for param2 things?
  7. Node metadata: Could show how to make a mob that vandalized all signs it finds. :D
  8. ...
Advanced
These will explain, um, advanced concepts or show how to combine several simpler steps to make a great mod (for science!)
TBD.

I'm quite sure I have forgotten something! Also, if anyone has an idea to get the tutorials into a logical order, that would be neat.

jachoo
Member
Posts: 45
Joined: Mon Sep 12, 2011 08:29

by jachoo » Post

IMO, this topic should be in 'development' section.

TBC_x
Member
Posts: 17
Joined: Wed Nov 02, 2011 13:18

by TBC_x » Post

something about performance

hiro
New member
Posts: 7
Joined: Thu Dec 01, 2011 00:53

by hiro » Post

just start simple, maybe illustrate how to add a new simple block with different properties, for example
nyan cat tail (stackable) and head (non-stackable).

then progress to something more complex, for example a pizza oven which is like a furnace but crafted
from brick blocks instead of stone, and gives better food.

i also like the idea of a safe, like a locking chest, but openable for anyone who knows the password or
combination.

direction blocks could be fun, blocks with an arrow on top that can only be passed in this direction. for this
a way to let the player set the direction would be needed. this could also be used to make more realistic logs.

dont know, but if possible leaf decay, water evaporation and lava cooling could be done via lua?

sfan5
Moderator
Posts: 4094
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

Oh!I really missed something
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

kahrl
Member
Posts: 236
Joined: Fri Sep 02, 2011 07:51
Location: Rös̓̇chenhof

by kahrl » Post

@TCB_x Thanks for the link. I agree, there should be at least some notes about performance in one of the early tutorials.

@hiro Nice ideas, thanks! (Although I'm not sure if the safe can be done any soon (requires an API for the GUIk), and the direction blocks are impossible to do in Lua because all player movement is still client-side.)

I'm not sure if I can start writing tutorials soon, too much other stuff to do :(. But this means the API will be less likely to change after the tutorials are written, right? ;)

User avatar
NakedFury
Member
Posts: 151
Joined: Thu Dec 08, 2011 03:55

by NakedFury » Post

Tutorials would be great to get started on modding. I know i would use them.

bcmpinc
Member
Posts: 30
Joined: Fri Jun 17, 2011 09:10

by bcmpinc » Post

Would the wiki be a good place to put these tutorials?

User avatar
kddekadenz
Member
Posts: 323
Joined: Mon Jun 27, 2011 17:21
GitHub: tinyworlds
Location: Germany
Contact:

by kddekadenz » Post

I would like to know how to create a random number, e.g. from 1-10 in Lua and how to create new mobs ;)

MarkTraceur
Member
Posts: 103
Joined: Sat Dec 03, 2011 05:41
Location: San Francisco, CA
Contact:

by MarkTraceur » Post

kddekadenz wrote:I would like to know how to create a random number, e.g. from 1-10 in Lua and how to create new mobs ;)

Code: Select all

-- at the beginning of your init.lua
math.randomseed(os.time())
-- wherever you need the random number
math.random(1,10)
New mobs are not yet available through the API, to my knowledge.

EDIT: You can see my leaf_decay mod for an example: https://gitorious.org/marktraceur-minet ... r/init.lua (search for "random" in the file)
Last edited by MarkTraceur on Thu Dec 08, 2011 17:03, edited 1 time in total.
Mods: https://gitorious.org/marktraceur-minetest-mods
IRC: marktraceur on freenode

User avatar
kddekadenz
Member
Posts: 323
Joined: Mon Jun 27, 2011 17:21
GitHub: tinyworlds
Location: Germany
Contact:

by kddekadenz » Post

Thank you for your help!
How can I combine a word with a random number with .png?
For example image_rndnumber.png? Is there any command for this, like 'concatword' ?

EDIT: Forget about this, I found a solution.

2nd EDIT:

Code: Select all

tile_images = { 'kdd_painting' .. (math.random(1,3)) .. '.png' },
I always get the 3rd pic :/
Any idea how to fix this?
Last edited by kddekadenz on Sun Dec 11, 2011 16:53, edited 1 time in total.

MarkTraceur
Member
Posts: 103
Joined: Sat Dec 03, 2011 05:41
Location: San Francisco, CA
Contact:

by MarkTraceur » Post

Put this at the beginning of your init.lua:

Code: Select all

math.randomseed(os.time())
This "seeds" the random number generator with the current time, pseudo-ensuring a random result at each run.
Mods: https://gitorious.org/marktraceur-minetest-mods
IRC: marktraceur on freenode

User avatar
jordan4ibanez
Member
Posts: 1923
Joined: Tue Sep 27, 2011 18:44
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

by jordan4ibanez » Post

how would you make it randomly select an item say a painting? because i have tried everything and it will not allow me
hello, am program. do language in rust. make computer do. okay i go now.

User avatar
Jeija
Member
Posts: 686
Joined: Fri Dec 23, 2011 21:46
Location: Nürtingen, Germany

by Jeija » Post

@Jordan:
Register all the painting nodes.
Then, in the on_placenode function for the painting node that you can craft, do something like this.
local i=math.random(5)
if i==1 then
minetest.env:add_node(pos, {name="painting:painting1"})
end
if i==2 then
minetest.env:add_node(pos, {name="painting:painting2"})
end
if i==3 then
minetest.env:add_node(pos, {name="painting:painting3"})
end
...

I'm not sure if this is the best solution, but it should be possible.
Redstone for minetest: Mesecons (mesecons.net)

User avatar
jordan4ibanez
Member
Posts: 1923
Joined: Tue Sep 27, 2011 18:44
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

by jordan4ibanez » Post

its helping me get there! ..i was going to do a bunch of if then statements with that if == command
hello, am program. do language in rust. make computer do. okay i go now.

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests