From 3f95220951ba55fc3544eed530848adbf453135d Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Thu, 28 May 2020 15:33:53 -0300 Subject: ...And, I think I've found Micksha's bug. '-' --- npc/functions/util.txt | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'npc/functions') diff --git a/npc/functions/util.txt b/npc/functions/util.txt index 164c7d7d8..7bd0b9dbe 100644 --- a/npc/functions/util.txt +++ b/npc/functions/util.txt @@ -918,6 +918,28 @@ function script EnterTown { return; } +// Convert map name to location id +// LocToMap( LocName ) +function script LocToMap { + // Fill variable + .@v$=getarg(0); + + // Error code + if (playerattached()) + .@err=RB_DEFAULT; + else + .@err=RB_DEBUGMES; + + // Validade variable, see npc/000-1/exit.txt first + setarray .@mapx$, "005-1", "003-1", "009-1", "012-1", "017-1", "018-5", "020-1", "024-1"; + setarray .@locs$, "Candor", "Tulim", "Halin", "Hurns", "LoF", "Lilit", "Nival", "Frostia"; + .@lx=array_find(.@locs$, .@v$); + if (.@lx < 0) + return Exception("Invalid map passed to MapToLoc: "+.@v$, .@err); + + return .@locs$[.@lx]; +} + // Convert map name to location id // MapToLoc( MapName ) function script MapToLoc { @@ -933,7 +955,7 @@ function script MapToLoc { // Validade variable, see npc/000-1/exit.txt first setarray .@mapx$, "005-1", "003-1", "009-1", "012-1", "017-1", "018-5", "020-1", "024-1"; setarray .@locs$, "Candor", "Tulim", "Halin", "Hurns", "LoF", "Lilit", "Nival", "Frostia"; - .@lx=array_find(.@locs$, .@v$); + .@lx=array_find(.@mapx$, .@v$); if (.@lx < 0) return Exception("Invalid map passed to MapToLoc: "+.@v$, .@err); -- cgit v1.2.3-70-g09d2