From 08195da4e4ec4ecdaeb4aac3c8f38fa057f1e563 Mon Sep 17 00:00:00 2001 From: Joseph Botosh Date: Thu, 24 Sep 2015 05:14:29 +0300 Subject: add optional first integer arg to narrator and speech functions -- number of blank lines at beginning --- npc/functions/main.txt | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'npc') diff --git a/npc/functions/main.txt b/npc/functions/main.txt index b78c9433..f44fb44e 100644 --- a/npc/functions/main.txt +++ b/npc/functions/main.txt @@ -76,9 +76,24 @@ function script strip { return substr(.@s$, .@start, .@end); } + +// Function to show narrator text. Accepts string args. +// If first arg is a number N, it prints N blank lines at beginning. +// Default number of blank lines is 1. function script narrator { + .@start = 0; + .@blank_lines = 1; + if (getargcount() > 1 && !isstr(getarg(0))) + { + .@start = 1; + .@blank_lines = getarg(0); + } + + for (.@i = 0; .@i < .@blank_lines; .@i++) + mes ""; + mes l("[Narrator]"); - for (.@i = 0; .@i < getargcount(); .@i++) + for (.@i = .@start; .@i < getargcount(); .@i++) { mes col(getarg(.@i), 9); next; @@ -86,9 +101,24 @@ function script narrator { return; } + +// Function to show NPC speech. Accepts string args. +// If first arg is a number N, it prints N blank lines at beginning. +// Default number of blank lines is 1. function script speech { + .@start = 0; + .@blank_lines = 1; + if (getargcount() > 1 && !isstr(getarg(0))) + { + .@start = 1; + .@blank_lines = getarg(0); + } + + for (.@i = 0; .@i < .@blank_lines; .@i++) + mes ""; + mesn; - for (.@i = 0; .@i < getargcount(); .@i++) + for (.@i = .@start; .@i < getargcount(); .@i++) { mesq getarg(.@i); next; -- cgit v1.2.3-70-g09d2