Post your modding questions here

User avatar
Chinchow
Member
 
Posts: 683
Joined: Tue Sep 18, 2012 21:37

Re: Post your modding questions here

by Chinchow » Mon Jul 07, 2014 15:10

There is probably a very simple answer to this, but how would one create a flat area of certain dimensions. For example: Say you have a hill, but you want something to generate there via a mod. However when you generate your structure there are nodes from the hill inside. Therefore a flat area needs to be set.
 

User avatar
srifqi
Member
 
Posts: 508
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi

Re: Post your modding questions here

by srifqi » Mon Jul 07, 2014 17:41

prestidigitator wrote:Where did you start the server?

Singleplayer
prestidigitator wrote:Can you see any error output in the console there, or in the log file?

No. Just a normal output

chinchow wrote:There is probably a very simple answer to this, but how would one create a flat area
of certain dimensions. For example: Say you have a hill, but you want something to
generate there via a mod. However when you generate your structure there are nodes
from the hill inside. Therefore a flat area needs to be set.

That's why i want it works in singlenode mapgen
I'm from Indonesia! Saya dari Indonesia!
Terjemahkan Minetest!
Mods by me. Modifikasi oleh saya.

Pronounce my nick as in: es-rifqi (IPA: /es rifˈki/)
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Post your modding questions here

by Krock » Mon Jul 07, 2014 19:03

Chinchow wrote:flat area

viewtopic.php?p=145653#p145653
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
Chinchow
Member
 
Posts: 683
Joined: Tue Sep 18, 2012 21:37

Re: Post your modding questions here

by Chinchow » Mon Jul 07, 2014 19:34

Krock wrote:
Chinchow wrote:flat area

viewtopic.php?p=145653#p145653

I apologize it seems I did not specify. I want a normal world with hills and the like, and I want a contained area to be flattened.
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Post your modding questions here

by Krock » Mon Jul 07, 2014 19:54

Chinchow wrote:
Krock wrote:
Chinchow wrote:flat area

viewtopic.php?p=145653#p145653

I apologize it seems I did not specify. I want a normal world with hills and the like, and I want a contained area to be flattened.


Contains streets, hills, flatlands. viewtopic.php?f=9&t=9296
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
LionsDen
Member
 
Posts: 525
Joined: Thu Jun 06, 2013 03:19

Re: Post your modding questions here

by LionsDen » Mon Jul 07, 2014 19:54

Check out paramat's terrain flattener mod.

viewtopic.php?f=11&t=7701

This may be a lot more like you want.
 

User avatar
philipbenr
Member
 
Posts: 1665
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: WisdomFire or philipbenr

Re: Post your modding questions here

by philipbenr » Thu Jul 10, 2014 22:52

dev.minetest.net wrote:> drop — alternatively drop = { max_items = ..., items = { ... } }


How to use the multiple drop function? I am trying to get a node to drop more than one thing when it is dug.
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Post your modding questions here

by Krock » Fri Jul 11, 2014 08:59

philipbenr wrote:
dev.minetest.net wrote:> drop — alternatively drop = { max_items = ..., items = { ... } }


How to use the multiple drop function? I am trying to get a node to drop more than one thing when it is dug.


Something similar to
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
drop = {
   max_items = 2,
   items = {
      {items = {"mod:item"}, rarity = 10 },
      {items = {"mod:item"}, rarity = 2 },
   }
},

Chance to get the item is 1 / rarity
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
philipbenr
Member
 
Posts: 1665
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: WisdomFire or philipbenr

Re: Post your modding questions here

by philipbenr » Fri Jul 11, 2014 16:22

Ohhhh. Thanks Krock! ;)

Edit1: So, one is will drop and 10 really rare.

Edit2: More info (forgot to post this ;) I'm making a sub-game, and I want the birch tree (separate mod in the game) to drop a birch tree unit always and paper unit sometimes.
 

User avatar
philipbenr
Member
 
Posts: 1665
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: WisdomFire or philipbenr

Re: Post your modding questions here

by philipbenr » Sat Jul 12, 2014 11:16

Question #2:
Is there a way to make sure that texture packs are not enabled in game.conf (when making a game...) I want to have the textures be default and stay that way (There is a good reason too). Or at least disabled at first entry.

Edit:
And for question #3:
What is the simplest way to define a tree and have it spawn in the world? I want to have a simple birch tree, close to the default elm or whatever. Anyhow, I saw that there is the L system, but I was hoping there would be a better way to do it now in 0.4.10
 

User avatar
Casimir
Member
 
Posts: 1101
Joined: Fri Aug 03, 2012 16:59

Re: Post your modding questions here

by Casimir » Sat Jul 12, 2014 13:01

#2 I don't think so. You can not prevent the clients from doing what they want.
#3 Look at minetest_game's default/trees.lua and functions.lua
 

User avatar
philipbenr
Member
 
Posts: 1665
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: WisdomFire or philipbenr

Re: Post your modding questions here

by philipbenr » Sat Jul 12, 2014 14:45

#2: That's what I was afraid of... Oh well. Cant be helped. Also, when I look in minetest.conf, I see the line:
"mainmenu_last_selected_TP = 1" and the line "texture_path = ____" So I was wondering if those made any difference.
#3: I already looked in trees.lua so I suppose it would be in functions.lua...
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: Post your modding questions here

by kaeza » Sat Jul 12, 2014 15:47

As said by Casimir, you can't force the client to do what you want, but you can recommend people to use the default textures. If it looks bad with other texture packs, it's the user's fault, not yours.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
philipbenr
Member
 
Posts: 1665
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: WisdomFire or philipbenr

Re: Post your modding questions here

by philipbenr » Sat Jul 12, 2014 16:22

@kaeza: question, but do you know of you can change the facedir of a node on a spawning tree?

I want to have ivy growing on trees that is climbable. It would look horrible with random ladderlike nodes facing only one direction...
 

User avatar
RHR
Member
 
Posts: 214
Joined: Mon Jan 27, 2014 20:07
GitHub: RHRhino

Re: Post your modding questions here

by RHR » Sat Jul 12, 2014 16:31

#2: Just rename all textures in the texture folder and in the source code e.g. default_stone.png --> philipbenr_stone.png
 

User avatar
philipbenr
Member
 
Posts: 1665
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: WisdomFire or philipbenr

Re: Post your modding questions here

by philipbenr » Sat Jul 12, 2014 17:48

RHR wrote:#2: Just rename all textures in the texture folder and in the source code e.g. default_stone.png --> philipbenr_stone.png


Very very original thinking. XD Might even use. (probably a no; either that or release the textures as a separate TP.)
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: Post your modding questions here

by paramat » Sun Jul 13, 2014 04:37

I've been meaning to ask a question for perhaps a year, i'm in the habit of adding 'modname = {}' to a mod's init.lua file, but i still don't know why this is done, which is why i title that with the comment 'Stuff' in my code. What is the purpose and (when) is it essential?
 

yaman
Member
 
Posts: 56
Joined: Wed Sep 04, 2013 21:22

Re: Post your modding questions here

by yaman » Sun Jul 13, 2014 05:20

Topic - How do you get the player's position, or better, the position of the block they are standing on?
Reason - I am making a gold touch mod: it makes blocks the player walks on into gold blocks
More Info - I really want to get into coding mods and I want to succeed in making this one so I can get my self esteem up.
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Post your modding questions here

by Krock » Sun Jul 13, 2014 07:43

yaman wrote:Topic - How do you get the player's position, or better, the position of the block they are standing on?
Reason - I am making a gold touch mod: it makes blocks the player walks on into gold blocks
More Info - I really want to get into coding mods and I want to succeed in making this one so I can get my self esteem up.

minetest.get_node(vector.round(player:getpos())
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
Casimir
Member
 
Posts: 1101
Joined: Fri Aug 03, 2012 16:59

Re: Post your modding questions here

by Casimir » Sun Jul 13, 2014 13:24

@paramat
(Please anyone correct me if I'm wrong on this.)
Normally you don't need this. Only it you want that definitions made by your mod can be used by other mods too.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
yourmod = {} -- global variable
local modname = "yourmod" -- local variable
local function first_func(pos, player)
   -- this is a local function
end

function yourmod.second_func(pos, player)
      -- this is a global function
end

From within your mod you can call both functions by there name. From an other mod you can only call yourmod.second_func because it is part of the table "yourmod" which is a global variable.

edit: see webdesigners post
Last edited by Casimir on Sun Jul 13, 2014 19:04, edited 1 time in total.
 

User avatar
webdesigner97
Member
 
Posts: 1307
Joined: Mon Jul 30, 2012 19:16
GitHub: webD97
IRC: webdesigner97
In-game: webdesigner97

Re: Post your modding questions here

by webdesigner97 » Sun Jul 13, 2014 13:56

Casimir wrote:@paramat
(Please anyone correct me if I'm wrong on this.)
Normally you don't need this. Only it you want that definitions made by your mod can be used by other mods too.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
yourmod = {} -- global variable
local modname = "yourmod" -- local variable
function first_func(pos, player)
   -- this is a local function
end

function yourmod.second_func(pos, player)
      -- this is a global function
end

From within your mod you can call both functions by there name. From an other mod you can only call yourmod.second_func because it is part of the table "yourmod" which is a global variable.

first_func() is also global, make it local by putting "local" before "function". In theory, you don't need to put your mod's functions in a table, but to make sure that they are unique and don't get overriden accidently by other mods, many modders do put their function in tables.
 

yaman
Member
 
Posts: 56
Joined: Wed Sep 04, 2013 21:22

Re: Post your modding questions here

by yaman » Mon Jul 14, 2014 05:14

2 Questions

Topic - How do you replace a single node if I have its position stored in a variable?
Reason - Creating goldtouch mod

Topic - How could i make a chat command make a loop to do a function over and over
Reason - to make the ground under you keep turning into gold


*Edit* - Solved
Last edited by yaman on Mon Jul 14, 2014 18:57, edited 1 time in total.
 

User avatar
srifqi
Member
 
Posts: 508
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi

Re: Post your modding questions here

by srifqi » Mon Jul 14, 2014 09:34

How to create my own map gen?
I see there's many mapgen mod that use singlenode mapgen.
Minetest Dev Wiki wrote:singlenode:Intended to be used by mods that perform total mapgen takeovers.
I'm from Indonesia! Saya dari Indonesia!
Terjemahkan Minetest!
Mods by me. Modifikasi oleh saya.

Pronounce my nick as in: es-rifqi (IPA: /es rifˈki/)
 

drkwv
Member
 
Posts: 67
Joined: Thu Jun 28, 2012 13:48

Re: Gracefully replace node upon digging?

by drkwv » Tue Jul 15, 2014 17:24

prestidigitator wrote:you might need to us on_dig() instead.

I have copied on_dig from builtin/item.lua and set it for my needs, but lag is still there (pushed this code to github). I have found out that even with an empty function passed to on_dig, minetest client is removing node then setting it back instead of simply doing nothing. Is there anything else I can do to get rid of the lag?
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

Re: Post your modding questions here

by prestidigitator » Tue Jul 15, 2014 22:48

paramat wrote:I've been meaning to ask a question for perhaps a year, i'm in the habit of adding 'modname = {}' to a mod's init.lua file, but i still don't know why this is done, which is why i title that with the comment 'Stuff' in my code. What is the purpose and (when) is it essential?

As others have said, a table with the name of your mod creates a convenient namespace to place your API. Any functions or variables you want to be "publicly" accessible (part of an outside API usable by other mods and during debugging) should go there. This is the de facto standard for mod APIs.

EVERY top-level variable or function you use in your mod which does NOT go in that table should be local! Otherwise it pollutes the global namespace, which is a Bad Thing. Note that in Lua the syntax:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
function mytable.myfunc(...) ... end

is guaranteed by the language to be exactly equivalent to:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
mytable.myfunc = function(...) ... end

so if you do not create "mytable" in the first place you'll get an error because you are trying to set a value in a non-existent table (the global variable "mytable" effectively has the value nil). See Lua Function Definitions.
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

Re: Post your modding questions here

by prestidigitator » Tue Jul 15, 2014 23:07

yaman wrote:Topic - How do you get the player's position, or better, the position of the block they are standing on?
Reason - I am making a gold touch mod: it makes blocks the player walks on into gold blocks
More Info - I really want to get into coding mods and I want to succeed in making this one so I can get my self esteem up.

If you have a player object (like from a parameter to a registered callback function), you can get the player's position by calling the getpos() method on it:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local pos = player:getpos();
...

If you only have the player's name, you can try to get the player object using minetest.get_player_by_name():

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local player = minetest.get_player_by_name(player_name);
if not player then error("player "..player_name.." not found"); end
local pos = player:getpos()
...

The player's position will generally be about one unit higher (the y direction is up) than the block he or she is standing on, if standing rather than jumping or flying or falling or swimming or whatever. So given the above two examples, you might be interested in the position "{x=pos.x, y=pos.y-1, z=pos.z}".
 

User avatar
LionsDen
Member
 
Posts: 525
Joined: Thu Jun 06, 2013 03:19

Re: Gracefully replace node upon digging?

by LionsDen » Wed Jul 16, 2014 00:13

drkwv wrote:
prestidigitator wrote:you might need to us on_dig() instead.

I have copied on_dig from builtin/item.lua and set it for my needs, but lag is still there (pushed this code to github). I have found out that even with an empty function passed to on_dig, minetest client is removing node then setting it back instead of simply doing nothing. Is there anything else I can do to get rid of the lag?


If you simply want the node to never be able to be dug then add diggable = false, to the node definition. If you want it to be dug and then replaced, I'm not sure how to optimize that because I only play single player and haven't tried to do anything for servers.
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: Post your modding questions here

by paramat » Wed Jul 16, 2014 09:40

Thanks everyone.
srifqi wrote:How to create my own map gen?

See this thread https://forum.minetest.net/viewtopic.php?f=18&t=6396
I also have a few simplified lua mapgens meant to help people learn the methods, the most useful one is here https://forum.minetest.net/viewtopic.php?f=11&t=8628
 

User avatar
srifqi
Member
 
Posts: 508
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi

Re: Post your modding questions here

by srifqi » Thu Jul 17, 2014 08:30

paramat wrote:See this thread https://forum.minetest.net/viewtopic.php?f=18&t=6396
I also have a few simplified lua mapgens meant to help people learn the methods, the most useful one is here https://forum.minetest.net/viewtopic.php?f=11&t=8628


Thanks, paramat!
I'm from Indonesia! Saya dari Indonesia!
Terjemahkan Minetest!
Mods by me. Modifikasi oleh saya.

Pronounce my nick as in: es-rifqi (IPA: /es rifˈki/)
 

User avatar
Mitroman
Member
 
Posts: 62
Joined: Thu Apr 03, 2014 19:47
GitHub: Mitroman
In-game: Mitroman15

Re: Post your modding questions here

by Mitroman » Sat Jul 19, 2014 21:35

Hi. I wanted to have the Itemstack of the wielded item of the player. But here is the problem:
There is a function (player:get_wielded_item() ) that should return the Itemstack, but it returns userdata and I have no idea how to change / use it into an itemstack. Thanks :).
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: Google [Bot] and 5 guests

cron