Post your modding questions here

prestidigitator
Member
 
Posts: 640
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:

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():

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: 530
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.
 

User avatar
paramat
Developer
 
Posts: 3580
Joined: Sun Oct 28, 2012 00:05
Location: UK
GitHub: paramat
IRC: 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: 557
Joined: Sat Jun 28, 2014 04:31
Location: Indonesia
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!
Saya dari Indonesia! · Terjemahkan Minetest! · my mods · My nickname in IPA: /es.rif.qi/
 

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 :).
 

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

Re: Post your modding questions here

by prestidigitator » Sun Jul 20, 2014 09:26

Mitroman wrote: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 :).

Itemstacks ARE userdata objects. Userdata objects can have methods associated with them. Try some of the Itemstack methods (e.g. player:get_wielded_item():get_name()) on the returned userdata object and you should get what you expect from an Itemstack.
 

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

Re: Post your modding questions here

by prestidigitator » Sun Jul 20, 2014 09:29

paramat wrote: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

Here's a little more about mapgens: Development Wiki Modding FAQ: How Do I Generate a Custom Map?
 

UtahTeapot
New member
 
Posts: 1
Joined: Wed Jul 09, 2014 17:37
In-game: UtahTeapot

Re: Post your modding questions here

by UtahTeapot » Tue Jul 22, 2014 17:48

Title: How can I change the default font?
I've saw people change their default font, i wanna do it myself!

OffT: Hi! I'm new here!
 

User avatar
kidmondo
Member
 
Posts: 130
Joined: Sun May 11, 2014 07:56
Location: New Zealand
IRC: kidmondo
In-game: kidmondo
 

User avatar
philipbenr
Member
 
Posts: 1688
Joined: Fri Jun 14, 2013 01:56
Location: United States
GitHub: philipbenr
IRC: philipbenr
In-game: robinspi

Re: Post your modding questions here

by philipbenr » Wed Jul 23, 2014 00:16

I just replaced the font files in the fonts folder and renamed them to liberationsans.ttf and whatever. Just replace them is what I'd suggest.
 

User avatar
Calinou
Moderator
 
Posts: 3162
Joined: Mon Aug 01, 2011 14:26
Location: Troyes, France
GitHub: Calinou
IRC: Calinou
In-game: Calinou

Re: Post your modding questions here

by Calinou » Wed Jul 23, 2014 08:34

UtahTeapot wrote:Title: How can I change the default font?
I've saw people change their default font, i wanna do it myself!

OffT: Hi! I'm new here!


This has nothing to do with modding, but put this in minetest.conf and replace the font path with something else (or nothing if you have no font around, to use the default one):

This changes font settings which work only with Freetype-enabled builds, not with bitmap fonts.

Code: Select all
font_path = /usr/share/fonts/truetype/droid/DroidSans.ttf
font_size = 18
font_shadow_alpha = 255
mono_font_size = 16
fallback_font_size = 18
fallback_font_shadow_alpha = 255
 

User avatar
Krock
Developer
 
Posts: 4481
Joined: Thu Oct 03, 2013 07:48
Location: Switzerland
GitHub: SmallJoker

Re: Post your modding questions here

by Krock » Wed Jul 23, 2014 08:54

UtahTeapot wrote:Title: How can I change the default font?
I've saw people change their default font, i wanna do it myself!

OffT: Hi! I'm new here!

Addition for builds without freetype:
https://github.com/minetest/minetest/bl ... s.cpp#L181

Code: Select all
font_path = fonts/fontlucida.png
mono_font_path = fonts/fontdejavusansmono.png
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>
 

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 » Sun Jul 27, 2014 15:01

Itemstacks ARE userdata objects. Userdata objects can have methods associated with them. Try some of the Itemstack methods (e.g. player:get_wielded_item():get_name()) on the returned userdata object and you should get what you expect from an Itemstack.[/quote]
Thanks. =)
 

TeTpaAka
Member
 
Posts: 141
Joined: Sat Dec 28, 2013 21:54

Re: Post your modding questions here

by TeTpaAka » Mon Jul 28, 2014 18:29

I have a question: When there are multiple minetest.register_on_generated() calls, which one is called first?
I mean, by combining multiple mods with map-manipulating calls, which mod sees the changes of the others?
 

User avatar
rubenwardy
Moderator
 
Posts: 6022
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Post your modding questions here

by rubenwardy » Mon Jul 28, 2014 19:01

It is a FIFO* stack. The first minetest.register_on_generated() call is run first, and then the second is etc.

This means mods see the changes of the mods loaded before it. Use depends.txt to force a mod to load before your mod.

* - First In First Out.
 

User avatar
Esteban
Member
 
Posts: 873
Joined: Sun Sep 08, 2013 13:26
Location: Somewhere in the Caribbean...
GitHub: Esteban-
IRC: Esteban
In-game: Esteban

Re: Post your modding questions here

by Esteban » Wed Jul 30, 2014 19:58

I am trying to finish an NPC, my question is how I can make that when you left-click the NPC it disappear and give me its spawner back? Here is the code:

+ Spoiler
 

User avatar
philipbenr
Member
 
Posts: 1688
Joined: Fri Jun 14, 2013 01:56
Location: United States
GitHub: philipbenr
IRC: philipbenr
In-game: robinspi

Re: Post your modding questions here

by philipbenr » Wed Jul 30, 2014 23:00

Topic: How to generate trees normally
--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=
Reason: I want to make a forest with birch trees/ oak trees
--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=
More info: I looked into farming_plus, and I saw that I could easily make saplings grow, and that I had no problem with that. But then I thought 'If I have saplings of birch or oak trees, then I will need a good birch/oak forest.' So, I need to be able to generate forests, thickets, and the like, mainly because I think the mod (for a subgame) I am making will not look good. Anybody able to explain how to do so? I can use a simple bit of code to get trees to spawn randomly, but that isn't good enough...

[Edit] I looked at plants_lib documentation, and it was rather complicated and helped my mind swim even more.
 

User avatar
HeroOfTheWinds
Member
 
Posts: 470
Joined: Wed Apr 23, 2014 23:16
Location: Hawaii
GitHub: HeroOfTheWinds
IRC: WindHero

Re: Post your modding questions here

by HeroOfTheWinds » Thu Jul 31, 2014 00:21

There are a few ways to go about this, and since mgv7 is not stable at the minute, I'll take the more catch-all approach. Lua Voxel Manipulator is the short answer. There are two ways to make forests via LVM:
1. Have it spawn special saplings that grow via abm 1 second after chunk gen, by placing premade schematics of the trees (save them with WorldEdit).
2. Have it use functions to procedurally generate the trees.

That there is the heart of it. You will also need to implement a simple for loop to search for the ground level at any given area, and see if it is of suitable material (e.g. default:dirt_with_grass). A small example could be like this:
Code: Select all
--make variables to condense the edges of the generated chunk
local x0 = minp.x
local x1 = maxp.x
local y0 = minp.y
local y1 = maxp.y
local z0 = minp.z
local z1 = maxp.z

--loop through the x and z planes first
for x = x0, x1 do
    for z = z0, z1 do
        --loop from the top to the bottom, and stop when the node isn't ground.
        for y = y1, y0, -1 do
            local vi = area:get_data(x,y,z)
            if data[vi] ~= c_air then
                --grab the index of y+1, place your tree generator or else call your function to gen the tree.  break afterward.
            end
        end
    end
end


Just a very rough idea. I left out the bits about initializing the LVM and closing it down, look at either paramat or my own mods to get an idea how to start and stop them.
Nam ex spatio, omnes res venire possunt.
Why let the ground limit you when you can reach for the sky?
Back to college now, yay for sophomore year schedules. :P
 

User avatar
philipbenr
Member
 
Posts: 1688
Joined: Fri Jun 14, 2013 01:56
Location: United States
GitHub: philipbenr
IRC: philipbenr
In-game: robinspi

Re: Post your modding questions here

by philipbenr » Thu Jul 31, 2014 00:38

Thanks. Will do.

I do wish mgv7 was stable and complete... :/ Oh well. c55 will work at his own pace.
 

User avatar
HeroOfTheWinds
Member
 
Posts: 470
Joined: Wed Apr 23, 2014 23:16
Location: Hawaii
GitHub: HeroOfTheWinds
IRC: WindHero

Re: Post your modding questions here

by HeroOfTheWinds » Thu Jul 31, 2014 00:50

philipbenr wrote:Thanks. Will do.

I do wish mgv7 was stable and complete... :/ Oh well. c55 will work at his own pace.

Happy to help. :)

So do I.... Also, it's hmmm's jurisdiction, I believe, not c55's.
Nam ex spatio, omnes res venire possunt.
Why let the ground limit you when you can reach for the sky?
Back to college now, yay for sophomore year schedules. :P
 

User avatar
philipbenr
Member
 
Posts: 1688
Joined: Fri Jun 14, 2013 01:56
Location: United States
GitHub: philipbenr
IRC: philipbenr
In-game: robinspi

Re: Post your modding questions here

by philipbenr » Thu Jul 31, 2014 01:39

@ HeroOfTheWinds: I heard that it was c55 (I think from paramat...). It may be both.
 

User avatar
paramat
Developer
 
Posts: 3580
Joined: Sun Oct 28, 2012 00:05
Location: UK
GitHub: paramat
IRC: paramat

Re: Post your modding questions here

by paramat » Thu Jul 31, 2014 14:30

Mgv7 is entirely hmmmm / kwolekr's work. He was recently trying to rewrite it but is frustrated with the difficult progress so is taking a break from mapgen (i can confirm it drives you crazy very quickly, it's common to waste 2 days of full time work adjusting parameters, generating huge amounts of terrain and not getting anywhere), he's also going through 'real life' stuff too like illness. So don't expect anything soon. Celeron55 wants to work on the 3D noise mgv5 of MT 0.3.0 and re-introduce that into Minetest.
 

User avatar
philipbenr
Member
 
Posts: 1688
Joined: Fri Jun 14, 2013 01:56
Location: United States
GitHub: philipbenr
IRC: philipbenr
In-game: robinspi

Re: Post your modding questions here

by philipbenr » Thu Jul 31, 2014 19:34

Okay... Kinda confused, I heard that c55 was doing work on something, but I wasn't sure what...
 

User avatar
addi
Member
 
Posts: 663
Joined: Thu Sep 20, 2012 03:16
Location: Black-Forest, Germany
GitHub: adrido

How does the Lua Table formspec works?

by addi » Fri Aug 01, 2014 06:31

How does the Lua Table formspec works?

How can i send that formspec to a player?
minetest.show_formspec(playername, formname, formspec)
seems not to work, it requires a string not a table?
 

User avatar
Bas080
Member
 
Posts: 398
Joined: Mon May 21, 2012 15:54
Location: Netherlands
GitHub: bas080
IRC: bas080
In-game: bas080

Re: Post your modding questions here

by Bas080 » Fri Aug 01, 2014 12:29

addi, that's because the formspec is defined with a string. The api documentation helped me. Also looking at mods that alter the player formspec should give you the solution.

https://github.com/minetest/minetest/bl ... i.txt#L922
 

PreviousNext

Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 10 guests