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.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?
Post your modding questions here
- HeroOfTheWinds
- Member
- Posts: 470
- Joined: Wed Apr 23, 2014 23:16
- GitHub: HeroOfTheWinds
- IRC: WindHero
- Location: Hawaii
Re: Pay Doors [please help]
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
Why let the ground limit you when you can reach for the sky?
Back to college now, yay for sophomore year schedules. :P
- 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]
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.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?
Re: Post your modding questions here
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.
clicker:get_wielded_item():take_item() - also don`t work.
Re: Pay Doors [please help]
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.Evergreen wrote: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.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?
I keep taking a look at the wiki though!
- 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]
I think some already did something like that. It's a lock and key door.Ackirb wrote: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.Evergreen wrote: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.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?
I keep taking a look at the wiki though!
Re: Pay Doors [please help]
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.
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.
How To Replace Nodes within a Radius
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
})
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
})
Re: Post your modding questions here
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
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
Re: Post your modding questions here
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.
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.
- Krock
- Developer
- Posts: 4650
- Joined: Thu Oct 03, 2013 07:48
- GitHub: SmallJoker
- Location: Switzerland
- Contact:
Re: Post your modding questions here
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>
Re: Post your modding questions here
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?
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?
- PilzAdam
- Member
- Posts: 4026
- Joined: Fri Jul 20, 2012 16:19
- GitHub: PilzAdam
- IRC: PilzAdam
- Location: Germany
Re: Post your modding questions here
Why don't you submit a pull request to my carts mod?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.
Re: Post your modding questions here
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.PIlzAdam wrote:Why don't you submit a pull request to my carts mod?
- PilzAdam
- Member
- Posts: 4026
- Joined: Fri Jul 20, 2012 16:19
- GitHub: PilzAdam
- IRC: PilzAdam
- Location: Germany
Re: Post your modding questions here
Oh, new PMs are rather invisible with this new forum software, sorry for not seeing them.Kilarin wrote: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.PIlzAdam wrote:Why don't you submit a pull request to my carts mod?
I probably have time to review your code at the next weekend.
Re: Post your modding questions here
Nothing to apologize for!PilzAdam wrote:sorry for not seeing them.
Thank you, I really appreciate the time taken. It takes a lot of time and work to review someone elses code.PilzAdam wrote:I probably have time to review your code at the next weekend.
Re: Post your modding questions here
I tried that as well, and no luck. I think it may be a problem with the functionsTopywo 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
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?
- Casimir
- Member
- Posts: 1206
- Joined: Fri Aug 03, 2012 16:59
- GitHub: CasimirKaPazi
Re: Post your modding questions here
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
Re: Post your modding questions here
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?
Also, can you help me with the mod for adding a hungerbar to the world?
- 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
If it works it might be slow with a radius of 1000, 'find node near' is very slow even with a small radius.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
})
Re: Post your modding questions here
viewtopic.php?f=11&t=572Daven 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?
You can find most mods under Mod Releases, the most common used ones on the first pages.
Re: How To Replace Nodes within a Radius
Hmmm - good to know. Any other suggestions?paramat wrote:If it works it might be slow with a radius of 1000, 'find node near' is very slow even with a small radius.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
})
- Krock
- Developer
- Posts: 4650
- Joined: Thu Oct 03, 2013 07:48
- GitHub: SmallJoker
- Location: Switzerland
- Contact:
Re: How To Replace Nodes within a Radius
Try voxelmanip, maybe it's faster.Ackirb wrote:Hmmm - good to know. Any other suggestions?
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>
Re: Post your modding questions here
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,
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,
- Hybrid Dog
- Member
- Posts: 2828
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
I don't know exactly, I think the locked_chest does something with something like on_inventory_put.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.
Re: Post your modding questions here
I'll look at that, thank you.
Next stupid question. I've got a formspec that previously had a dropdown and a button:
And I want to change it to a textlist:
Now, using the dropdown code, I'm able to run minetest.register_on_player_receive_fields
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>
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]"
Code: Select all
"textlist[0,1.5;5,8;bookmark_list;"..list..";1]"..
"button[0,6.3;5,1;find_bookmark;find selected bookmark]"
Code: Select all
if fields["find_bookmark"] then
compass.find_bookmark(name, fields["bookmark_list"])
end
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>
Who is online
Users browsing this forum: No registered users and 6 guests