metalmap/pathmap problem with ctrlpanel.lua

metalmap/pathmap problem with ctrlpanel.lua

Discuss your problems with the latest release of the engine here. Problems with games, maps or other utilities belong in their respective forums.

Moderator: Moderators

Post Reply
Chojin
Posts: 141
Joined: 04 Oct 2006, 11:22

metalmap/pathmap problem with ctrlpanel.lua

Post by Chojin »

I have been trying the ctrlpanels from: http://taspring.clan-sy.com/phpbb/viewtopic.php?t=7449

I'd like to use these panels or maybe even modify them a bit. But I ran into this problem:

When placing a metal extractor the view is changed to metalmap. On a few maps I do like to change the view to pathmap, because it's pretty difficult to find a spot for the big moho metal extractor sometimes.

Now, when I use either of the ctrlpanel.lua, the view is immediately reverted back to metalmap. Most of the times so quick, that I couldn't look for a valid spot to place the MME at all.

This only happens, when one of those ctrlpanel.lua is in place. Without it changing between the views los/metalmap/pathmap/elevation works fine while placing a metal extractor.

Could it be, that the UpdateLayout-function needs more checks? What checks should I add?


As a side note: pathmap is not working for construction planes at all.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

I'm to hear that someone knows that UpdateLayout(),
exists, and apparently even knows what it does :-)

Here's a snippet I tried out ...

Code: Select all

function UpdateLayout(commandsChanged, page, alt, ctrl, meta, shift)

  local needUpdate =  ... blah ... blah ... blah ...

  -- do not ask for updates if we are trying to build a mex,
  -- avoid the automatic reversions to metalmap from pathmap
  local slot, id, type, name = Spring.GetInCommand()  
  if ((slot ~= nil) and (id ~= nil) and (id < 0)) then
    unitDef = UnitDefs[-id] 
    if (unitDef ~= nil) then
      if (unitDef.extractsMetal > 0) then
        needUpdate = false  --  do not ask for an update
      end
    end  
  end
  
  return needUpdate
end
Chojin
Posts: 141
Joined: 04 Oct 2006, 11:22

Post by Chojin »

Ahhh, thanks a lot, Trepan, works like a charm now :-)

Now I just need to read through the other code in ctrlpanel.lua ;-) Is there any written doc/help about the functions that may be used in it?

I am going to download spring's source tarball, but of course I would really appreciate any pointers you might have.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

Is there any written doc/help about the functions that may be used in it?
Nope, not really. Those examples, and reading through
rts/Game/UI/IconLayoutHandler.cxx are probably the best
you'll find right now. I do intend to do some doc work on the
additions made to 0.73b1/2, but I'm still playing around with
code at the moment ;)

https://taspring.clan-sy.com/svn/spring ... andler.cpp


P.S. I forgot, I can give you one tip that you may find useful:


HOWTO Print The LUA Definition Tables:

1. Move uikeys.txt and ctrlpanel.lua to a temporary directory
2. Start spring with the mod to be printed
3. Type: /keydebug 2
4. Move uikeys.txt and ctrlpanel.lua back to the config directory
5. Type: /ctrlpanel
6. Type: /layout reload

* The Unitdefs[] and WeaponDefs[] tables should
have been written into your infolog.txt file.
Chojin
Posts: 141
Joined: 04 Oct 2006, 11:22

Post by Chojin »

Alright, thanks again :-)

Actually, I am not really qualified, but I think that in the CIconLayoutHandler::LayoutIcons function of IconLayoutHandler.cpp it should be Call_LayoutIcons at line 286:

Code: Select all

 245 bool CIconLayoutHandler::LayoutIcons(int& xIcons, int& yIcons,
 ...
 282         // call the function
 283         const int error = lua_pcall(L, 4, LUA_MULTRET, 0);
 284         if (error != 0) {
 285                 logOutput.Print("error = %i, %s, %s\n", error,
 286                                 "Call_ConfigureLayout", lua_tostring(L, -1));
 287                 lua_pop(L, 1);
 288                 return false;
 289         }
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

A little C&P glitch in the debug message ;-)
It's being fixed in SVN, thanks.
Post Reply

Return to “Help & Bugs”