Icons?

Icons?

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

Moderator: Moderators

Post Reply
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Icons?

Post 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.
User avatar
Peet
Malcontent
Posts: 4384
Joined: 27 Feb 2006, 22:04

Re: Icons?

Post by Peet »

Example code is in the 'custom unit icons' lua widget. Most likely implementable as a gadget.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Icons?

Post 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.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Icons?

Post 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...
User avatar
Peet
Malcontent
Posts: 4384
Joined: 27 Feb 2006, 22:04

Re: Icons?

Post by Peet »

Or the icon parameter has to be an icon object? I dunno, java is rotting my brain.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Icons?

Post by Argh »

Looks like the callin is no longer valid :P 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.
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Re: Icons?

Post by Pressure Line »

could always make the "icon" 1px * 1px and transparent...
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Icons?

Post by jK »

  • Spring.SetUnitDefIcon() is a LuaUI only functions.
  • You should use Spring.SetUnitNoMinimap() and/or Spring.SetUnitNoDraw
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Icons?

Post by Argh »

Ok, I'll take a look at that, once I have the rest of this demo set up. Thanks!
Post Reply

Return to “Lua Scripts”