Author Topic: Look.c to automatically display corresponding ascii art if present  (Read 3222 times)

Offline amylase

  • Friend
  • **
  • Posts: 73
    • View Profile
    • gpLand
Mudlib: DeadSouls 2.1 on Windows XP
Driver: MudOS v22.2b14
Filename: /ds/lib/verbs/items/look.c

Hi guys, nothing too exciting. Just adding a line to /verbs/items/look.c to automatically display corresponding ascii art if file present. For example "look at jennybot" (/domains/campus/npc/jennybot.c) will automatically search for  /domains/campus/npc/jennybot.asc which is basically a text file containing ascii representation of what this bot looks like. If .asc is present, look.c will longcat  (http://lpmuds.net/forum/index.php?topic=210.0) it and then carry on with the rest of usual look output.

Added this line to do_look_at_obj() in /ds/lib/verbs/items/look.c immediately before "return ob->eventShow(this_player());"
Code: [Select]
  if(file_exists(base_name(ob)+".asc")) load_object("/secure/cmds/creators/longcat")->cmd(base_name(ob)+".asc");

So here is what the function looks like afterwards
Code: [Select]
varargs mixed do_look_at_obj(object ob, mixed arg) {
      if(ob->GetInvis() && !archp(this_player()) &&
      base_name(ob) != LIB_DUMMY && !inherits(LIB_DUMMY,ob) ){
write("There is no "+arg+" here.");
return 1;
    } 

  if(file_exists(base_name(ob)+".asc")) load_object("/secure/cmds/creators/longcat")->cmd(base_name(ob)+".asc");

  return ob->eventShow(this_player());
}

Thanks again to Cratylus for explaining correct syntax for load object and cmd, and coming up with  longcat in a few seconds.

Now I wasn't too big a fan of ascii stuff until I stumbled across this impressive gif/jpg/bmp2txt convertor. It actually does a very good job turning pictures into text (http://ascgendotnet.jmsoftware.co.uk/) plus various smart features such as adjusting contrast and brightness of text output. Color mode available. As it's open source, source code can also be downloaded from its website.


« Last Edit: December 20, 2006, 10:14:58 AM by amylase »

Offline Atomic

  • BFF
  • ***
  • Posts: 112
  • To infinity and beyond!
    • View Profile
Re: Look.c to automatically display corresponding ascii art if present
« Reply #1 on: December 22, 2006, 10:09:24 AM »
Nice! Is the girl from the original color pic Open Source too?  ;D

On a serious note: ascii art that big is definately gonna get screwed up by the maximum amount of
lines that the screen-width allows.
Always remember that the early bird gets the worm first, but the fi...*SNAP*...second mouse gets the cheese.

Offline amylase

  • Friend
  • **
  • Posts: 73
    • View Profile
    • gpLand
Re: Look.c to automatically display corresponding ascii art if present
« Reply #2 on: December 23, 2006, 06:44:07 PM »
Hi atomic, nice black belt. Is that you?

Both pictures come directly from ascgen website and both pictures have no copyright. A note on color: you can save color output only in HTML format ie. will require a little bit of work to show up properly in color in game.

In terms of fitting to screen, it probably also depends on the resolution setting of your video card as well as "screen" setting in game. I'm displaying on 1024 x 768 with screen 150 150 which handles moderately large ascii art quite well.

Offline Atomic

  • BFF
  • ***
  • Posts: 112
  • To infinity and beyond!
    • View Profile
Re: Look.c to automatically display corresponding ascii art if present
« Reply #3 on: December 25, 2006, 08:19:59 AM »
It is me  ;) No black belt though, it has been brown for years,
never really took the time to train 4-5 times a week to go for black,
which still is high on my wishlist though...
Always remember that the early bird gets the worm first, but the fi...*SNAP*...second mouse gets the cheese.

Offline amylase

  • Friend
  • **
  • Posts: 73
    • View Profile
    • gpLand
Re: Look.c to automatically display corresponding ascii art if present
« Reply #4 on: October 28, 2007, 07:32:28 AM »
Nice! Is the girl from the original color pic Open Source too?  ;D

Okay, I just noticed Atomic made a joke back in December 2006. Sorry about that Atomic, my fault. I am very slow on jokes (as a matter of fact abstract thinking also). On quick review of some of the comments from the past, I came across your remark about whether this girl in the picture is also open source. Your comment was taken literally by me last year.

Offline Atomic

  • BFF
  • ***
  • Posts: 112
  • To infinity and beyond!
    • View Profile
Re: Look.c to automatically display corresponding ascii art if present
« Reply #5 on: October 29, 2007, 09:42:43 AM »
Sweet, nearly a year to reply to a joke.

That's good fun on itself :)
Always remember that the early bird gets the worm first, but the fi...*SNAP*...second mouse gets the cheese.