try screwdriver and the Sokomine's replacer mod (or my version which adds more than just single node mode https://github.com/HybridDog/replacer)swordpaint12 wrote:Actually, that's WHY I asked. I'm trying to make a tall roof using 'walls.'Hybrid Dog wrote: If they did, building roofs with slabs would become far more annoying.
Post your modding questions here
- Hybrid Dog
- Member
- Posts: 2828
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
Re: Post your modding questions here
Hi, can I restrict actions on player inventories somehow? Like the allow_* callbacks on detached inventories, or the allow_metadata_inventory_* callbacks on nodes. The idea is to show the player an formspec of a player-based inventory that they can take items from, but not insert items to.
Re: Post your modding questions here
deleted - miss read your postBen wrote:Hi, can I restrict actions on player inventories somehow? Like the allow_* callbacks on detached inventories, or the allow_metadata_inventory_* callbacks on nodes. The idea is to show the player an formspec of a player-based inventory that they can take items from, but not insert items to.
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
A list of my mods can be found here
- Nathan.S
- Member
- Posts: 1147
- Joined: Wed Sep 24, 2014 17:47
- GitHub: NathanSalapat
- IRC: NathanS21
- In-game: NathanS21
- Location: Bigsby Texas
- Contact:
Re: Post your modding questions here
Well I don't know how the inventory is being populated but you could do something like this
Of course you'd have to change the variables: sap, and bucket:bucket_empty. Maybe just change it to air or cloud. Then if a player tries to put anything in it will just get spit back at them. Unless they cheat to get clouds or air. You might even be able to use a non-existent string in place of the bucket:bucket_empty which would just return everything.
Code: Select all
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname == 'sap' then
if stack:get_name() == ('bucket:bucket_empty') then
return 1
else
return 0
end
end
end,
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course
Check out my website, and brand new Minetest Modding Course
Re: Post your modding questions here
Untested but I think this should work
Code: Select all
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.get_meta(pos)
return 0
end
return count
end,
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
A list of my mods can be found here
Re: Post your modding questions here
Thanks Nathan and Don, but those are for node inventories, right? I'm dealing with player inventories here.
Digging through mod code has not turned anything up, so far. Does anyone know where something like this has been done before?
Digging through mod code has not turned anything up, so far. Does anyone know where something like this has been done before?
Re: Post your modding questions here
@Ben - The mod "creative" in minetest_game might help.
https://github.com/minetest/minetest_ga ... e/init.lua
https://github.com/minetest/minetest_ga ... e/init.lua
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
A list of my mods can be found here
Re: Post your modding questions here
No, sorry. The creative inventory is a detached inventory – the same for all players. And the "craftpreview" inventory slot seems to be special-cased in the engine?Don wrote:The mod "creative" in minetest_game might help.
I'm beginning to feel it's not possible in the current MT?
- ArguablySane
- Member
- Posts: 116
- Joined: Sun Oct 12, 2014 21:29
Re: Post your modding questions here
Does anyone know why these two methods of perlin noise generation give different results?
Code: Select all
local perlin_map = minetest.get_perlin_map(params, {x=sidelen, y=sidelen, z=sidelen}):get2dMap_flat({x=minp.x, y=minp.z})
local index = (x-minp.x+1) + (z-minp.z)*sidelen
return perlin_map[index]
Code: Select all
return PerlinNoise(params):get2d{x=x, y=z}
The above post and any ideas expressed therein are released to the public domain under a Creative Commons CC0 license.
- paramat
- Developer
- Posts: 3700
- Joined: Sun Oct 28, 2012 00:05
- GitHub: paramat
- IRC: paramat
- Location: UK
Re: Post your modding questions here
Try:
local index = (x - minp.x) + (z - minp.z) * sidelen
I'm not sure if the map indexes from 0 or 1.
And / or try:
return minetest.get_perlin(params):get2d{x = x, y = z}
local index = (x - minp.x) + (z - minp.z) * sidelen
I'm not sure if the map indexes from 0 or 1.
And / or try:
return minetest.get_perlin(params):get2d{x = x, y = z}
- Hybrid Dog
- Member
- Posts: 2828
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
maybe you need to set z to 1 to make it really flatArguablySane wrote:Does anyone know why these two methods of perlin noise generation give different results?
Code: Select all
local perlin_map = minetest.get_perlin_map(params, {x=sidelen, y=sidelen, z=sidelen}):get2dMap_flat({x=minp.x, y=minp.z}) local index = (x-minp.x+1) + (z-minp.z)*sidelen return perlin_map[index]
Code: Select all
return PerlinNoise(params):get2d{x=x, y=z}
Code: Select all
local perlin_map = minetest.get_perlin_map(params, {x=sidelen, y=sidelen, z=1}):get2dMap_flat({x=minp.x, y=minp.z})
- ArguablySane
- Member
- Posts: 116
- Joined: Sun Oct 12, 2014 21:29
Re: Post your modding questions here
That worked, thanks!paramat wrote:return minetest.get_perlin(params):get2d{x = x, y = z}
It turns out that the PerlinNoise[Map] objects ignore the map seed but minetest.get_perlin[_map] includes it somehow. That discrepancy made them produce different noise.
Thanks for your suggestion too, Hybrid Dog.
The above post and any ideas expressed therein are released to the public domain under a Creative Commons CC0 license.
- Hybrid Dog
- Member
- Posts: 2828
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
What happens if l use the functions somewhere outside generation, e.g. when the mods become loaded?ArguablySane wrote:That worked, thanks!paramat wrote:return minetest.get_perlin(params):get2d{x = x, y = z}
It turns out that the PerlinNoise[Map] objects ignore the map seed but minetest.get_perlin[_map] includes it somehow. That discrepancy made them produce different noise.
Thanks for your suggestion too, Hybrid Dog.
- ArguablySane
- Member
- Posts: 116
- Joined: Sun Oct 12, 2014 21:29
Re: Post your modding questions here
You can't use minetest.get_perlin or minetest.get_perlin_map until the game has finished loading. If you put them in the body of your init.lua file, then they won't work. You can use them anywhere else though. They aren't restricted to being used in the on_generated callback, although that's the most obvious place to put them.Hybrid Dog wrote:What happens if l use the functions somewhere outside generation, e.g. when the mods become loaded?ArguablySane wrote:That worked, thanks!paramat wrote:return minetest.get_perlin(params):get2d{x = x, y = z}
It turns out that the PerlinNoise[Map] objects ignore the map seed but minetest.get_perlin[_map] includes it somehow. That discrepancy made them produce different noise.
Thanks for your suggestion too, Hybrid Dog.
Also, I have another question: Does anyone know how to implement a version of minetest.hash_node_position(pos) which actually works to seed PcgRandom or PseudoRandom?
I've been testing the following code (part of a much larger mapgen project) and the image shows what it returns:
Code: Select all
local prng = PcgRandom(minetest.hash_node_position(pos) + self.seed)
minetest.chat_send_all(pos.x..","..pos.y..","..pos.z.." goes to "..prng:next())
As you can see, similar values of x give the same result from the PRNG, which leads to repeating patterns on the map.
EDIT: Turns out it was a problem with adding the map seed (a very large number) to the result from minetest.hash_node_position(pos). When I removed that it started working again. I still need to figure out a good way to include the map seed though. Maybe I could just take the lower ~8 bits of it and add those. That should provide sufficient randomness.
EDIT2: Yep, that fixed it. I now only add the lower 16 bits of the map seed.
The above post and any ideas expressed therein are released to the public domain under a Creative Commons CC0 license.
Re: Post your modding questions here
What would be the best way for me to store all the entities of an area in a table that I can save to a file so it can later be loaded back?
I tried to serialize ``minetest.luaentities``, but it crashes the game.
I tried to serialize ``minetest.luaentities``, but it crashes the game.
- Hybrid Dog
- Member
- Posts: 2828
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
l'm using this code https://github.com/HybridDog/vines/blob ... t.lua#L193, what are the disadvantages?ArguablySane wrote:EDIT: Turns out it was a problem with adding the map seed (a very large number) to the result from minetest.hash_node_position(pos). When I removed that it started working again. I still need to figure out a good way to include the map seed though. Maybe I could just take the lower ~8 bits of it and add those. That should provide sufficient randomness.
EDIT2: Yep, that fixed it. I now only add the lower 16 bits of the map seed.
Re: Post your modding questions here
Ok after some struggle I found out what I think is the way to serialize minetest.luaentitites
It seems a bit awkward to have to pass self to the entity all the time. Maybe I'm accessing the functions the wrong way, I don't know...
So, I store position, name (which according to the documentation is the identifier used in register_entity and already determines the initial_properties) and staticdata (according to the docs should hold any changes in state that are not covered already by the initial_properties).
The thing is that after doing this, I get a lot of entities with name "__builtin:item" for the items that are dropped down in the map.
I don't know if it's because they are "__builtin:*" but these items don't seem to expose any properties in the staticdata that determine what kind of item it is.
I can access some values if I directly use the entity as a table (there's for example "entity.stringitem"), but it's not clear to me how would I restore those entities when I try to deserialize the file, since minetest.add_entity(pos, "name") doesn't have enough parameters to specify this, and the only other method to change its state seems to be on_activate(self, staticdata) which requires a staticdata that is not present.
I see that there is a "minetest.add_item" function, which seems to suggest that items dropped are a special kind of entity (__builtin:item) that doesn't really follow the rules of standard entities. But even if I made an exception in the code for this entity name, I wouldn't know how to obtain the name of the item to be used in add_item. Or is it safe to assume that all items will have an "entity.stringitem" property that would always correspond to the item identifier? And are there other entities I have to add exceptions for?
It seems a bit awkward to have to pass self to the entity all the time. Maybe I'm accessing the functions the wrong way, I don't know...
Code: Select all
local entities = {}
for id,entity in pairs(minetest.luaentities) do
table.insert(entities, {
pos = entity.object.getpos(entity.object),
name = entity.name,
staticdata = entity.object.get_luaentity(entity.object).get_staticdata(entity.object)
})
end
local str = minetest.serialize(entities)
The thing is that after doing this, I get a lot of entities with name "__builtin:item" for the items that are dropped down in the map.
I don't know if it's because they are "__builtin:*" but these items don't seem to expose any properties in the staticdata that determine what kind of item it is.
I can access some values if I directly use the entity as a table (there's for example "entity.stringitem"), but it's not clear to me how would I restore those entities when I try to deserialize the file, since minetest.add_entity(pos, "name") doesn't have enough parameters to specify this, and the only other method to change its state seems to be on_activate(self, staticdata) which requires a staticdata that is not present.
I see that there is a "minetest.add_item" function, which seems to suggest that items dropped are a special kind of entity (__builtin:item) that doesn't really follow the rules of standard entities. But even if I made an exception in the code for this entity name, I wouldn't know how to obtain the name of the item to be used in add_item. Or is it safe to assume that all items will have an "entity.stringitem" property that would always correspond to the item identifier? And are there other entities I have to add exceptions for?
- ArguablySane
- Member
- Posts: 116
- Joined: Sun Oct 12, 2014 21:29
Re: Post your modding questions here
It will produce identical results for certain positions. For y = 0, there will be a set of points corresponding to x = -z^5 where the seed is just vine_seed, but there will be lots of other sets of identical points too. Using math.abs actually makes things worse because it doubles the number of symmetric points. You can seed the PRGN with a negative number just as effectively as with a positive number.Hybrid Dog wrote: l'm using this code https://github.com/HybridDog/vines/blob ... t.lua#L193, what are the disadvantages?
Also, you might want to do some testing with PseudoRandom. In my experience it gave similar results from similar seeds, but that might have been a programming error on my part. I usually use PcgRandom.
Depending on your particular use it might not matter. From looking at your code, the only thing it's going to do is make vines which appear at those symmetry points the same length, but that shouldn't be noticeable to the player.
I did notice a different possible problem though. On line 311 that PRNG is going to return the same result every time it's run. That means that 25% of rotten vines simply won't disappear no matter how long they are left. Is that the intended behaviour?
The same is true of the ABM on line 199. It will always immediately return for 25% of vines.
The above post and any ideas expressed therein are released to the public domain under a Creative Commons CC0 license.
Re: Post your modding questions here
How do you do a check for nodes when placing a schematic? I want to do if not air then return.
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
A list of my mods can be found here
- GunshipPenguin
- Member
- Posts: 94
- Joined: Tue Jan 28, 2014 00:38
- GitHub: GunshipPenguin
- IRC: GunshipPenguin
- In-game: GunshipPenguin
- Location: Vancouver, BC
Re: Post your modding questions here
I'm having trouble with a mod that utilizes minetest.after heavily.
Basically what I want to happen is this. A function is called through the use of minetest.after which does something and then uses minetest.after to call itself again sometime in the future. It will then continue to do something and call itself sometime in the future indefinitely.
Here is a very simple example.
This code calls timerfunction 5 seconds in the future through the use of minetest.after. timerfunction then logs a message, and uses minetest.after to call itself 5 seconds in the future. This cycle goes on indefinitely.
The problem is, all calls to timerfunction through minetest.after besides the first one seem to be executed after 10 seconds rather than 5 seconds. Here is the output from minetest with this mod running.
Notice how the first log message "Calling timerfunction in 5 seconds" appears at 17:32:59 and then the message "timerfunction called, calling again in 5 seconds" is logged at 17:33:04. These two messages are separated by 5 seconds, which makes sense, given that the call to minetest.after specified that timerfunction was to be called 5 seconds in the future.
What I don't understand however, is why all the remaining log messages are separated by 10 seconds. This presents a large problem in my mod, as the correct timing of actions is very important.
I'm pretty stumped here. Can anybody tell me why this is happening? Many thanks in advance.
Basically what I want to happen is this. A function is called through the use of minetest.after which does something and then uses minetest.after to call itself again sometime in the future. It will then continue to do something and call itself sometime in the future indefinitely.
Here is a very simple example.
Code: Select all
local timerfunction
timerfunction = function()
minetest.log("action", "timerfunction called, calling again in 5 seconds")
minetest.after(5, timerfunction)
end
minetest.log("action", "Calling timerfunction in 5 seconds")
minetest.after(5, timerfunction)
The problem is, all calls to timerfunction through minetest.after besides the first one seem to be executed after 10 seconds rather than 5 seconds. Here is the output from minetest with this mod running.
Code: Select all
2015-09-08 17:32:59: ACTION[main]: Calling timerfunction in 5 seconds
2015-09-08 17:32:59: ACTION[main]: .__ __ __
2015-09-08 17:32:59: ACTION[main]: _____ |__| ____ _____/ |_ ____ _______/ |_
2015-09-08 17:32:59: ACTION[main]: / \| |/ \_/ __ \ __\/ __ \ / ___/\ __\
2015-09-08 17:32:59: ACTION[main]: | Y Y \ | | \ ___/| | \ ___/ \___ \ | |
2015-09-08 17:32:59: ACTION[main]: |__|_| /__|___| /\___ >__| \___ >____ > |__|
2015-09-08 17:32:59: ACTION[main]: \/ \/ \/ \/ \/
2015-09-08 17:32:59: ACTION[main]: World at [/home/rhys/Desktop/minetest-0.4.13/bin/../worlds/asdf]
2015-09-08 17:32:59: ACTION[main]: Server for gameid="minetest" listening on 0.0.0.0:54258.
2015-09-08 17:32:59: ACTION[ServerThread]: singleplayer [127.0.0.1] joins game.
2015-09-08 17:32:59: ACTION[ServerThread]: singleplayer joins game. List of players: singleplayer
2015-09-08 17:33:00: ACTION[main]: Irrlicht: Could not open file of texture: character.png
2015-09-08 17:33:00: ACTION[main]: Irrlicht: Could not open file of texture: character.png
2015-09-08 17:33:04: ACTION[ServerThread]: timerfunction called, calling again in 5 seconds
2015-09-08 17:33:14: ACTION[ServerThread]: timerfunction called, calling again in 5 seconds
2015-09-08 17:33:24: ACTION[ServerThread]: timerfunction called, calling again in 5 seconds
2015-09-08 17:33:34: ACTION[ServerThread]: timerfunction called, calling again in 5 seconds
2015-09-08 17:33:44: ACTION[ServerThread]: timerfunction called, calling again in 5 seconds
2015-09-08 17:33:54: ACTION[ServerThread]: timerfunction called, calling again in 5 seconds
What I don't understand however, is why all the remaining log messages are separated by 10 seconds. This presents a large problem in my mod, as the correct timing of actions is very important.
I'm pretty stumped here. Can anybody tell me why this is happening? Many thanks in advance.
Sprint Mod -- viewtopic.php?f=11&t=9650&p=156207
Server Essentials Mod -- viewtopic.php?f=11&t=12445&p=180964
My PvE server -- viewtopic.php?f=10&t=10616
Server Essentials Mod -- viewtopic.php?f=11&t=12445&p=180964
My PvE server -- viewtopic.php?f=10&t=10616
- rubenwardy
- Moderator
- Posts: 6972
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Re: Post your modding questions here
It's possible that the messages aren't flushed immediately, but that wouldn't explain the 10 second gap.
Here is the minetest.after code: https://github.com/minetest/minetest/bl ... lua#L7-L75
Here is the minetest.after code: https://github.com/minetest/minetest/bl ... lua#L7-L75
- Hybrid Dog
- Member
- Posts: 2828
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
I use PseudoRandom to reduce lag, originally it used math.random and the abms made the vines grow and die repeatedly.ArguablySane wrote:On line 311 that PRNG is going to return the same result every time it's run. That means that 25% of rotten vines simply won't disappear no matter how long they are left. Is that the intended behaviour?
The same is true of the ABM on line 199. It will always immediately return for 25% of vines.
- Hybrid Dog
- Member
- Posts: 2828
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
https://github.com/minetest/minetest/bl ... sc.lua#L18rubenwardy wrote:It's possible that the messages aren't flushed immediately, but that wouldn't explain the 10 second gap.
Here is the minetest.after code: https://github.com/minetest/minetest/bl ... lua#L7-L75
https://github.com/minetest/minetest/bl ... sc.lua#L60
l think delay needs to be set to 0 but before a temporary copy of it needs to be set and used then for executing the function(s)
Edit: https://github.com/minetest/minetest/pull/3163/files
Last edited by Hybrid Dog on Wed Sep 09, 2015 11:56, edited 1 time in total.
- everamzah
- Member
- Posts: 490
- Joined: Thu Jan 29, 2015 00:47
- GitHub: everamzah
- IRC: everamzah
- In-game: everamzah
Re: Post your modding questions here
How do I delete all weird characters - particularly spaces - from any text entered as param in this chat command:
Thanks for any tips!
Spoiler
Code: Select all
minetest.register_chatcommand("setwarp", {
params = "name",
description = "Set a warp location to the players location",
privs = { warp_admin = true },
func = function(name, param)
local h = "created"
for i = 1,table.getn(warps) do
if warps[i].name == param then
table.remove(warps, i)
h = "changed"
break
end
end
local player = minetest.get_player_by_name(name)
local pos = player:getpos()
table.insert(warps, { name = param, x = pos.x, y = pos.y, z = pos.z, yaw = player:get_look_yaw(), pitch = player:get_look_pitch() })
save()
minetest.log("action", name .. " " .. h .. " warp \"" .. param .. "\": " .. pos.x .. ", " .. pos.y .. ", " .. pos.z)
return true, h .. " warp \"" .. param .. "\""
end,
})
- Hybrid Dog
- Member
- Posts: 2828
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
maybe param = string.trim(param)everamzah wrote:How do I delete all weird characters - particularly spaces - from any text entered as param in this chat command:Thanks for any tips!Spoiler
Code: Select all
minetest.register_chatcommand("setwarp", { params = "name", description = "Set a warp location to the players location", privs = { warp_admin = true }, func = function(name, param) local h = "created" for i = 1,table.getn(warps) do if warps[i].name == param then table.remove(warps, i) h = "changed" break end end local player = minetest.get_player_by_name(name) local pos = player:getpos() table.insert(warps, { name = param, x = pos.x, y = pos.y, z = pos.z, yaw = player:get_look_yaw(), pitch = player:get_look_pitch() }) save() minetest.log("action", name .. " " .. h .. " warp \"" .. param .. "\": " .. pos.x .. ", " .. pos.y .. ", " .. pos.z) return true, h .. " warp \"" .. param .. "\"" end, })
Who is online
Users browsing this forum: No registered users and 9 guests