Post your modding questions here

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

Re: Pay Doors [please help]

by HeroOfTheWinds » Post

Ackirb wrote:I would like to create a "pay door". Basically, it can only be opened if a player inserts a specified item into it (eg - they would right-click on the door, and an inventory would open. The player would add 10 cobble stone blocks to this inventory (for example), and then the door would open).

Any ideas on how I could do this?
Have a function that opens the door, then have the actual door node have a callback for on_metadata_inventory_put that checks the ItemStack being placed in the door's inventory to see if it matches the door's payment criteria, and if so, calls the door opening function.
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
Evergreen
Member
Posts: 2135
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen
Location: A forest in the midwest
Contact:

Re: Pay Doors [please help]

by Evergreen » Post

Ackirb wrote:I would like to create a "pay door". Basically, it can only be opened if a player inserts a specified item into it (eg - they would right-click on the door, and an inventory would open. The player would add 10 cobble stone blocks to this inventory (for example), and then the door would open).

Any ideas on how I could do this?
We can't really write a mod for you. Look on http://dev.minetest.net/Main_Page for modding stuff. Also, default code is your friend. In your case, I would look at the chest code in minetest_game, and the door code. I would also look at formspecs on the minetest dev wiki.

User avatar
Pavel_S
Member
Posts: 131
Joined: Sat Apr 06, 2013 11:43

Re: Post your modding questions here

by Pavel_S » Post

I have a trouble. I use "local item = clicker:get_wielded_item()" in on_rightclick entity callback and then "item:take_item()", but it don`t work. the item is on it`t place. What I do wrong?
clicker:get_wielded_item():take_item() - also don`t work.

User avatar
Ackirb
Member
Posts: 23
Joined: Thu Mar 27, 2014 21:01
Location: United States

Re: Pay Doors [please help]

by Ackirb » Post

Evergreen wrote:
Ackirb wrote:I would like to create a "pay door". Basically, it can only be opened if a player inserts a specified item into it (eg - they would right-click on the door, and an inventory would open. The player would add 10 cobble stone blocks to this inventory (for example), and then the door would open).

Any ideas on how I could do this?
We can't really write a mod for you. Look on http://dev.minetest.net/Main_Page for modding stuff. Also, default code is your friend. In your case, I would look at the chest code in minetest_game, and the door code. I would also look at formspecs on the minetest dev wiki.
Of course not. I'm just a bit stumped. I am semi-familiar with how to create inventories for items (such as chests), and I'm quite familiar with the code for doors. Based on that, I could make a door that also functions as a chest lol. But I just can't seem to figure out how to make the door look for a specific item in its inventory, and only open when said item is present.

I keep taking a look at the wiki though!

User avatar
Evergreen
Member
Posts: 2135
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen
Location: A forest in the midwest
Contact:

Re: Pay Doors [please help]

by Evergreen » Post

Ackirb wrote:
Evergreen wrote:
Ackirb wrote:I would like to create a "pay door". Basically, it can only be opened if a player inserts a specified item into it (eg - they would right-click on the door, and an inventory would open. The player would add 10 cobble stone blocks to this inventory (for example), and then the door would open).

Any ideas on how I could do this?
We can't really write a mod for you. Look on http://dev.minetest.net/Main_Page for modding stuff. Also, default code is your friend. In your case, I would look at the chest code in minetest_game, and the door code. I would also look at formspecs on the minetest dev wiki.
Of course not. I'm just a bit stumped. I am semi-familiar with how to create inventories for items (such as chests), and I'm quite familiar with the code for doors. Based on that, I could make a door that also functions as a chest lol. But I just can't seem to figure out how to make the door look for a specific item in its inventory, and only open when said item is present.

I keep taking a look at the wiki though!
I think some already did something like that. It's a lock and key door.

User avatar
Ackirb
Member
Posts: 23
Joined: Thu Mar 27, 2014 21:01
Location: United States

Re: Pay Doors [please help]

by Ackirb » Post

Of course not. I'm just a bit stumped. I am semi-familiar with how to create inventories for items (such as chests), and I'm quite familiar with the code for doors. Based on that, I could make a door that also functions as a chest lol. But I just can't seem to figure out how to make the door look for a specific item in its inventory, and only open when said item is present.

I keep taking a look at the wiki though![/quote]
I think some already did something like that. It's a lock and key door.[/quote]

They did. If you have a key in your inventory, you can open the door.
But what I want is for the door itself to have an inventory. You open this inventory and add a specified item(s), and then the door will open.

User avatar
Ackirb
Member
Posts: 23
Joined: Thu Mar 27, 2014 21:01
Location: United States

How To Replace Nodes within a Radius

by Ackirb » Post

Hello
I am looking to create a block that replaces a certain block with another one within a radius.
For example, it would replace all of the "default:wood" blocks with "default:stone" within a 100-node radius of itself.

This is what I have, but it doesn't work. Any ideas? (feel free to completely scrap what I have if necessary)

minetest.register_abm({
nodenames = "forcefield:switch_on",
interval = 1,
chance = 1,
action = function(pos, nodenames)
local obj = minetest.find_node_near(pos, 1000, "forcefield:forcefield") --trying to replace this node
minetest.set_node(obj, "forcefield:forcefield_on") --with this one
end
})

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

Re: Post your modding questions here

by Topywo » Post

nodenames = "forcefield:switch_on",

Not sure if this is causing it not to work, but I place brackets (or however those are called) around the nodenames:

nodenames = {"forcefield:switch_on"},



Edit: Typo

User avatar
Kilarin
Member
Posts: 894
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

Re: Post your modding questions here

by Kilarin » Post

I've got a fork of PilzAdam's cart mod that I want to publish as cartsplus. So I renamed everything from carts to cartsplus, and it works just fine. BUT, I'd like to make it so that when you include the cartsplus mod, all carts created under the old carts mod (carts:cart) become cartsplus carts (cartsplus:cartplus)

From some advice I thought that minetest.register_alias("name", "convert_to") would do this. so I put at the top of the cartsplus init.lua:

minetest.register_alias("carts:cart", "cartsplus:cartplus")

But... it does nothing. old carts in the game or your inventory still run the old carts code and do not stack with new carts. Creative inventory shows two types of carts. new carts work fine, but the old carts still work as old carts.

So, am I misunderstanding what register_alias is supposed to do, or am I just using it incorrectly? Or does it only work with nodes, not entities?

Thanks in advance for your help.

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

Re: Post your modding questions here

by Krock » Post

Code: Select all

minetest.register_node("mymod:name_is_too_long", def)
minetest.register_alias("mymod:name_is_too_long", "nameistoolong")

/giveme nameistoolong
Added mymod:name_is_too_long to the inventory.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
Kilarin
Member
Posts: 894
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

Re: Post your modding questions here

by Kilarin » Post

Krock: Thanks for the attempt, but I'm not certain I understand how to apply that to overriding the cart entity. Sometimes I'm a bit slow. :)

This:

minetest.register_alias("carts:touringrail", "cartsplus:touringrail")

works fine. But carts:touringrail is no longer defined. Aliasing it to cartsplus:touringrail makes any touringrails that were defined when they were in the carts mod work great. BUT, attempting to override the existing carts:cart chokes. Is it impossible to use register_alias to override an existing entity in another mod?

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

Re: Post your modding questions here

by PilzAdam » Post

Kilarin wrote:I've got a fork of PilzAdam's cart mod that I want to publish as cartsplus. So I renamed everything from carts to cartsplus, and it works just fine. BUT, I'd like to make it so that when you include the cartsplus mod, all carts created under the old carts mod (carts:cart) become cartsplus carts (cartsplus:cartplus)

From some advice I thought that minetest.register_alias("name", "convert_to") would do this. so I put at the top of the cartsplus init.lua:

minetest.register_alias("carts:cart", "cartsplus:cartplus")

But... it does nothing. old carts in the game or your inventory still run the old carts code and do not stack with new carts. Creative inventory shows two types of carts. new carts work fine, but the old carts still work as old carts.

So, am I misunderstanding what register_alias is supposed to do, or am I just using it incorrectly? Or does it only work with nodes, not entities?

Thanks in advance for your help.
Why don't you submit a pull request to my carts mod?

User avatar
Kilarin
Member
Posts: 894
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

Re: Post your modding questions here

by Kilarin » Post

PIlzAdam wrote:Why don't you submit a pull request to my carts mod?
Would LOVE to, I PM'd you about whether you were interested in the changes and didn't get a response, so I thought you weren't interested. I'll figure out how to do a pull and execute it today.

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

Re: Post your modding questions here

by PilzAdam » Post

Kilarin wrote:
PIlzAdam wrote:Why don't you submit a pull request to my carts mod?
Would LOVE to, I PM'd you about whether you were interested in the changes and didn't get a response, so I thought you weren't interested. I'll figure out how to do a pull and execute it today.
Oh, new PMs are rather invisible with this new forum software, sorry for not seeing them.
I probably have time to review your code at the next weekend.

User avatar
Kilarin
Member
Posts: 894
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

Re: Post your modding questions here

by Kilarin » Post

PilzAdam wrote:sorry for not seeing them.
Nothing to apologize for!
PilzAdam wrote:I probably have time to review your code at the next weekend.
Thank you, I really appreciate the time taken. It takes a lot of time and work to review someone elses code.

User avatar
Ackirb
Member
Posts: 23
Joined: Thu Mar 27, 2014 21:01
Location: United States

Re: Post your modding questions here

by Ackirb » Post

Topywo wrote:nodenames = "forcefield:switch_on",

Not sure if this is causing it not to work, but I place brackets (or however those are called) around the nodenames:

nodenames = {"forcefield:switch_on"},



Edit: Typo
I tried that as well, and no luck. I think it may be a problem with the functions

minetest.register_abm({
nodenames = "forcefield:switch_on",
interval = 1,
chance = 1,
action = function(pos, nodenames)
local obj = minetest.find_node_near(pos, 1000, "forcefield:forcefield") --trying to replace this node
minetest.set_node(obj, "forcefield:forcefield_on") --with this one
end
})

I know that minetest.find_node_near returns a list of positions of the indicated nodes. As you can see, I am using that as a variable (obj), and plugging it into minetest.set_node.
Normally, the parameter for minetest.set_node is (pos, nodename). But I substituted pos with the obj variable....
is that why it won't work?

User avatar
Casimir
Member
Posts: 1206
Joined: Fri Aug 03, 2012 16:59
GitHub: CasimirKaPazi

Re: Post your modding questions here

by Casimir » Post

nodenames is a table, so it must have brackets, even if there is only one element. In your function I think the problem is with set_node. Try this:

Code: Select all

local pos_found = minetest.find_node_near(pos, 1000, "forcefield:forcefield") --trying to replace this node
minetest.set_node(pos_found, {name="forcefield:forcefield_on"}) --with this one

Daven
Member
Posts: 26
Joined: Mon Jan 20, 2014 21:51
Location: Inside the white whale

Re: Post your modding questions here

by Daven » Post

Can someone please post a link to the worldedit mod? It would be really helpful. Thanks.
Also, can you help me with the mod for adding a hungerbar to the world?

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

Re: How To Replace Nodes within a Radius

by paramat » Post

Ackirb wrote:minetest.register_abm({
nodenames = "forcefield:switch_on",
interval = 1,
chance = 1,
action = function(pos, nodenames)
local obj = minetest.find_node_near(pos, 1000, "forcefield:forcefield") --trying to replace this node
minetest.set_node(obj, "forcefield:forcefield_on") --with this one
end
})
If it works it might be slow with a radius of 1000, 'find node near' is very slow even with a small radius.

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

Re: Post your modding questions here

by Topywo » Post

Daven wrote:Can someone please post a link to the worldedit mod? It would be really helpful. Thanks.
Also, can you help me with the mod for adding a hungerbar to the world?
viewtopic.php?f=11&t=572

You can find most mods under Mod Releases, the most common used ones on the first pages.

User avatar
Ackirb
Member
Posts: 23
Joined: Thu Mar 27, 2014 21:01
Location: United States

Re: How To Replace Nodes within a Radius

by Ackirb » Post

paramat wrote:
Ackirb wrote:minetest.register_abm({
nodenames = "forcefield:switch_on",
interval = 1,
chance = 1,
action = function(pos, nodenames)
local obj = minetest.find_node_near(pos, 1000, "forcefield:forcefield") --trying to replace this node
minetest.set_node(obj, "forcefield:forcefield_on") --with this one
end
})
If it works it might be slow with a radius of 1000, 'find node near' is very slow even with a small radius.
Hmmm - good to know. Any other suggestions?

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

Re: How To Replace Nodes within a Radius

by Krock » Post

Ackirb wrote:Hmmm - good to know. Any other suggestions?
Try voxelmanip, maybe it's faster.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
Kilarin
Member
Posts: 894
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

Re: Post your modding questions here

by Kilarin » Post

So, I'm working on my own variation of TeTpaAka's awsome variation of Echo's really cool compass mod.

In order to update the compass, the original mod does a register_globalstep. But, if I am understanding this, the globastep just keeps running every cycle no matter what. If you take the compass out of your active inventory and drop it into your main inventory, the globalstep keeps running. If you put the compass into a chest and leave the region, the globalstep keeps running.

I'd LIKE for the globalstep to only run when the compass in in your active inventory. No reason to have it sucking cpu cycles when the compass isnt where you could see it. BUT, it seems to me that doing a scan at the top of the global step to see if your active inventory contains the compass would actually eat up more cpu than just leaving it as is.

Is there any way to trigger a function whenever an item is MOVED within inventory? That way I could check to see if the compass is in active inventory only when you move it, and turn off the globalstep if its not, and turn it back on if it is.

Thanks,

User avatar
Hybrid Dog
Member
Posts: 2828
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

Re: Post your modding questions here

by Hybrid Dog » Post

Kilarin wrote:Is there any way to trigger a function whenever an item is MOVED within inventory? That way I could check to see if the compass is in active inventory only when you move it, and turn off the globalstep if its not, and turn it back on if it is.
I don't know exactly, I think the locked_chest does something with something like on_inventory_put.

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪

User avatar
Kilarin
Member
Posts: 894
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

Re: Post your modding questions here

by Kilarin » Post

I'll look at that, thank you.

Next stupid question. I've got a formspec that previously had a dropdown and a button:

Code: Select all

"dropdown[0,1.5;8;bookmark_list;"..list..";0]"..
"button[0,2.3;5,1;find_bookmark;find selected bookmark]"
And I want to change it to a textlist:

Code: Select all

"textlist[0,1.5;5,8;bookmark_list;"..list..";1]"..
"button[0,6.3;5,1;find_bookmark;find selected bookmark]"
Now, using the dropdown code, I'm able to run minetest.register_on_player_receive_fields

Code: Select all

if fields["find_bookmark"] then
  compass.find_bookmark(name, fields["bookmark_list"]) 
end
And it works just fine. But when I switch to textlist, my formspec comes up and looks great, and I'm able to select a bookmark and click on "find", but in register_on_player_recieve_fields, while the find_bookmark button is set, bookmark_list is nil.

Doesn't textlist return the value selected in it the same as dropdown does?

Thanks,

Edit: Figured a few things out since I posted the question
textlist fires as soon as you click on any element in the list, dropdown does NOT return it's results until you have clicked a button.
dropdown returns the actual string selected, textlist returns CHG:<index of item selected>

Locked

Who is online

Users browsing this forum: No registered users and 6 guests