Icons?
Moderator: Moderators
Icons?
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?
Example code is in the 'custom unit icons' lua widget. Most likely implementable as a gadget.
Re: Icons?
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:
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.
Ok, looks pretty simple... you can just specify an Icon type via lines like this:
Code: Select all
Spring.SetUnitDefIcon(udid, "m.user")
Re: Icons?
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:
... 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...
Code: Select all
Spring.SetUnitNeutral(u, true)
Spring.SetUnitDefIcon(u, "neverseeme")
... I suppose that means that this callin no longer exists? Lemme go check the supposedly-current list of callins...
Re: Icons?
Or the icon parameter has to be an icon object? I dunno, java is rotting my brain.
Re: Icons?
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.

[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.
- Pressure Line
- Posts: 2283
- Joined: 21 May 2007, 02:09
Re: Icons?
could always make the "icon" 1px * 1px and transparent...
Re: Icons?
- Spring.SetUnitDefIcon() is a LuaUI only functions.
- You should use Spring.SetUnitNoMinimap() and/or Spring.SetUnitNoDraw
Re: Icons?
Ok, I'll take a look at that, once I have the rest of this demo set up. Thanks!