Post your modding questions here

User avatar
benrob0329
Member
 
Posts: 1192
Joined: Thu Aug 06, 2015 22:39
GitHub: Benrob0329
In-game: benrob03

Re: Post your modding questions here

by benrob0329 » Wed May 11, 2016 03:53

Thanks all, I'd tell you what in working on but I'm not sure how far I'll get with it.
If I do get something done, I'll be sure to post it though!
 

User avatar
stu
Member
 
Posts: 737
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11

Re: Post your modding questions here

by stu » Wed May 11, 2016 17:37

benrob0329 wrote:Not perfect, but MUCH better:

Along with the uv errors already pointed out, It looks to me as though the mesh is non-manifold, that can also cause some pretty strange visual effects in-game.
 

bidaian
New member
 
Posts: 3
Joined: Sat May 14, 2016 03:31

Re: Post your modding questions here

by bidaian » Sat May 14, 2016 03:44

Topic: How do I move a node?

After creating tutorial:decowood and reading about growing default:junglegrass I wanted to move decowood with this code. But nothing happens. What do I need to move a node?

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_abm({
        nodenames = {"tutorial:decowood"},
        interval = 10,
        chance = 1,
        action = function(pos)
                pos.y = pos.y + 1
        end,
})
 

User avatar
Foghrye4
Member
 
Posts: 24
Joined: Sun Mar 13, 2016 13:38
IRC: Foghrye4
In-game: Foghrye4

Re: Post your modding questions here

by Foghrye4 » Sat May 14, 2016 05:45

bidaian, "pos" table in function is just a copy of an information about actual node position. Changing it will do nothing. You need to delete node on a old position and add on a new. Check how to do it here: http://dev.minetest.net/Category:Methods
 

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

this should make it move upwards

by Hybrid Dog » Sat May 14, 2016 09:32

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_abm({
        nodenames = {"tutorial:decowood"},
        interval = 10,
        chance = 1,
        action = function(pos, node)
                pos.y = pos.y + 1
                if minetest.get_node(pos).name == "air" then
                       minetest.set_node(pos, node)
                       pos.y = pos.y - 1
                       minetest.remove_node(pos)
                end
        end,
})
 

bidaian
New member
 
Posts: 3
Joined: Sat May 14, 2016 03:31

Re: Post your modding questions here

by bidaian » Sat May 14, 2016 13:57

Foghrye4 wrote:bidaian, "pos" table in function is just a copy of an information about actual node position. Changing it will do nothing. You need to delete node on a old position and add on a new. Check how to do it here: http://dev.minetest.net/Category:Methods


Thanks. I wanted to do something that moved sheep-like and destroying and recreating sounded like a lot of work. But I guess I still have to learn a lot, maybe that's not simply a block. Anyway, it's great, with the decowood example, the wiki, the forum and the source of the other mods, lots of things can be done!
 

bidaian
New member
 
Posts: 3
Joined: Sat May 14, 2016 03:31

Re: this should make it move upwards

by bidaian » Sat May 14, 2016 14:00

Hybrid Dog wrote:
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_abm({
        nodenames = {"tutorial:decowood"},
        interval = 10,
        chance = 1,
        action = function(pos, node)
                pos.y = pos.y + 1
                if minetest.get_node(pos).name == "air" then
                       minetest.set_node(pos, node)
                       pos.y = pos.y - 1
                       minetest.remove_node(pos)
                end
        end,
})


It does, but in one iteration it goes as high as it can. It was on the ground one second and underneath the branches in the next move. I'll work on it. Thanks also for bringing up the relationship with the environment. I was ready to go through anything that was already there :).
 

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

Re: Post your modding questions here

by paramat » Sat May 14, 2016 23:53

xeranas wrote:How I can reset player skybox to default server? I want temporally change user skybox and then return to 'normal'.

https://github.com/paramat/moonrealm/blob/master/init.lua#L206
 

User avatar
everamzah
Member
 
Posts: 490
Joined: Thu Jan 29, 2015 00:47
GitHub: everamzah
IRC: everamzah
In-game: everamzah

Re: Post your modding questions here

by everamzah » Sun May 15, 2016 00:36

Is it possible to make modifications to an ItemStack using the on_take callback of a detached inventory?
 

User avatar
Foghrye4
Member
 
Posts: 24
Joined: Sun Mar 13, 2016 13:38
IRC: Foghrye4
In-game: Foghrye4

Re: Post your modding questions here

by Foghrye4 » Sun May 15, 2016 05:09

everamzah wrote:Is it possible to make modifications to an ItemStack using the on_take callback of a detached inventory?

Yes. Don't forget to call "set_stack("listname", i, stack)" with your modificated stack on receiver inventory.
 

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

Re: this should make it move upwards

by Hybrid Dog » Sun May 15, 2016 06:55

bidaian wrote:It does, but in one iteration it goes as high as it can. It was on the ground one second and underneath the branches in the next move. I'll work on it. Thanks also for bringing up the relationship with the environment. I was ready to go through anything that was already there :).

the code should actually make it move 1 m ("perform one iteration") every 10 seconds
time(P) = (log(P*chance)/log(1-1/chance)+1)*interval

interval = 10; chance = 1

time(P) = lim(chance → 1, (log(P*chance)/log(1-1/chance)+1)*10)
= lim(h → 0, (log(P*(h+1))/log(1-1/(h+1))+1)*10)
= 1*10 = 10 = interval

Maybe it works if you disable catch_up
 

User avatar
everamzah
Member
 
Posts: 490
Joined: Thu Jan 29, 2015 00:47
GitHub: everamzah
IRC: everamzah
In-game: everamzah

Re: Post your modding questions here

by everamzah » Sun May 15, 2016 12:22

Foghrye4 wrote:
everamzah wrote:Is it possible to make modifications to an ItemStack using the on_take callback of a detached inventory?

Yes. Don't forget to call "set_stack("listname", i, stack)" with your modificated stack on receiver inventory.


Thanks!! That was the trick, though I needed to use set_stack() in the allow_take callback, and not the on_take one.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: this should make it move upwards

by rubenwardy » Sun May 15, 2016 12:27

Hybrid Dog wrote:
bidaian wrote:It does, but in one iteration it goes as high as it can. It was on the ground one second and underneath the branches in the next move. I'll work on it. Thanks also for bringing up the relationship with the environment. I was ready to go through anything that was already there :).

the code should actually make it move 1 m ("perform one iteration") every 10 seconds
time(P) = (log(P*chance)/log(1-1/chance)+1)*interval

interval = 10; chance = 1

time(P) = lim(chance → 1, (log(P*chance)/log(1-1/chance)+1)*10)
= lim(h → 0, (log(P*(h+1))/log(1-1/(h+1))+1)*10)
= 1*10 = 10 = interval

Maybe it works if you disable catch_up


It's possible that it updates the same node multiple times in one abm run (as it is placed in a new position that may not have been run.)
 

User avatar
AnxiousInfusion
Member
 
Posts: 146
Joined: Sun Aug 02, 2015 05:43
GitHub: AnxiousInfusion[GitLab]
IRC: AnxiousInfusion
In-game: AnxiousInfusion

Re: Post your modding questions here

by AnxiousInfusion » Sun May 15, 2016 13:25

Hello, I'm trying to get player position to feed into add_item but there is little documentation outside of Rubenwardy's API reference so I'm somewhat stuck.

Is this even close to being correct?
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.add_item(player:getpos(), "mymod:myitem")


It returns the error: attempt to index global 'player' (a nil value)
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Post your modding questions here

by rubenwardy » Sun May 15, 2016 14:47

Take a look at this chapter: http://rubenwardy.com/minetest_modding_ ... ories.html

You don't store items at a player's position, you store them in a player.
 

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

by Hybrid Dog » Sun May 15, 2016 17:32

AnxiousInfusion, where do you use this code?
 

User avatar
AnxiousInfusion
Member
 
Posts: 146
Joined: Sun Aug 02, 2015 05:43
GitHub: AnxiousInfusion[GitLab]
IRC: AnxiousInfusion
In-game: AnxiousInfusion

Re:

by AnxiousInfusion » Sun May 15, 2016 18:23

rubenwardy wrote:Take a look at this chapter: http://rubenwardy.com/minetest_modding_ ... ories.html

You don't store items at a player's position, you store them in a player.


Your guide has been a thoroughly helpful tool but I have not communicated well what I am trying to achieve. I actually want the item to be dropped at the player's position and I have had some success with:
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
player = minetest.env:get_player_by_name("singleplayer")
minetest.add_item(player:getpos(), "mymod:myitem")

The only problem being "singleplayer" limits the mod to offline, solo use. Is there a more generic term I could use to refer to the player?

Hybrid Dog wrote:AnxiousInfusion, where do you use this code?


Please bear with me, I am learning the ropes at Minetest modding.
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Re:

by Don » Sun May 15, 2016 23:03

AnxiousInfusion wrote:
rubenwardy wrote:Take a look at this chapter: http://rubenwardy.com/minetest_modding_ ... ories.html

You don't store items at a player's position, you store them in a player.


Your guide has been a thoroughly helpful tool but I have not communicated well what I am trying to achieve. I actually want the item to be dropped at the player's position and I have had some success with:
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
player = minetest.env:get_player_by_name("singleplayer")
minetest.add_item(player:getpos(), "mymod:myitem")

The only problem being "singleplayer" limits the mod to offline, solo use. Is there a more generic term I could use to refer to the player?

env: is depreciated. You should remove it.
Without knowing the rest of the code it is hard to know what you are doing. Is this inside an abm or a certain function in a node? If you could post more code it would be much easier to help you.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Post your modding questions here

by rubenwardy » Sun May 15, 2016 23:10

Try

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.add_item(player:getpos(), ItemStack("mymod:myitem"))


mods are only run on the server side, there is no current player
 

User avatar
AnxiousInfusion
Member
 
Posts: 146
Joined: Sun Aug 02, 2015 05:43
GitHub: AnxiousInfusion[GitLab]
IRC: AnxiousInfusion
In-game: AnxiousInfusion

Re: Post your modding questions here

by AnxiousInfusion » Mon May 16, 2016 01:21

So a while back I decided to work toward the goal of producing a reasonable Star Ships mod. And with Lua being new territory to me, I knew I should start small so I pulled an all nighter and hammered out this rudimentary mod to wrap my head around the basics.

I'm still trying to understand how set_breath() can be used to decrement the bubbles bar, and how to bind a key to execute a function. Does Lua not allow this?
 

sofar
Member
 
Posts: 781
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Post your modding questions here

by sofar » Mon May 16, 2016 03:40

AnxiousInfusion wrote:I'm still trying to understand how set_breath() can be used to decrement the bubbles bar, and how to bind a key to execute a function. Does Lua not allow this?


As far as the keybindings, yes, mods can't override key bindings. You can find out if a player has pressed a standard movement key, but that's it.
 

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

by Hybrid Dog » Mon May 16, 2016 10:38

There are the functions minetest.on_key_press and minetest.on_key_release:
http://dev.minetest.net/User:Hybrid_Dog ... _functions
 

KCoombes
Member
 
Posts: 278
Joined: Thu Jun 11, 2015 23:19
In-game: Knatt or Rudilyn

Re: Post your modding questions here

by KCoombes » Tue May 17, 2016 10:31

Is it possible to add to/create new PlayerArgs via a mod, or will I have to edit the sourcecode?
 

User avatar
AnxiousInfusion
Member
 
Posts: 146
Joined: Sun Aug 02, 2015 05:43
GitHub: AnxiousInfusion[GitLab]
IRC: AnxiousInfusion
In-game: AnxiousInfusion

Re:

by AnxiousInfusion » Tue May 17, 2016 14:58

Hybrid Dog wrote:There are the functions minetest.on_key_press and minetest.on_key_release:
http://dev.minetest.net/User:Hybrid_Dog ... _functions


Hybrid, this is incredible and almost exactly what I had in mind. I hope it is okay if I copy/paste those register_on_key_ functions into my mod.
 

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

by Hybrid Dog » Wed May 18, 2016 15:30

thanks, the code is free to use (WTFPL)
Last edited by Hybrid Dog on Tue May 24, 2016 19:48, edited 1 time in total.
 

sofar
Member
 
Posts: 781
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Post your modding questions here

by sofar » Wed May 18, 2016 20:13

KCoombes wrote:Is it possible to add to/create new PlayerArgs via a mod, or will I have to edit the sourcecode?


We want to add this functionality to core, there are some proposals around to implement this:

https://github.com/minetest/minetest/pull/4139
 

User avatar
AnxiousInfusion
Member
 
Posts: 146
Joined: Sun Aug 02, 2015 05:43
GitHub: AnxiousInfusion[GitLab]
IRC: AnxiousInfusion
In-game: AnxiousInfusion

Re: Post your modding questions here

by AnxiousInfusion » Fri May 20, 2016 20:53

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
array = { initializingvalue = {0} }
math.randomseed(os.clock()*100000000000)
minetest.register_globalstep(function(dtime)
   for _, user in pairs(minetest.get_connected_players()) do
      item = user:get_player_name()
      array.item = array.item + dtime;


attempt to perform arithmetic on field 'item' (a nil value)

Paradox: I need to increment the "item" value in "array" every global step, but the first time through the loop won't work until "array.item" has a numeric value. If I assign an initial value, it won't increment for every step (this is a timer). What do?

EDIT: So sorry if I'm spamming up this thread... I have solved(?) the issue by using an if statement to test whether the array.item is nil or not and the timer is working now. Of course, if there is still a better way to be doing this please let me know.
 

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 » Fri May 20, 2016 21:43

AnxiousInfusion wrote:
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
array = { initializingvalue = {0} }
math.randomseed(os.clock()*100000000000)
minetest.register_globalstep(function(dtime)
   for _, user in pairs(minetest.get_connected_players()) do
      item = user:get_player_name()
      array.item = array.item + dtime;


attempt to perform arithmetic on field 'item' (a nil value)

Maybe you meant `array[item]`. The two are not the same.

The code `array.item` is equivalent to `array["item"]` (i.e. set an actual field named "item"), while `array[item]` sets the field referred to by the variable `item`, which holds the player name (which in your code is probably what you want).

Edit: Also, remember to declare variables local to the scope on which they are used. `item` is global in your case.

Edit 2: Also, please don't use `math.randomseed`; the engine already does that for you.
Finally, as a minor nitpick, you don't need semicolons at the end of statements :)
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
 

Godo
Member
 
Posts: 17
Joined: Mon May 02, 2016 06:41
In-game: Godo

Inventory items mixed up

by Godo » Sat May 21, 2016 10:33

Topic: inventory in creative mode
Reason: mismatched items (pop-up names) and icons.
More info: the pop-up names are correct, but the icons sometimes do not match them.

Hi, I hope I'm in the right forum, I have a problem with Minetest version 0.4.13, when playing Minetest game in creative mode the item icons in the inventory do not match the item descriptions (the pop-up names). For example, to select "glass" I have to click on the third icon on the top row of page 3, which shows the image of the furnace. On page 1 of the inventory, the first misplaced icons are the bookshelf and brick block, which seem to occupy each other's place. The next one (bronze ingot) is OK, then the last one (bronze block) shows what looks like a red brick block instead. From page 2 the mixed-up items are more abundant.

I was told in another forum that the order of items in the inventory is determined by the mod, so I can't fix it by hand. So how can I fix that?
Last edited by Godo on Tue May 24, 2016 16:34, edited 1 time in total.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Post your modding questions here

by rubenwardy » Sat May 21, 2016 10:43

Make sure you have the latest version of minetest, 0.4.14.

Does this happen in the normal inventory?
This sounds more like an Engine bug, rather than a mod bug.
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron