Page 1 of 1
Icons?
Posted: 04 Jan 2008, 06:17
by Argh
Is there a way to turn the Icon of a Unit off (or change the Icon type displayed) via LUA? Kind've need it, as one of the refining steps for my first version of the map-script I'm working on. If no, let me know, I'll ask for it in Feature Requests, it'd really be a nice thing to have.
Re: Icons?
Posted: 04 Jan 2008, 06:21
by Peet
Example code is in the 'custom unit icons' lua widget. Most likely implementable as a gadget.
Re: Icons?
Posted: 04 Jan 2008, 06:41
by Argh
Hmm. Lemme go take a look at that, see what can be done.
Ok, looks pretty simple... you can just specify an Icon type via lines like this:
Code: Select all
Spring.SetUnitDefIcon(udid, "m.user")
So long as they're defined, great. Now I just need to get it set up so that they have a default icon that they regain when no longer Neutral, and I can define an Icon that won't ever be drawn for the Neutral stuff, so that it's no longer crowding up the Minimap or otherwise looking lame.
Re: Icons?
Posted: 04 Jan 2008, 07:13
by Argh
Huh. That didn't work. Put that line in, and I get told I'm referencing a nil value. I put it in as I'm setting the Unit up to be neutral:
Code: Select all
Spring.SetUnitNeutral(u, true)
Spring.SetUnitDefIcon(u, "neverseeme")
... where "neverseeme" is an icon that should never get drawn. Doesn't work, and breaks the script, I get the following error: "LuaRules::RunCallIn: error = 2, GameFrame, [string "LuaRules/Gadgets/neutralizer.lua"]:37: attempt to call field 'SetUnitDefIcon' (a nil value)"
... I suppose that means that this callin no longer exists? Lemme go check the supposedly-current list of callins...
Re: Icons?
Posted: 04 Jan 2008, 07:20
by Peet
Or the icon parameter has to be an icon object? I dunno, java is rotting my brain.
Re: Icons?
Posted: 04 Jan 2008, 07:23
by Argh
Looks like the callin is no longer valid

It points me towards the OpenGL API <groans> which is the area I want to mess with
last, since I'm still figuring out very basic manipulation of the gameworld here... I'll just set up my "units" with this IconType as their type, for now... and come back to this later.
[EDIT]
Setting up the Units as Stealth and giving them an IconRadius that basically will not cause them to be drawn, ever, made a huge difference in performance! So, that's cool- I'll have to write something in their COBs that checks their Neutral state and sets Stealth to FALSE if they get captured, though. And some things need an icon and should be seen on radar, of course. But this is more than "good enough" for shrubs, trees, etc.
Re: Icons?
Posted: 10 Jan 2008, 11:56
by Pressure Line
could always make the "icon" 1px * 1px and transparent...
Re: Icons?
Posted: 10 Jan 2008, 13:17
by jK
- Spring.SetUnitDefIcon() is a LuaUI only functions.
- You should use Spring.SetUnitNoMinimap() and/or Spring.SetUnitNoDraw
Re: Icons?
Posted: 10 Jan 2008, 22:26
by Argh
Ok, I'll take a look at that, once I have the rest of this demo set up. Thanks!