Ok, so I figured out how to attach an animated cursor to the mouse pointer (mod of Beer Invaders example):
the cursor can call an entity (npc soldier, asset, structure, whatever, as long as its an entity) making it display its name or ID, cursor also displays map coordinates upon choosing an empty location (using Novashell Scripting Reference example):
function Update(step)--this is run every logic tick (a minimum of 60 times a second of game-time).
ProcessMovement(); --update this function every tick
if (m_vLastMousePos != GetInputManager:GetMousePos()) then --GetMousePos returns Vector2(x) and Vector2(y).
m_vLastMousePos = GetInputManager:GetMousePos(); --this updates mouse position if its moving.
this:SetPos(m_vLastMousePos); --sticks cursor to mouse. not working correctly when out of 0,0 or 1:1
Note: the cursor is technically the player, as all other entities on the map are essentially npc's. I copied a script icon from System Palette and assigned it to be the player. Cursor entity had to be pasted directly on the active map instead of in a placeholding palette (like a palette just used to store images like in the Dink example), as it caused the cursor to double its text output on left click unless it only has a single instance running. No big deal.
function OnMouseLeft(bKeyDown) --handles mouse clicks for cursor
LogMsg("Cursor OnMouseLeft"); --I want to see when this function is called in the console.
if (bKeyDown) then
--LogMsg("You pressed the left mouse button down."); --we want output on release not depress.
local vPos = ScreenToWorld(GetInputManager:GetMousePos());
local pt = ScreenToWorld(GetInputManager:GetMousePos());
local ent = GetEntityByWorldPos(pt, this, true); --get all entities but ignore ourself, be pixel accurate
if (ent != nil) then --what entity is the cursor hovering over?
this:SetAnimByName("select"); --make the cursor have animation on select
GetTextManager:Add(ent:GetName() .. " Standing By", ent); --verify communication
GetTextManager:Add(tostring(vPos), this); --display world coordinates above cursor
this:SetAnimByName("idle"); --reset the cursor animation because we are selecting nothing
return true; --keep calling callbacks for this keypress.
I attempted to add functionality to scroll the map when the cursor touches the edge, but it doesn't work correctly yet. For some reason the above code to "stick" the cursor to the pointer only works in 1:1 zoom and when the camera is at 0,0. Otherwise, it just rips the cursor off the pointer for some reason. I don't see anything that restricts the cursor image to that part of the map, so until I figure it out, I won't bother posting my hacked up test code.
Oh, and I also have little "foot soldier" animations (only walk and attack for now) that work perfectly, but I have yet to perfect the script to make the soldier move to a valid map world coordinates using the cursor. I imagine it would have to be in the cursor script or an external script (like maybe select.lua or something), as the soldiers all run off the same script, so they would ALL run in the same direction simultaneously and there would be no way to tell each individual entity to perform a unique task from the npc code (that I know of).
I'll update here when I figure it out. Sorry if this is too long of a post. I hope this helps anyone trying to do the same types of tasks.