Help With Changing Button Names

Help With Changing Button Names

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

Moderator: Moderators

Post Reply
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Help With Changing Button Names

Post by SanadaUjiosan »

I'm working on modifying unit_morph.lua so that I can have customized button names per unit. I poked into it and I actually managed to figure it out (Lua leveling up for me!) but then I realized that if I stop the morph mid-morph, the Stop text on the button stays instead of going back to the customized button name.

I'm at a loss, but I imagine you fine people can give me some help. Here is what I modified (probably filled with nastiness, but it does most of what I want :-) ) First batch starts at line ~279, second batch starts at line ~381, and the last batch at ~ 406 :

Unchanged version on the CT SVN (there's so many versions of unit_morph floating around, I hold onto the one CT has because it snaps buildings to the grid)

Code: Select all

    newData.texture = morphData.texture
    newData.text = morphData.text
    newData.name = morphData.name
    return newData
  end
end

...

if morphDef.name then
    morphCmdDesc.name = ''.. morphDef.name
  else
    morphCmdDesc.name = '#' .. morphDef.into   --//only works with a patched layout.lua or the TweakedLayout widget!
  end
  
  if morphDef.texture then
    morphCmdDesc.texture = "LuaRules/Images/Morph/".. morphDef.texture
    --morphCmdDesc.name = ''
  else
    morphCmdDesc.texture = "#" .. morphDef.into   --//only works with a patched layout.lua or the TweakedLayout widget!
  end

...

  morphCmdDesc.tooltip = nil
  morphCmdDesc.texture = nil
  morphCmdDesc.text = nil
  morphCmdDesc.name = nil
end
Sorry if I didn't provide enough/correct info for help, I don't post often in the lua part of the boards :P
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Help With Changing Button Names

Post by SanadaUjiosan »

It's impossible!

I managed to track down the culprit for making the red Stop appear, and deleted that. So now morphing in CT doesn't say Stop while you're morphing, although you can still of course stop. This isn't desired but it's a bullet I'll bite to get customized button names.

If someone wants to speak up on how to remedy this, be my guest. At the top of the gadget I added a note detailing what I did.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Help With Changing Button Names

Post by jK »

I really don't see your problem.
Just reset the cmddesc name in StopMorph(). Also you better revert your whole commit, cause 90% of it is just wrong.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Help With Changing Button Names

Post by FLOZi »

SanadaUjiosan wrote:It's impossible!

I managed to track down the culprit for making the red Stop appear, and deleted that. So now morphing in CT doesn't say Stop while you're morphing, although you can still of course stop. This isn't desired but it's a bullet I'll bite to get customized button names.

If someone wants to speak up on how to remedy this, be my guest. At the top of the gadget I added a note detailing what I did.
S44 version of morph does it, have fun integrating the right changes :P
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Help With Changing Button Names

Post by SanadaUjiosan »

FLOZi wrote:S44 version of morph does it, have fun integrating the right changes :P
Actually wasn't that hard :P

So can anyone explain real quick why:

Code: Select all

  morphCmdDesc.name = morphDef.name or "Deploy"
works and:

Code: Select all

if morphDef.name then
    morphCmdDesc.name = ''.. morphDef.name
  else
    morphCmdDesc.name = '#' .. morphDef.into   --//only works with a patched layout.lua or the TweakedLayout widget!
  end
doesn't? I'm guessing it is because of the "if ... then", but I don't know.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Help With Changing Button Names

Post by jK »

Code: Select all

    morphCmdDesc.name = '#' .. morphDef.into   --//only works with a patched layout.lua or the TweakedLayout widget!
You copied that line from a few lines below, BUT there it is morphCmdDesc.texture = ... !
User avatar
Deadnight Warrior
Posts: 183
Joined: 08 Jun 2009, 17:59

Re: Help With Changing Button Names

Post by Deadnight Warrior »

XTA version of morph gadget allows you to name your morph button anyway you like and associate any texture you want with it (borrowed some code from The Cursed and added some of my own). Just look into the gadget config file for details.
You'll just have to remove "Stop" if you don't want it to appear while morphing.
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Help With Changing Button Names

Post by SanadaUjiosan »

I got morph doing what I want, thanks though Deadnight Warrior
Post Reply

Return to “Lua Scripts”