Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | None | 0 0
  1. -- IRE mapping script room label command
  2. ^room label (.+)$
  3. mmp.roomLabel(matches[2])
  4.  
  5.  
  6. -- room label the room I'm in
  7. -- room label 342 this is a label in room 342
  8. -- room label green this is a green label where I'm at
  9. -- room label green black this is a green to black label where I'm at
  10. -- room label 34 green black this is a green to black label at room 34
  11. -- how it works: split input string into tokens by space, then determine
  12. -- what to do by checking first few tokens, and finally call the local
  13. -- function with the proper arguments
  14. function mmp.roomLabel(input)
  15.   local tk = input:split(" ")
  16.   local room, fg, bg, message = mmp.currentroom, "yellow", "red", "Some room label"
  17.  
  18.   -- input always have to be something, so tk[1] at least always exists
  19.   if tonumber(tk[1]) then
  20.     room = tonumber(table.remove(tk, 1)) -- remove the number, so we're left with the colors or msg
  21.   end
  22.  
  23.   -- next: is this a foreground color?
  24.   if tk[1] and color_table[tk[1]] then
  25.     fg = table.remove(tk, 1)
  26.   end
  27.  
  28.   -- next: is this a backround color?
  29.   if tk[1] and color_table[tk[1]] then
  30.     bg = table.remove(tk, 1)
  31.   end
  32.  
  33.   -- the rest would be our message
  34.   if tk[1] then
  35.     message = table.concat(tk, " ")
  36.   end
  37.  
  38.   -- if we haven't provided a room ID and we don't know where we are yet, we can't make a label
  39.   if not room then
  40.     mmp.echo("We don't know where we are to make a label here.") return
  41.   end
  42.  
  43.   local x,y = getRoomCoordinates(room)
  44.   local f1,f2,f3 = unpack(color_table[fg])
  45.   local b1,b2,b3 = unpack(color_table[bg])
  46.  
  47.   -- finally: do it :)
  48.  
  49.   local lid = createMapLabel(getRoomArea(room), message, x, y, f1,f2,f3, b1,b2,b3)
  50.   mmp.echo(string.format("Created new label #%d '%s' in %s.", lid, message, getRoomAreaName(getRoomArea(room))))
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement