Adding a new mouse cursor to spring

Adding a new mouse cursor to spring

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

Moderator: Moderators

Post Reply
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Adding a new mouse cursor to spring

Post by Forboding Angel »

[16:28:11] <[Evo]Forboding_Angel> does anyone here know how to add a new mouse cursor to the engine?
[16:28:28] <[Evo]Forboding_Angel> so that I can tell a gadget to sue that mouse cursor?
[16:28:30] <[Evo]Forboding_Angel> use*
[16:30:08] <lurker[]@IRC> what is your goal here, forb?
[16:30:56] <[Evo]Forboding_Angel> area mex gadget
[16:31:12] <[Evo]Forboding_Angel> defines the repair cursor as the one to use
[16:31:21] <[Evo]Forboding_Angel> I want to feed spring anew mosue cursor
[16:31:34] <[Evo]Forboding_Angel> I'm surprised there isn't already a gadget for it
[16:31:36] <lurker[]@IRC> oh, that kind of cursor
[16:31:52] ** zisleetlepiggy left the channel( Quit ).
[16:31:54] <[Evo]Forboding_Angel> yeah, didn't really know how to describe it in short
[16:31:54] <lurker[]@IRC> that is much less of a nightmare
[16:32:09] <[Evo]Forboding_Angel> but once i have the ability
[16:32:14] <[Evo]Forboding_Angel> I would like to be able to define more
[16:32:21] <[Evo]Forboding_Angel> for other gadget related actions later on
[16:32:26] <[Evo]Forboding_Angel> rather than a one shot
[16:32:31] <lurker[]@IRC> retreat adds a cursor
[16:32:44] <[Evo]Forboding_Angel> retreat?
[16:32:49] <lurker[]@IRC> and I wrote adding one once in planetwars, and don't remember it being complex
[16:32:53] ** EchoOne_irc joined the channel.
[16:33:16] <lurker[]@IRC> it's somewhere in caland
I was unable to find anything named retreat in the zk sauce, so hopefully either someone here will help me with code examples or at least pointing me towards aforementioned gadgetry. Thx :-)
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: Adding a new mouse cursor to spring

Post by FLOZi »

And also:

http://answers.springlobby.info/questio ... tom-cursor which has examples right in the Q&A.

Also see:

http://spring1944.svn.sourceforge.net/v ... iew=markup

For a full gadget
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Adding a new mouse cursor to spring

Post by Forboding Angel »

Flozi, you are awesome (and thanks jk :-))

I have a question tho... This seems to be the function where the mosue cursor is defined:

Code: Select all

function gadget:Initialize()
	gadgetHandler:RegisterCMDID(CMD_CLEARMINES)
	-- Fake UnitCreated events for existing units. (for '/luarules reload')
	local allUnits = Spring.GetAllUnits()
	for i=1,#allUnits do
		local unitID = allUnits[i]
		gadget:UnitCreated(unitID, Spring.GetUnitDefID(unitID))
	end
	Spring.AssignMouseCursor("Clear Mines", "cursordemine", true, false)
	Spring.SetCustomCommandDrawData(CMD_CLEARMINES, "Clear Mines", {1,0.5,0,.8}, false)
end
Yeah ok, easy enough to understand, but why is the loop necessary?
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Re: Adding a new mouse cursor to spring

Post by yuritch »

Loop is not cursor related. It's used to add "clear mines" button to units which can do so if the gadget is somehow loaded AFTER the game starts (so the units are already on the field before the code initializes, like after /luarules reload for ex.)
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Adding a new mouse cursor to spring

Post by Forboding Angel »

aha, I was wondering if it was somehting like that :-)

thanks!
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Adding a new mouse cursor to spring

Post by Forboding Angel »

Ultimately, jk's answer led me to the right place, I appreciate the s44 examples tho quite muchly. I ended up using the text file addition thingy and it worked like a charm!
Post Reply

Return to “Lua Scripts”