General Help
General Help
I wonder if there could be a thread where we can maybe share things we may know and help each other figure out how to do things. If people may have questions and other people may know things that may help. And stuff like that. Maybe this may be redundant, but I don't know.
Re: General Help
My question would be, I am wondering if it is possible to make it so if I place a specific object onto another specific object, if it can turn that object that it was placed on into a different specific object, and remove the object I placed from my inventory.
Re: General Help
A little code that creates a dirt block that turns into a diamond block when right-clicked with a gold block, or turns into a mese block when punched with sand :)
Code: Select all
minetest.register_node("test:dirt", {
description = "My Dirt",
tiles = {"default_dirt.png"},
groups = {crumbly = 3},
sounds = default.node_sound_dirt_defaults(),
on_punch = function(pos, node, puncher, pointed_thing)
local itemstack = puncher:get_wielded_item()
local item = itemstack:get_name()
if item == "default:sand" then
itemstack:take_item()
puncher:set_wielded_item(itemstack)
minetest.set_node(pos, {name = "default:mese"})
end
end,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local item = itemstack:get_name()
if item == "default:goldblock" then
itemstack:take_item()
minetest.set_node(pos, {name = "default:diamondblock"})
return itemstack
end
end
})
Re: General Help
Oh my goodness, it actually works. I would then ask if there is a way that I could rightclick it with an open hand and get a specific item from it, and change it into a different specific object at the same time. I may be able to take what has already been given and figure out how to do it on my own, but I'm not sure yet. Thank you very much.
I may just make it so it gives something when it is broken and make it breakable by hand and have it change into something else, if that is possible.
(I think I may have managed to figure it out.)
(Actually having a bit of difficulty with trying to make it work for stairs, but maybe you have helped enough, so it may be okay.)
(Pretty tough to figure out. Could maybe use some help. Also having trouble trying to change the textures of stairs.)
I may just make it so it gives something when it is broken and make it breakable by hand and have it change into something else, if that is possible.
(I think I may have managed to figure it out.)
(Actually having a bit of difficulty with trying to make it work for stairs, but maybe you have helped enough, so it may be okay.)
(Pretty tough to figure out. Could maybe use some help. Also having trouble trying to change the textures of stairs.)
Re: General Help
Do you think it is possible to make something that could make the grass grow on its own?
And is it also possible to make a headlamp? Important questions.
And is it also possible to make a headlamp? Important questions.
- Skamiz Kazzarch
- Member
- Posts: 618
- Joined: Fri Mar 09, 2018 20:34
- GitHub: Skamiz
- In-game: Skamiz
- Location: la lojbaugag.
Re: General Help
When asking if something 'is possible' in an open source engine the answer is pretty-much always going to be yes. The question is only how difficult it is to implement.
With this mod:https://github.com/mt-mods/illumination I think you only need to add light_source = 'whatever', to the armor piece definition to make it spread light when worn. Though I haven't tested it myself.
As for grass, do you mean tall grass just growing on dirt_with_grass, or do you mean a node which makes grass grow around itself? I am not sure from the question what you mean?
With this mod:https://github.com/mt-mods/illumination I think you only need to add light_source = 'whatever', to the armor piece definition to make it spread light when worn. Though I haven't tested it myself.
As for grass, do you mean tall grass just growing on dirt_with_grass, or do you mean a node which makes grass grow around itself? I am not sure from the question what you mean?
Re: General Help
I have tried to use the illumination and stuff and it doesn't seem to work that way. Only for items that are held in the hand and stuff.
The idea of the grass is that you have grass on dirt, and then over time you see small grass appear and then over more time the grass gets taller and until it reaches maximum height. And so you would have grass growing on its own on blocks with grass.
The idea of the grass is that you have grass on dirt, and then over time you see small grass appear and then over more time the grass gets taller and until it reaches maximum height. And so you would have grass growing on its own on blocks with grass.
- Skamiz Kazzarch
- Member
- Posts: 618
- Joined: Fri Mar 09, 2018 20:34
- GitHub: Skamiz
- In-game: Skamiz
- Location: la lojbaugag.
Re: General Help
Riiiight... . Except that the readme specifically mentions that it's compatible with '3d_armor' and I literally looked up the code bit in the code, where it checks all worn armor for the 'light_source' property. Link to armor checking function: https://github.com/mt-mods/illumination ... t.lua#L105
As for the grass, put this in in your code somewhere:
You might want to fiddle with the interval and chance parameters to set the growth speed to your preference. Relevant documentation: https://github.com/minetest/minetest/bl ... .txt#L7072
As for the grass, put this in in your code somewhere:
Code: Select all
local next_grass = {
["default:grass_1"] = "default:grass_2",
["default:grass_2"] = "default:grass_3",
["default:grass_3"] = "default:grass_4",
["default:grass_4"] = "default:grass_5",
}
minetest.register_abm({
label = "Grass growth",
nodenames = {
"default:dirt_with_grass",
"default:grass_1",
"default:grass_2",
"default:grass_3",
"default:grass_4",
},
interval = 60,
chance = 100,
min_y = -50,
max_y = 200,
catch_up = false,
action = function(pos, node)
if node.name == "default:dirt_with_grass" then
pos.y = pos.y + 1
if minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name = "default:grass_1"})
end
else
minetest.set_node(pos, {name = next_grass[node.name]})
end
end
})
Re: General Help
You are like a hero of some sort... I want to shed a tear...
Maybe because I am using an "Illumination" mod by Piezo it doesn't have that part in it... I will attempt it...
Update: ... Oh my goodness... it worked.. but now I have smoke coming from torches I am carrying and the illuminated helmet I am wearing... uhh I will try to fix it.. I say thank you..
This is amazing. Time for celebration.
(Maybe we can add something that gives it a small chance to grow a flower instead of grass.)
Maybe because I am using an "Illumination" mod by Piezo it doesn't have that part in it... I will attempt it...
Update: ... Oh my goodness... it worked.. but now I have smoke coming from torches I am carrying and the illuminated helmet I am wearing... uhh I will try to fix it.. I say thank you..
This is amazing. Time for celebration.
(Maybe we can add something that gives it a small chance to grow a flower instead of grass.)
Re: General Help
How does a person use a "globalstep" thing?
Re: General Help
It can be used to execute something globally about every 0.1 seconds (the time may depend on server lag)
You should add some kind of timer to keep a good performance.
Example:
Code: Select all
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime
if timer >= 3 then
minetest.chat_send_all(timer)
timer = 0
end
end)
https://github.com/minetest-mods/areas/ ... hud.lua#L6
Can your read this?
Re: General Help
One time, a person made a change to a soft leaves mod for me where if you step on the leaves it has a change to break. I think they used the globalstep thing, but I am not sure how they did it. I didn't understand the scripting at the time.
In an unrelated note, I was looking at the minecart mod that lets the minecart move items, but it leaves them sitting inside the cart and maybe they could disappear. I am wondering if since it seems like how it works is when the cart is moving it turns into a different sort of thing than when it is not moving, if it could be made into a chest sort of object instead of leaving things sitting there, but maybe it may be not possible or maybe too hard to do. I also wonder about vertical transportation of items. The sounding line mod seems kind of useful. Not sure if I am going beyond the idea of general help.
Another thing... I tried to use an ABM to make plants turn into air if a footprints trail is below them, but it seems to be turning anything on it into air. Plant or not.
In an unrelated note, I was looking at the minecart mod that lets the minecart move items, but it leaves them sitting inside the cart and maybe they could disappear. I am wondering if since it seems like how it works is when the cart is moving it turns into a different sort of thing than when it is not moving, if it could be made into a chest sort of object instead of leaving things sitting there, but maybe it may be not possible or maybe too hard to do. I also wonder about vertical transportation of items. The sounding line mod seems kind of useful. Not sure if I am going beyond the idea of general help.
Another thing... I tried to use an ABM to make plants turn into air if a footprints trail is below them, but it seems to be turning anything on it into air. Plant or not.
Re: General Help
I tried to make a thing that is wallmounted like a ladder and changes into another form when a light level is detected and it seems that when it changes, it always wants to be mounted to the top of the block, so it changes positions if it was placed on a different side. Is there a way to make it not change positions when that happens?
- Skamiz Kazzarch
- Member
- Posts: 618
- Joined: Fri Mar 09, 2018 20:34
- GitHub: Skamiz
- In-game: Skamiz
- Location: la lojbaugag.
Re: General Help
You need to copy the previous nodes 'param2' value. That's where the rotation is stored.
relevant links:
https://github.com/minetest/minetest/bl ... .txt#L5064
https://github.com/minetest/minetest/bl ... .txt#L5045
relevant links:
https://github.com/minetest/minetest/bl ... .txt#L5064
https://github.com/minetest/minetest/bl ... .txt#L5045
Re: General Help
I don't seem to know how to do that.
Re: General Help
I would want to know how to make it so when I step on a block, it may do something to it.
- Skamiz Kazzarch
- Member
- Posts: 618
- Joined: Fri Mar 09, 2018 20:34
- GitHub: Skamiz
- In-game: Skamiz
- Location: la lojbaugag.
Re: General Help
Generally you would make a globalstep function which checks what node the player is standing on and triggers an effect if it's the right node.
Re: General Help
Then I would maybe like to know how to do that, if that is something that would help, I guess.
And then maybe I could walk on grass and it would go down each time I walked on it until it was gone, and combined with the thing that makes it grow on its own, that may be pretty neat.
And then maybe I could walk on grass and it would go down each time I walked on it until it was gone, and combined with the thing that makes it grow on its own, that may be pretty neat.
- Skamiz Kazzarch
- Member
- Posts: 618
- Joined: Fri Mar 09, 2018 20:34
- GitHub: Skamiz
- In-game: Skamiz
- Location: la lojbaugag.
Re: General Help
You may be interested in this mod in general: https://content.minetest.net/packages/F ... ootprints/
And in specific the function starting here: https://github.com/minetest-mods/footpr ... t.lua#L463 which does what I described.
Edit:
Since it just so happened to be useful for my own world have this:
And in specific the function starting here: https://github.com/minetest-mods/footpr ... t.lua#L463 which does what I described.
Edit:
Since it just so happened to be useful for my own world have this:
Code: Select all
local previous_grass = {
["default:grass_1"] = "air",
["default:grass_2"] = "default:grass_1",
["default:grass_3"] = "default:grass_2",
["default:grass_4"] = "default:grass_3",
["default:grass_5"] = "default:grass_4",
}
local players = {}
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime
if timer >= 0.5 then
timer = timer - 0.5
else
return
end
for _, player in ipairs(minetest.get_connected_players()) do
local player_name = player:get_player_name()
local pos = vector.round(player:get_pos())
local pos_string = minetest.pos_to_string(pos)
if pos_string == players[player_name] then return end
players[player_name] = pos_string
local node = minetest.get_node(pos)
if previous_grass[node.name] then
node.name = previous_grass[node.name]
minetest.set_node(pos, node)
end
end
end)
- rubenwardy
- Moderator
- Posts: 6977
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Re: General Help
We used to have a modding questions mega thread, but it was eventually closed as it made googling things impossible and it was hard to keep track of conversations - so questions were buriedGrubler wrote: ↑Thu Sep 09, 2021 17:38I wonder if there could be a thread where we can maybe share things we may know and help each other figure out how to do things. If people may have questions and other people may know things that may help. And stuff like that. Maybe this may be redundant, but I don't know.
-
- Member
- Posts: 102
- Joined: Thu May 28, 2020 15:32
- GitHub: axcore
- In-game: Josselin
- Location: Tunnelers' Abyss
Re: General Help
Before this mini-thread gets buried, how can LUA code in a mod detect that name of the game it's running on? (Specifically, I want to know if I'm running on top of minetest-game or not)
- Skamiz Kazzarch
- Member
- Posts: 618
- Joined: Fri Mar 09, 2018 20:34
- GitHub: Skamiz
- In-game: Skamiz
- Location: la lojbaugag.
- Wizard Of mkdir
- Member
- Posts: 26
- Joined: Tue Aug 17, 2021 14:18
- GitHub: wizardofgcc
- In-game: Wizard Of mkdir
Re: General Help
Hello! I have a question: how does the number of nodes affect performance? If I want multiple versions of a node, e. g. an item frame or placed potion bottle, is it better to register many nodes or use entities to create visual changes in the node?
Re: General Help
From what I gather nodes are the kings of speed, and entities are eaters of cpu -- whereas ABMs are the wellspring of lag in multiplayer.
Lead dev of Exile, git repo: https://codeberg.org/Mantar/Exile
Re: General Help
I want to pack points efficently on the surface of a sphere . the fibonacci lattice can do this. but it doesn't coincide with the platonic solids. I want a lattice that does that.if anyone can help it could be very lucrative for you
Who is online
Users browsing this forum: No registered users and 5 guests