It puts the markers on the map

It puts the markers on the map

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

It puts the markers on the map

Post by smoth »

Code: Select all

function gadget:GetInfo()
	return {
		name		= "Point Placeer",
		desc		= "test for placement",
		author		= "Smoth",
		date		= "7/25/2015",
		license		= "PD",
		layer	 	= 0,
		enabled	 	= true 
	}
end

local pointSpacing = 128

local function LocationMarker(markerX, markerZ)
	if markerX >= 0 and markerZ >= 0 then
		local markerY		=  Spring.GetGroundHeight(markerX, markerZ)
		
		local markerString	= "( ".. markerX .. " , " .. markerZ .. " )"
		Spring.MarkerAddPoint(markerX,0,markerZ, markerString, false)
		Spring.Echo("adding point at: ", markerX,markerY,markerZ)
	else
		Spring.Echo(markerX, markerZ)
	end  
end

local function markerLines(distance, multiplier)
	local spacing = 1 -- start 1x multiplier away from edge
	while (spacing * multiplier) < distance do
		LocationMarker(distance, spacing * multiplier)
		LocationMarker(spacing * multiplier, distance)
		spacing = spacing + 1
	end
		LocationMarker(distance, distance)
end

if (gadgetHandler:IsSyncedCode()) then
	function gadget:Initialize()
		local counter = 1 

		while counter < 100 do
			markerLines(counter * pointSpacing, pointSpacing)
			counter	= counter + 1
		end

	end
end
I was writing this to point out some locations with waypoints/markers.. someone, somewhere, some when, might have a use for it.
Post Reply

Return to “Lua Scripts”