leeminer wrote:The "name" variable. I assume this is a global variable.
leeminer wrote:Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_chatcommand("mvol", {
params = "<mvol>",
description = "set volume of music, default 1 normal volume.",
privs = {server=true},
func = function(name, param)
func = function(name, param)
minetest.register_chatcommand("mvol", {
params = "<mvol>",
description = "set volume of music, default 1 normal volume.",
privs = {server=true},
func = function(name, param)
MUSICVOLUME = param
minetest.chat_send_player(name, "Music volume set.")
end,
})
leeminer wrote:HybridDog linked to this exampleYour phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_chatcommand("mvol", {
params = "<mvol>",
description = "set volume of music, default 1 normal volume.",
privs = {server=true},
func = function(name, param)
MUSICVOLUME = param
minetest.chat_send_player(name, "Music volume set.")
end,
})
The name variable in the chat_send_player function, is not defined here. So I was wondering where there name is assigned. I assumed it was a global variable that holds the current users name.
minetest.register_chatcommand("noon", {
params="",
description="Sets time to noon",
func=function(name, param)
minetest.set_timeofday(.5)
end,
}]
minetest.register_abm({
nodenames = {"leemod:woodyblock"},
interval = 10.0, -- Run every 10 seconds
chance = 5, -- Select every 1 in 50 nodes
action = function(pos, node)
minetest.add_entity(pos,"mobs:cow")
--minetest.remove_node(pos)
end
})
HeroOfTheWinds wrote:Do you have mobs added to the dependencies.txt? That often causes trouble for mods that reference others, and it's easy to miss.
minetest.register_abm({
nodenames={"a:a"},
neighbors={'default:cobble'},
interval=1,
chance=1,
action=function(pos, node, active_object_count, active_object_count_wider)
print(tostring('neighbors: ')..dump(neighbors))
end,
})
srifqi wrote:^^^
@pandaro:
That code will not work, the 'neighbors' variable is not exist nor given, so you need to use minetest.find_nodes_in_area.
I'd like that name to then be displayed either above the entity all of the time or when the player hovers over the entity.
TeTpaAka wrote:I'd like that name to then be displayed either above the entity all of the time or when the player hovers over the entity.
Take a look at this:
https://forum.minetest.net/viewtopic.php?f=9&t=7321&hilit=npc
It uses textures for every char that is displayed.
tfranko wrote:I'm using Carbone's mobs mod to create the entity, so I'm not sure how I would integrate the part of the code I want from the link you shared above with the mobs mod. I'll keep working on it though.
local name_hud = nil
function display_mob_name(player_object, text)
-- Function to flash text near cursor.
local player = player_object
if name_hud == nil then
name_hud = player:hud_add({
hud_elem_type = "text",
position = {x=.5, y=.5},
alignment = {x=-0, y=0},
offset = {x=0, y=-18},
text = text,
number = 0xFFFF00, -- Color as 0xRRGGBB
}) -- name_hud()
else
player:hud_change(name_hud, 'text', text)
end -- if/then
minetest.after(5, function()
player:hud_remove(name_hud)
name_hud = nil
end) -- after()
end -- HUD function
display_mob_name(clicker, self.mob_name)
LonelyCrow wrote:Any Idea on how to access the World Directory? Sorry, I am rather new to modifying software and the lingo for that matter.
ArguablySane wrote:Is it safe to use the lua functions math.randomseed(seed) and math.random() to generate random numbers for each chunk during mapgen? I don't want it to behave differently on different computers.
ArguablySane wrote:Also, does anyone know of an elegant way to divide the world into Voroni cells (or similar) during mapgen? Subdividing any given chunk requires knowledge of the random points in adjacent chunks, but I see no way to get the random seed for adjacent chunks.
kaeza wrote:ArguablySane wrote:Is it safe to use the lua functions math.randomseed(seed) and math.random() to generate random numbers for each chunk during mapgen? I don't want it to behave differently on different computers.
`math.random` is a straightforward interface to C's stdlib `random` function. I'm not sure if every C lib out there uses the same algorithm. Minetest's `PseudoRandom` class is the same across all supported systems (albeit with some limitations), so you should probably use it to be sure.
Kalabasa wrote:Is there any way to change the length of a day? Change the speed of time of day.
Kalabasa wrote:Is there any way to change the length of a day? Change the speed of time of day.
ArguablySane wrote:Regarding ABMs, is there any way to detect if a node is near the edge of the active region of the map? I'm trying to create more dynamic trees, but when the trunk lies just outside the active region the active leaves stop receiving their keep-alive messages and die. I could put the code to check if the tree is still intact in the leaf node ABMs, but that seems very inefficient since there are maybe 80 leaf nodes but only 1 root node per tree.
ArguablySane wrote:Regarding metadata, does it get erased if I use minetest.set_node to replace a node with a different one?
Users browsing this forum: No registered users and 11 guests