[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Overriding Class Variables
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Overriding Class Variables

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Xavious   (41 posts)  [Biography] bio
Date Mon 13 Jul 2015 06:10 PM (UTC)
Message
I'm using mapper.lua to tailor a mapper for my mud. However, some of the default_configs don't apply to my situation. Is there a way for me to override these values somehow to prevent them from being added to the configuration list on the mapper.init() method without modifying the class file?

This has become a concern because my configuration list has become too large to display. I know I could just modify the class file to accomplish what I want, but I'm hoping Lua offers some way to override the class without having to change the class file.
[Go to top] top

Posted by Nick Gammon   Australia  (21,324 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Mon 13 Jul 2015 08:50 PM (UTC)
Message
What class file are you referring to?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Xavious   (41 posts)  [Biography] bio
Date Reply #2 on Mon 13 Jul 2015 09:32 PM (UTC)
Message
mapper.lua

I want to override the default_config table to not include a few pieces.


local default_config = {
  -- assorted colours
  BACKGROUND_COLOUR       = { name = "Background",        colour =  ColourNameToRGB "lightseagreen", },
  ROOM_COLOUR             = { name = "Room",              colour =  ColourNameToRGB "cyan", },
  EXIT_COLOUR             = { name = "Exit",              colour =  ColourNameToRGB "darkgreen", },
  EXIT_COLOUR_UP_DOWN     = { name = "Exit up/down",      colour =  ColourNameToRGB "darkmagenta", },
  EXIT_COLOUR_IN_OUT      = { name = "Exit in/out",       colour =  ColourNameToRGB "#3775E8", },
  UNKNOWN_ROOM_COLOUR     = { name = "Unknown room",      colour =  ColourNameToRGB "#00CACA", },
  MAPPER_NOTE_COLOUR      = { name = "Messages",          colour =  ColourNameToRGB "lightgreen" },
  
  ROOM_NAME_TEXT          = { name = "Room name text",    colour = ColourNameToRGB "#BEF3F1", },
  ROOM_NAME_FILL          = { name = "Room name fill",    colour = ColourNameToRGB "#105653", },
  ROOM_NAME_BORDER        = { name = "Room name box",     colour = ColourNameToRGB "black", },
  
  AREA_NAME_TEXT          = { name = "Area name text",    colour = ColourNameToRGB "#BEF3F1",},
  AREA_NAME_FILL          = { name = "Area name fill",    colour = ColourNameToRGB "#105653", },   
  AREA_NAME_BORDER        = { name = "Area name box",     colour = ColourNameToRGB "black", },
               
  FONT = { name =  get_preferred_font {"Dina",  "Lucida Console",  "Fixedsys", "Courier", "Sylfaen",} ,
           size = 8
         } ,
         
  -- size of map window
  WINDOW = { width = 400, height = 400 },
  
  -- how far from where we are standing to draw (rooms)
  SCAN = { depth = 30 },
  
  -- speedwalk delay
  DELAY = { time = 0.3 },
  
  -- how many seconds to show "recent visit" lines (default 3 minutes)
  LAST_VISIT_TIME = { time = 60 * 3 },  
  
  }
[Go to top] top

Posted by Xavious   (41 posts)  [Biography] bio
Date Reply #3 on Mon 13 Jul 2015 10:49 PM (UTC)

Amended on Tue 14 Jul 2015 03:20 AM (UTC) by Xavious

Message
"Exit In/Out" isn't applicable to my mud and I don't intend to use Area either. I could easily change the mapper.lua file, but for the sake of OOP and keeping things self contained, I was hoping I could override the default_config{} table somehow to exclude fields I don't want, rather than making changes to mapper.lua

I wouldn't even bother, but when this config list is too large, it will exclude the color configs from the configuration menu that comes up when you click "*" and I've added a lot of extra room flags.
[Go to top] top

Posted by Nick Gammon   Australia  (21,324 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Wed 15 Jul 2015 05:33 AM (UTC)
Message
After (maybe) calling mapper.init, just make the ones you don't want to be nil.

eg.


config.UNKNOWN_ROOM_COLOUR = nil


If they aren't in the config table, they won't be listed.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Xavious   (41 posts)  [Biography] bio
Date Reply #5 on Wed 15 Jul 2015 06:39 PM (UTC)
Message
I added so many items that the colors were being omitted from the window when using the default window height of 400.

Exploring this function in mapper.lua, I realized why it was happening:

local function draw_configuration ()



If the size exceeds the mapper window, it reverts to only displaying the main 4 configurations that are unrelated to color.

I was able to work around this by setting some configuration colors that I wasn't using to nil, like you suggested. Thanks Nick.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


2,726 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]