Page 1 of 1
Adding a new mouse cursor to spring
Posted: 09 Mar 2011, 19:36
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

Re: Adding a new mouse cursor to spring
Posted: 09 Mar 2011, 19:45
by jK
Re: Adding a new mouse cursor to spring
Posted: 09 Mar 2011, 20:02
by FLOZi
Re: Adding a new mouse cursor to spring
Posted: 09 Mar 2011, 20:22
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?
Re: Adding a new mouse cursor to spring
Posted: 09 Mar 2011, 20:33
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.)
Re: Adding a new mouse cursor to spring
Posted: 09 Mar 2011, 20:45
by Forboding Angel
aha, I was wondering if it was somehting like that
thanks!
Re: Adding a new mouse cursor to spring
Posted: 09 Mar 2011, 22:00
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!