Hybrid Dog wrote:BrunoMine, maybe emerge_area doesn't work if pos1 is pos2, you could set pos2 to vector.add(pos1, 1)
you could also look at the emergeblocks chatcommand: https://github.com/minetest/minetest/bl ... s.lua#L476
after_place_node = function(pos, placer, itemstack, pointed_thing)
if placer and minetest.check_player_privs(placer:get_player_name(), {myarcade = true}) then
else
minetest.remove_node(pos)
return true
end
end,
function potions.register_potion(iname, color, exptime, action, expaction)
local rname = string.gsub(iname, "[-%[%]()1023456789 ]", "")
minetest.register_craftitem(minetest.get_current_modname()..":"..rname:lower(), {
description = iname.." Potion",
inventory_image = "potions_bottle.png^potions_"..color..".png",
on_use = function(itemstack, user, pointed_thing)
Nathan.S wrote:Take a look at the bucket code in default_game, it returns an empty bucket after placing the water. You might just need a line like this,
return {name="potions:empty_bottle}
Which you could call after using the potion.
on_use = minetest.item_eat(2, "farming:drinking_cup"),
on_use = function(itemstack, user, pointed_thing)
Hybrid Dog wrote:You could put it into the player's inventory:
https://github.com/Sokomine/replacer/bl ... t.lua#L218
amadin wrote:Hybrid Dog wrote:You could put it into the player's inventory:
https://github.com/Sokomine/replacer/bl ... t.lua#L218
Thank you it work right, i used search in dev.minetest.net but not find this.
Hybrid Dog wrote:Can l use the logarithm as random number generator?
Hybrid Dog wrote:Can l use the logarithm as random number generator?
i = 1000
for n in xrange(100):
i = abs((math.log(i)*1000)%1); print i
local load_time_start = os.clock()
-- $ time luajit raan.lua && pnmtopng tmp.ppm > tmp.png && optipng -o7 tmp.png
local path = "./tmp.ppm"
local file = io.open(path,"w")
file:write("")
file:close()
file = io.open(path,"a")
local s = 500
file:write("P3 "..s.." "..s.." 255 ")
local i = 2
local function getcol()
i = math.abs((math.log(i)*1000)%1)
return math.floor(i*255+0.5)
end
for y = 1,s do
for x = 1,s do
file:write(getcol().." "..getcol().." "..getcol().." ")
end
end
file:close()
local time = math.floor(tonumber(os.clock()-load_time_start)*100+0.5)/100
local msg = "fertig nach ca. "..time.."s"
if time > 0.05 then
print(msg)
end
local load_time_start = os.clock()
-- $ time luajit log_rand.lua && pnmtopng tmp.ppm > tmp.png && optipng -o7 -quiet tmp.png
local path = "./tmp.ppm"
local file = io.open(path,"w")
file:write("")
file:close()
file = io.open(path,"a")
local s = 500
file:write("P3 "..s.." "..s.." 255 ")
local i = 2
local function getcol()
i = math.abs((1000/math.sqrt(i))%1)
return math.floor(i*255+0.5)
end
for y = 1,s do
for x = 1,s do
file:write(getcol().." "..getcol().." "..getcol().." ")
end
end
file:close()
local time = math.floor(tonumber(os.clock()-load_time_start)*100+0.5)/100
local msg = "fertig nach ca. "..time.."s"
if time > 0.05 then
print(msg)
end
BrunoMine wrote:How to catch max_stack an item? (Just knowing your ID. example: "default:tree")
I want a method to do this.
I am referring to the default value of an item can be accumulated.
local stack_max = minetest.registered_items["default:tree"].stack_max
Misadventure wrote:I have a recipe that calls for:a tool (named forge_hammer)
Trying to output : The forge hammer (with less durability) AND the plate.
and an ingot (in this example, iron_ingot)
The problem is, if it consumes my hammer. I have almost solved this by setting the output of the recipe to the hammer.
writing a "register on craft" function to deduct the durability. My question is, how do I write it, so that eitherA) the forge_hammer stays in the original crafting grid (while now having its updated durability deduction) allowing you to take out the plate as you normally would, then in a separate click, drag the hammer off the grid.
or
B) Have it so when the player clicks the plate to craft it, it immediately sends the now less-durable hammer to the inventory, while the player still is holding the plate to drag wherever they please.
if minetest.get_modpath("moonrealm") then
-- Make moonrealm soil the same as dirt
minetest.register_alias(":moonrealm:soil", "default:dirt")
end
default
moonrealm?
minetest.override_node("moonrealm:soil", {
on_construct = function(pos)
minetest.set_node(pos, {name = "default:dirt"})
end
})
local get_id = minetest.get_content_id
function minetest.get_content_id(name)
if name == "moonrealm:soil" then
name = "default:dirt"
end
return get_id(name)
end
Users browsing this forum: No registered users and 69 guests