Hi!
Is there a way to have unique descriptions on the morph button? With that I mean that instead of "morph" the button will say something different for certain units. I found the part of the skript which defines it to say "Morph" and I got the impression that this was made with such a feature in mind. So it would be great if like for that old deployment gadget you could define a "name = xxx" tag in the morph definition file in order to get a different text on the button depending on which fits the unit right.
That imo would be much nicer than disabling the text and baking it into the unit's buildpic. There also should be quite some mods which would be able to use that like S44 so you don't always get a "Deploy" button but a different one e.g. when getting mobile again and so on.
So if that's already possible with the current moprh gadget how has it to be done?
Morph Gadget - Getting different button texts?
Moderator: Moderators
-
- Posts: 1176
- Joined: 23 Aug 2007, 19:46
Re: Morph Gadget - Getting different button texts?
About line 300, AddMorphCmdDesc, make this simple change:
before morphCmdDesc.texture = "#" .. morphDef.into add:
morphCmdDesc.name = morphDef.name or "Morph"
before morphCmdDesc.texture = nil add:
morphCmdDesc.name = nil
Then you should be able to add name = "whatever" into the moph defs.
before morphCmdDesc.texture = "#" .. morphDef.into add:
morphCmdDesc.name = morphDef.name or "Morph"
before morphCmdDesc.texture = nil add:
morphCmdDesc.name = nil
Then you should be able to add name = "whatever" into the moph defs.
Re: Morph Gadget - Getting different button texts?
Another way (a little more generic) is to just edit the command description post-create. This has lots of uses.
Here's a very basic example:
Lurker's way is easier, for that specific job. I just figured that a few people might want to know, more broadly, about how to go about that kind of thing. There are other ways to do it, such as reading some customParams or building a table, but this is very easy code for one-offs.
Here's a very basic example:
Code: Select all
function gadget:UnitFromFactory(unitID, unitDefID, unitTeam, factID, factDefID, userOrders)
local cmdID
-- define CMD_MORPH with whatever ID it uses in the Morph Gadget
cmdID = Spring.FindUnitCmdDesc(unitID, CMD_MORPH)
--get the name of the Unit, and check for the relevant command
if cmdID ~= nil and UnitDefs[unitDefID].name == "MyUnitNameHere" then
EditUnitCmdDesc(unitID, cmdID, {
name = "MyNiftyMorph",
tooltip = "Here's all about the cool stuff that happens when you click this",
})
end
end
-
- Posts: 1176
- Joined: 23 Aug 2007, 19:46
Re: Morph Gadget - Getting different button texts?
@lurker:
Thanks - while your idea basically works just fine I had to add a
newData.name = morphData.name
somewhere around line 170 in order to make it actually read out the tags you want to give it as "variable"...
@Argh:
Thanks too - as I've definitely planned to give LUA a shoot I at one point sure will have a look at how what you proposed would have worked...
Thanks - while your idea basically works just fine I had to add a
newData.name = morphData.name
somewhere around line 170 in order to make it actually read out the tags you want to give it as "variable"...
@Argh:
Thanks too - as I've definitely planned to give LUA a shoot I at one point sure will have a look at how what you proposed would have worked...