-- hand out a preconfigured waypoint compass to the player yl_speak_up.custom_functions_r_[ "give_compass" ] = { description = "Hand out a preconfigured compass to the player.", param1_text = "X coordinate:", param1_desc = "The compass will be set to this x coordinate.", param2_text = "Y coordinate:", param2_desc = "The compass will be set to this y coordinate.", param3_text = "Z coordinate:", param3_desc = "The compass will be set to this z coordinate.", param4_text = "Name of target location:", param4_desc = "This is how the target location will be called on the compass, i.e. \"Tribe Micoene Camp\".", param5_text = "Color code in Hex:", param5_desc = "Give the color for the compass here. Example: \"FFD700\". Needs to be 6 characters long, with each character ranging from 0-9 or beeing A, B, C, D, E or F.", code = function(player, n_id, r) local pname = player:get_player_name() local coords = core.string_to_pos((r.r_param1 or "0")..",".. (r.r_param2 or "0")..",".. (r.r_param3 or "0")) local town = (r.r_param4 or "- some place somewhere -") local color = "0x"..(r.r_param5 or "FFFFFF") -- so that players cannot change the compass local compass_owner = "Service" if(not(coords)) then minetest.chat_send_player(pname, "Sorry. There was an internal error with the ".. "coordinates. Please inform whoever is responsible for this NPC.") return false end -- TODO: mostly for debugging minetest.chat_send_player(pname, "You received a compass to location \"".. town.."\" located at "..minetest.pos_to_string(coords)..".") -- no compass mod? then no way to hand one out if(not(minetest.global_exists("waypoint_compass"))) then minetest.chat_send_player(pname, "Error: Missing waypoint compass mod!") return false end -- the compass will be owned by Service (so the player can't reset it) --core.get_player_by_name(player):get_inventory():add_item("main",waypoint_compass.make_compass(coords,"Service",town,0xFFD700)) player:get_inventory():add_item("main", waypoint_compass.make_compass(coords, compass_owner, town, 0xFFD700)) -- the function was successful (effects only return true or false) return true end, }