Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- IRE mapping script room label command
- ^room label (.+)$
- mmp.roomLabel(matches[2])
- -- room label the room I'm in
- -- room label 342 this is a label in room 342
- -- room label green this is a green label where I'm at
- -- room label green black this is a green to black label where I'm at
- -- room label 34 green black this is a green to black label at room 34
- -- how it works: split input string into tokens by space, then determine
- -- what to do by checking first few tokens, and finally call the local
- -- function with the proper arguments
- function mmp.roomLabel(input)
- local tk = input:split(" ")
- local room, fg, bg, message = mmp.currentroom, "yellow", "red", "Some room label"
- -- input always have to be something, so tk[1] at least always exists
- if tonumber(tk[1]) then
- room = tonumber(table.remove(tk, 1)) -- remove the number, so we're left with the colors or msg
- end
- -- next: is this a foreground color?
- if tk[1] and color_table[tk[1]] then
- fg = table.remove(tk, 1)
- end
- -- next: is this a backround color?
- if tk[1] and color_table[tk[1]] then
- bg = table.remove(tk, 1)
- end
- -- the rest would be our message
- if tk[1] then
- message = table.concat(tk, " ")
- end
- -- if we haven't provided a room ID and we don't know where we are yet, we can't make a label
- if not room then
- mmp.echo("We don't know where we are to make a label here.") return
- end
- local x,y = getRoomCoordinates(room)
- local f1,f2,f3 = unpack(color_table[fg])
- local b1,b2,b3 = unpack(color_table[bg])
- -- finally: do it :)
- local lid = createMapLabel(getRoomArea(room), message, x, y, f1,f2,f3, b1,b2,b3)
- mmp.echo(string.format("Created new label #%d '%s' in %s.", lid, message, getRoomAreaName(getRoomArea(room))))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement