Post your modding questions here

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

Re: Post your modding questions here

by Krock » Sat Nov 08, 2014 07:26

Linuxdirk wrote:If I try to use that it crashes with attempt to index global 'player' (a nil value) for the line containing player:hud_change().

Complete code:

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
minetest.register_on_joinplayer(function(player)
    -- Delay a bit.
    minetest.after(1, function()
        hud_id = player:hud_add({
                ....
        })
    end)


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
<snip>
07:46:25: ERROR[main]: ServerError: /home/dirk/.minetest/mods/lp/init.lua:16: attempt to index global 'player' (a nil value)
<snip>

You need the player in your function!
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
    minetest.after(1, function(player)
        hud_id = player:hud_add({
                ....
        })
    end, player)
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
Linuxdirk
Member
 
Posts: 497
Joined: Wed Sep 17, 2014 11:21
GitHub: dsohler
In-game: Linuxdirk

Re: Post your modding questions here

by Linuxdirk » Sat Nov 08, 2014 07:41

Krock wrote:You need the player in your function!

hud_add works as expected. Adding player at the location you implied does not change anything in functionality. It still crashes with same error message.

Can you alter and re-post my complete code to make 100 percent clear what change at what location you’re talking about?
 

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

Re: Post your modding questions here

by Krock » Sat Nov 08, 2014 07:44

Linuxdirk wrote:
Krock wrote:You need the player in your function!

hud_add works as expected. Adding player at the location you implied does not change anything in functionality. It still crashes with same error message.

Well, you have to do the same with the function "changeText()":

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 changeText(player)
    player:hud_change(hud_id, 'text', 'Changed text')
    minetest.after(5, changeText, player)
end

-- This line is not valid because there is no player available in the current context
minetest.after(5, changeText, player)
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
Linuxdirk
Member
 
Posts: 497
Joined: Wed Sep 17, 2014 11:21
GitHub: dsohler
In-game: Linuxdirk

Re: Post your modding questions here

by Linuxdirk » Sat Nov 08, 2014 08:53

Krock wrote:Well, you have to do the same with the function "changeText()"

Please re-post my code with your proposed changes. I added player in all locations you implied (but never clearly stated). Still crashes after 5 seconds.
 

User avatar
Topywo
Member
 
Posts: 1718
Joined: Fri May 18, 2012 20:27

Re: Post your modding questions here

by Topywo » Sat Nov 08, 2014 09:27

Superdude44 wrote:It lets me in game now, but the gui does not pop up. I guess my ultimate question would be how I would get that to show up?



I created a folder aoe. Created a depends.txt with default in it and created an init.lua with your code in it:

Image

Did you place a new townblock to try out your last changes? Old(er) blocks with formspecs keep their older code. To see changes in the code you made, you must place a new formspec block and open it.
 

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

Re: Post your modding questions here

by Krock » Sat Nov 08, 2014 09:28

Linuxdirk wrote:Please re-post my code with your proposed changes.


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
minetest.register_on_joinplayer(function(player)
    -- Delay a bit.
    minetest.after(1, function(player)
        local hud_id = player:hud_add({
            hud_elem_type = 'text',
            position = {x=1, y=0},
            alignment = {x=-1, y=1},
            text = 'First text',
            number = 0xFFFFFF,
            offset = {x=-4, y=4}
        }, player)
        minetest.after(5, changeText, player, hud_id)
    end)
end)

function changeText(player, hud_id)
    player:hud_change(hud_id, 'text', 'Changed text')
    minetest.after(5, changeText, player, hud_id)
end


I hope it's correct now.
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
Linuxdirk
Member
 
Posts: 497
Joined: Wed Sep 17, 2014 11:21
GitHub: dsohler
In-game: Linuxdirk

Re: Post your modding questions here

by Linuxdirk » Sat Nov 08, 2014 09:34

Krock wrote:I hope it's correct now.

No, now it instantly crashes instead of after 5 seconds.

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
10:32:47: ACTION[ServerThread]: singleplayer leaves game. List of players:
10:32:47: ERROR[main]: ServerError: /home/dirk/.minetest/mods/lp/init.lua:4: attempt to index local 'player' (a nil value)
10:32:47: ERROR[main]: stack traceback:
10:32:47: ERROR[main]:    /home/dirk/.minetest/mods/lp/init.lua:4: in function 'func'
10:32:47: ERROR[main]:    /usr/share/minetest/builtin/game/misc.lua:17: in function '?'
10:32:47: ERROR[main]:    /usr/share/minetest/builtin/game/register.lua:348: in function </usr/share/minetest/builtin/game/register.lua:336>
 

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

Re: Post your modding questions here

by Krock » Sat Nov 08, 2014 09:47

Linuxdirk wrote:
Krock wrote:I hope it's correct now.

No, now it instantly crashes instead of after 5 seconds.

<snip>

Haha. Coded way too fast and added the ', player' to the wrong function.
If you would look at it, you can find this error self:
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
            offset = {x=-4, y=4}
        }) -- Remove ', player'
        minetest.after(5, changeText, player, hud_id)
    end, player) -- Add ', player'
end)
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
Linuxdirk
Member
 
Posts: 497
Joined: Wed Sep 17, 2014 11:21
GitHub: dsohler
In-game: Linuxdirk

Re: Post your modding questions here

by Linuxdirk » Sat Nov 08, 2014 09:53

Krock wrote:If you would look at it, you can find this error self:

I did and added player as described before. Weird … But finally it works! Thanks for your support! :)
 

User avatar
Nathan.S
Member
 
Posts: 679
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21

Re: Post your modding questions here

by Nathan.S » Sat Nov 08, 2014 16:35

I'm probably missing something obvious, but I'm trying to make a function for a lighter. I have two objects that can be lit, and both of them should result in different fires. I'm running a random number generator and if I get the right number then I want to start the node on fire, actually just call a swap_node. I can't seem to get it to work though. I've tried googleing, but I'm not really sure what to look for. I've tried replacing the and with if and elseif but it makes no difference.
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 burn(pointed_thing) --kindling doesn't always start from the first spark
   ignite_chance = math.random(10)
   if ignite_chance == 1
      and string.find(minetest.get_node(pointed_thing.under).name, 'more_fire:kindling')
      then
         minetest.env:swap_node(pointed_thing.under, {name = 'more_fire:campfire'})
      and string.find(minetest.get_node(pointed_thing.under).name, 'more_fire:kindling_contained')
      then
         minetest.env:swap_node(pointed_thing.under, {name = 'more_fire:contained_fire'})
   else --do nothing
   end
end


never mind I figured it out with help from the flint and steel part of homedecor.
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 burn(pointed_thing) --kindling doesn't always start from the first spark
   ignite_chance = math.random(10)
   if ignite_chance == 1
      and string.find(minetest.get_node(pointed_thing.under).name, 'more_fire:kindling_contained')
      then
         minetest.env:swap_node(pointed_thing.under, {name = 'more_fire:contained_fire'})
   elseif ignite_chance == 1
      and string.find(minetest.get_node(pointed_thing.under).name, 'more_fire:kindling')
      then
         minetest.env:swap_node(pointed_thing.under, {name = 'more_fire:campfire'})

   else --do nothing
   end
end
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website.
 

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 Nov 08, 2014 17:31

By the way, please don't use `minetest.env:xxx(yyy)` as it is deprecated and may be removed in the future. Use `minetest.xxx(yyy)` instead.
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
Nathan.S
Member
 
Posts: 679
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21

Re: Post your modding questions here

by Nathan.S » Sat Nov 08, 2014 18:11

kaeza wrote:By the way, please don't use `minetest.env:xxx(yyy)` as it is deprecated and may be removed in the future. Use `minetest.xxx(yyy)` instead.


Good to know, I'll change that in my code ASAP.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website.
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Sat Nov 08, 2014 21:32

kaeza wrote:By the way, please don't use `minetest.env:xxx(yyy)` as it is deprecated and may be removed in the future. Use `minetest.xxx(yyy)` instead.

Can I use core.xxx(yyy), too?
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

Re: Post your modding questions here

by 4aiman » Sat Nov 08, 2014 21:36

I believe you can't.
 

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 Nov 08, 2014 21:45

Hybrid Dog wrote:Can I use core.xxx(yyy), too?

The `core` namespace is internal/private to the engine. It was never made "public", so no. (I don't know the reason for using that namespace internally and not `minetest` directly)
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
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Sat Nov 08, 2014 22:11

I thought that there it's made public and minetest = core but core wasn't defined in the file
https://github.com/minetest/minetest/co ... 1a8eaa4241
 

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 » Mon Nov 10, 2014 19:08

How would .mts schematics be placed randomly? With perlin noise or some other way? I have some schematics I want to be placed randomly throughout the world on grass.
 

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

Re: Post your modding questions here

by Krock » Mon Nov 10, 2014 19:58

philipbenr wrote:How would .mts schematics be placed randomly? With perlin noise or some other way? I have some schematics I want to be placed randomly throughout the world on grass.

You can use Perlin Noise and only check every Xth node if there should be a house or not. Otherwise..well, you'll see what happens.

The 2nd way is to use math.random(), but buildings could collide there aswell.
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 » Mon Nov 10, 2014 22:00

Krock wrote:
philipbenr wrote:How would .mts schematics be placed randomly? With perlin noise or some other way? I have some schematics I want to be placed randomly throughout the world on grass.

You can use Perlin Noise and only check every Xth node if there should be a house or not. Otherwise..well, you'll see what happens.

The 2nd way is to use math.random(), but buildings could collide there aswell.


I think I will use math.random, because I am placing trees, not houses.
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

Re: Post your modding questions here

by Sokomine » Tue Nov 11, 2014 03:21

fireuser wrote:i'm struggling with minetest map gen. I would love it if some one could help me with making land flatter. I've seen it totally flat,but i don't like that. so if you could help me with this,i would be so grateful. Thanks!

Best talk to Krock. He's using mapgen parameters on his server which create a relatively (but not absolutely) flat map.

philipbenr wrote:How would .mts schematics be placed randomly? With perlin noise or some other way? I have some schematics I want to be placed randomly throughout the world on grass.

If you're using mapgen v7, you can let the mapgen do most of the work. If you're placing the schematics manually, try to use pseudorandom or something else that's reproducable in order to avoid situations where parts of your map are created using diffrent parameters.
A list of my mods can be found 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 » Tue Nov 11, 2014 04:07

I suppose I will have to write my own v7 magpen. I was hoping I didn't have to, but oh well. If it is easy to do the schematic placing, then why the heck not?

Edit: Got any good references other than paramat's magpens / Yappy?
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

Re: Post your modding questions here

by Sokomine » Tue Nov 11, 2014 04:13

philipbenr wrote:I suppose I will have to write my own v7 magpen. I was hoping I didn't have to, but oh well. If it is easy to do the schematic placing, then why the heck not?

Take a look at the earlier versions of Ethereal (less complex than later versions). The mod uses mapgen v7, and all the structures (trees, vulcanoes, mushrooms, ...) are schematics which are placed automaticly depending on the biome.
A list of my mods can be found here.
 

Amaz
Member
 
Posts: 328
Joined: Wed May 08, 2013 08:26
GitHub: Amaz1
IRC: Amaz
In-game: Amaz

Re: Post your modding questions here

by Amaz » Tue Nov 11, 2014 09:12

philipbenr wrote:I suppose I will have to write my own v7 magpen. I was hoping I didn't have to, but oh well. If it is easy to do the schematic placing, then why the heck not?

Edit: Got any good references other than paramat's magpens / Yappy?


Here is some example code (With comments) that places schematics in mapgens 7 and 5: https://gist.github.com/Amaz1/54ad76374316e98660fa
Here is some code (Again, with comments) that defines biomes for mgv5&7: https://gist.github.com/Amaz1/eee1efcbf6c483d0e03f

And then there are the dev wiki pages for biomes and decorations: http://dev.minetest.net/minetest.register_biome & http://dev.minetest.net/minetest.register_decoration

Hope this helps!
 

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 » Tue Nov 11, 2014 17:09

Thanks Sokomine and Amaz. This probably will get things off the ground.
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Tue Nov 11, 2014 17:36

Are the .mts and .we schematics the same?
 

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 » Tue Nov 11, 2014 18:47

Apparently, no. You can convert them yes, but they are not the same.
 

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

Re: Post your modding questions here

by Krock » Tue Nov 11, 2014 19:14

Sokomine wrote:Best talk to Krock. He's using mapgen parameters on his server which create a relatively (but not absolutely) flat map.

Bad idea. Changing the mapgen params wrongly can cause huge oceans and almost no space for building.
For this I made the yappy mapgen, it creates much flat area and also some hills as a variety.
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
Nathan.S
Member
 
Posts: 679
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21

Re: Post your modding questions here

by Nathan.S » Wed Nov 12, 2014 17:38

I know I can do something like this with node_boxes
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
node_box = {
      type = "wallmounted",
      wall_top    = {-0.0625, -0.0625, -0.0625, 0.0625, 0.5   , 0.0625},
      wall_bottom = {-0.0625, -0.5   , -0.0625, 0.0625, 0.0625, 0.0625},
      wall_side   = {-0.5   , -0.5   , -0.0625, -0.375, 0.0625, 0.0625},
   },


I want to do the same with meshes, I believe that RBA added support a while back. https://github.com/minetest/minetest/commit/dd4c21c1808acedfbcf8402c09ce9129b6ac31c7 but I can't find any documentation on it. I've tried just replacing the tables of numbers to the names of the meshes, and the game will run and I can place the torches, but nothing shows, save for the illumination.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website.
 

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

Re: Post your modding questions here

by Krock » Wed Nov 12, 2014 18:39

Nathan.S wrote:<snip> I believe that RBA added support a while back. <snip> but I can't find any documentation on it. <snip>

Here you can find a simple use of meshnodes:
https://github.com/RealBadAngel/meshnod ... r/init.lua
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
Nathan.S
Member
 
Posts: 679
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21

Re: Post your modding questions here

by Nathan.S » Wed Nov 12, 2014 18:45

Krock wrote:
Nathan.S wrote:<snip> I believe that RBA added support a while back. <snip> but I can't find any documentation on it. <snip>

Here you can find a simple use of meshnodes:
https://github.com/RealBadAngel/meshnod ... r/init.lua


Thanks, but I've already got that part figured out, it's the figuring out how to have two different models, or three, for the same node and the engine will place either the top, bottom, or side that's tripping me up.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website.
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 14 guests

cron