From 193b8ca5ffc82487872a147504e830d9fc033a8e Mon Sep 17 00:00:00 2001 From: gumi Date: Sat, 22 Aug 2020 13:56:52 -0400 Subject: add a command to display images in NPC windows --- npc/functions/main.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/npc/functions/main.txt b/npc/functions/main.txt index d65f634f..f3b58d01 100644 --- a/npc/functions/main.txt +++ b/npc/functions/main.txt @@ -73,6 +73,27 @@ function script mesc { return mes(col(getarg(0, ""), getarg(1, 9))); } +// *showimage(""); +// Displays an image in the NPC window. If no file extension is provided, it is +// assumed to be a PNG file. The image path is relative to client-data/graphics. +// example: +// showimage("guiicons/flags/fr"); +function script showimage { + .@file$ = getarg(0); + + if (!endswith(getarg(0), ".jpg") && !endswith(getarg(0), ".png")) { + .@file$ += ".png"; + } + + if (charat(getarg(0), 0) == "/") { + .@file$ = delchar(.@file$, 0); // absolute path from root of client-data + } else if (!startswith(getarg(0), "help/") && !startswith(getarg(0), "graphics/") ) { + .@file$ = "graphics/" + .@file$; // assume relative to graphics/ + } + + return mesf("~~~%s~", .@file$); +} + function script adddefaultskills { if (getskilllv(NV_BASIC) < 6) { -- cgit v1.2.3-60-g2f50