From 27fc261dcbfbbe20611efbb4aac8bf7a1d91009a Mon Sep 17 00:00:00 2001 From: Joseph Botosh Date: Thu, 24 Sep 2015 22:07:28 +0300 Subject: update function narrator and speech: using optional bit flags as first arg --- npc/functions/main.txt | 57 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 16 deletions(-) (limited to 'npc') diff --git a/npc/functions/main.txt b/npc/functions/main.txt index f44fb44e..d510f05b 100644 --- a/npc/functions/main.txt +++ b/npc/functions/main.txt @@ -78,51 +78,76 @@ function script strip { // 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. +// If first arg is a number N, then it represents bit flags. +// Bit flags : +// 0x1 -- blank line at beginning +// 0x2 -- blank line at the end +// 0x4 -- use last "next;" function script narrator { .@start = 0; - .@blank_lines = 1; - if (getargcount() > 1 && !isstr(getarg(0))) + .@argc = getargcount(); + .@flags = 0; + + if (.@argc > 1 && !isstr(getarg(0))) { .@start = 1; - .@blank_lines = getarg(0); + .@flags = getarg(0); } - for (.@i = 0; .@i < .@blank_lines; .@i++) + if (.@flags & 0x1) mes ""; mes l("[Narrator]"); - for (.@i = .@start; .@i < getargcount(); .@i++) + for (.@i = .@start; .@i < .@argc; .@i++) { mes col(getarg(.@i), 9); - next; + if (.@i < .@argc - 1) + next; } + + if (.@flags & 0x4) + next; + else if (.@flags & 0x2) + mes ""; + 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. +// If first arg is a number N, then it represents bit flags. +// Bit flags : +// 0x1 -- blank line at beginning +// 0x2 -- blank line at the end +// 0x4 -- use last "next;" function script speech { .@start = 0; - .@blank_lines = 1; - if (getargcount() > 1 && !isstr(getarg(0))) + .@argc = getargcount(); + .@flags = 0; + + if (.@argc > 1 && !isstr(getarg(0))) { .@start = 1; - .@blank_lines = getarg(0); + .@flags = getarg(0); } - for (.@i = 0; .@i < .@blank_lines; .@i++) + if (.@flags & 0x1) mes ""; mesn; - for (.@i = .@start; .@i < getargcount(); .@i++) + for (.@i = .@start; .@i < .@argc; .@i++) { mesq getarg(.@i); - next; + + if (.@i < .@argc - 1) + next; } + + if (.@flags & 0x4) + next; + else if (.@flags & 0x2) + mes ""; + return; } -- cgit v1.2.3-70-g09d2