From f507cb7bcb8eca0232bb5b94bd1aaa53c81029cb Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Sat, 11 Aug 2012 22:06:11 +0000 Subject: [PATCH] Fix error handling in Lua function run(). Made the samples use run() instead of dofile() git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1989 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- share/grafx2/scripts/samples_2.4/brush/ApplyColor.lua | 2 +- share/grafx2/scripts/samples_2.4/demo/3DPalette.lua | 2 +- share/grafx2/scripts/samples_2.4/demo/Spritesheet.lua | 2 +- share/grafx2/scripts/samples_2.4/libs/dawnbringer_lib.lua | 8 +++----- src/factory.c | 4 ++-- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/share/grafx2/scripts/samples_2.4/brush/ApplyColor.lua b/share/grafx2/scripts/samples_2.4/brush/ApplyColor.lua index 3da26c1d..23dc9ca5 100644 --- a/share/grafx2/scripts/samples_2.4/brush/ApplyColor.lua +++ b/share/grafx2/scripts/samples_2.4/brush/ApplyColor.lua @@ -9,7 +9,7 @@ -- as published by the Free Software Foundation; version 2 -- of the License. See -dofile("../libs/dawnbringer_lib.lua") +run("../libs/dawnbringer_lib.lua") OK,tin,clz,fade,amt,brikeep,falloff,nobg,briweight = inputbox("Apply PenColor 2 Brush", diff --git a/share/grafx2/scripts/samples_2.4/demo/3DPalette.lua b/share/grafx2/scripts/samples_2.4/demo/3DPalette.lua index b496240d..626880ed 100644 --- a/share/grafx2/scripts/samples_2.4/demo/3DPalette.lua +++ b/share/grafx2/scripts/samples_2.4/demo/3DPalette.lua @@ -15,7 +15,7 @@ -- "-" (Num): Zoom Out -- Esc: Exit script -dofile("../libs/dawnbringer_lib.lua") +run("../libs/dawnbringer_lib.lua") BRIDIAG_SHOW = 1 -- Show brightness/Grayscale diagonal (1 = on, 0 = off) diff --git a/share/grafx2/scripts/samples_2.4/demo/Spritesheet.lua b/share/grafx2/scripts/samples_2.4/demo/Spritesheet.lua index 171dcfaa..45d43555 100644 --- a/share/grafx2/scripts/samples_2.4/demo/Spritesheet.lua +++ b/share/grafx2/scripts/samples_2.4/demo/Spritesheet.lua @@ -2,7 +2,7 @@ --Spare page holds data - Plays on current --by Richard Fhager -dofile("../libs/memory.lua") +run("../libs/memory.lua") arg=memory.load({XS=16,YS=16,SPACE=1,FRAMES=8,XOFF=0,YOFF=0,FPS=10}) diff --git a/share/grafx2/scripts/samples_2.4/libs/dawnbringer_lib.lua b/share/grafx2/scripts/samples_2.4/libs/dawnbringer_lib.lua index 541a5cb0..d8539314 100644 --- a/share/grafx2/scripts/samples_2.4/libs/dawnbringer_lib.lua +++ b/share/grafx2/scripts/samples_2.4/libs/dawnbringer_lib.lua @@ -12,12 +12,10 @@ -- You may access these functions in your own scripts by loading this library, -- just add the follwing line as one of the first instructions: -- --- require("dawnbringer_lib") --- --- or --- --- dofile("dawnbringer_lib.lua") +-- run("dawnbringer_lib") -- +-- If the script is not in the same directory, use a relative path +-- like run("../libs/dawnbringer_lib.lua") -- -- Note that the functions must be called with the full library object-name, "db.function_name..." -- diff --git a/src/factory.c b/src/factory.c index 0d9b8343..53606bf5 100644 --- a/src/factory.c +++ b/src/factory.c @@ -1432,9 +1432,9 @@ int L_Run(lua_State* L) // confusing than helpful. if (nb_args>0 && (message = lua_tostring(L, nb_args))!=NULL) - Verbose_message("Error running script", message); + return luaL_error(L, message); else - Warning_message("Unknown error running script!"); + return luaL_error(L, "run: Unknown error running script!"); } nested_calls--; // restore directory