Index: Daodan/src/BFW_ScriptLang.h
===================================================================
--- Daodan/src/BFW_ScriptLang.h	(revision 445)
+++ Daodan/src/BFW_ScriptLang.h	(revision 445)
@@ -0,0 +1,44 @@
+#pragma once
+#ifndef BFW_SCRIPTLANG_H
+#define BFW_SCRIPTLANG_H
+
+#include "Daodan.h"
+
+#include <stdint.h>
+#include <stdbool.h>
+
+typedef enum {
+	sl_int32,
+	sl_str32,
+	sl_float,
+	sl_bool,  /* Actually int32 0 or 1. */
+	sl_void,
+} sl_type;
+
+typedef struct {
+	sl_type type;
+	union {
+		void*   value;
+		int32_t value_int32;
+		char*   value_str32;
+		float   value_float;
+		bool    value_bool;
+	};
+} sl_arg;
+
+typedef struct {
+	char*    name;
+	char*    calllocation; //maybe
+	int      linenumber;   //perhaps
+} sl_callinfo;
+
+typedef uint16_t (ONICALL *sl_func)(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret);
+
+uint16_t ONICALL SLrScript_Command_Register_ReturnType(char* name, char* desc, char* argfmt, sl_type type, sl_func callback);
+uint16_t ONICALL SLrScript_Command_Register_Void(char* name, char* desc, char* argfmt, sl_func callback);
+uint16_t ONICALL SLrGlobalVariable_Register_Int32(char* name, char* desc, int32_t* data);
+uint16_t ONICALL SLrGlobalVariable_Register_Float(char* name, char* desc, float* data);
+uint16_t ONICALL SLrGlobalVariable_Register_Bool(char* name, char* desc, uint32_t* data);
+uint16_t ONICALL SLrGlobalVariable_Register_String(char* name, char* desc, char* data);
+
+#endif
Index: Daodan/src/BFW_ScriptingLanguage.h
===================================================================
--- Daodan/src/BFW_ScriptingLanguage.h	(revision 444)
+++ 	(revision )
@@ -1,43 +1,0 @@
-#pragma once
-#ifndef BFW_UTILITY_H
-#define BFW_UTILITY_H
-
-#include "Daodan.h"
-
-#include <stdint.h>
-#include <stdbool.h>
-
-typedef enum {
-	sl_int32,
-	sl_str32, /* it's fixed length, 32 bytes. */
-	sl_float,
-	sl_bool,  /* Actually int32 0 or 1. */
-	sl_void,
-} sl_type;
-
-typedef struct {
-	sl_type type;
-	union {
-		void*   value;
-		int32_t value_int32;
-		char*   value_str32;
-		float   value_float;
-		bool    value_bool;
-	};
-} sl_arg;
-
-typedef struct {
-	char*    name;
-	char*    calllocation; //maybe
-} sl_callinfo;
-
-typedef uint16_t (ONICALL *sl_func)(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret);
-
-uint16_t ONICALL SLrScript_Command_Register_ReturnType(char* name, char* desc, char* argfmt, sl_type type, sl_func callback);
-uint16_t ONICALL SLrScript_Command_Register_Void(char* name, char* desc, char* argfmt, sl_func callback);
-uint16_t ONICALL SLrGlobalVariable_Register_Int32(char* name, char* desc, int32_t* data);
-uint16_t ONICALL SLrGlobalVariable_Register_Float(char* name, char* desc, float* data);
-uint16_t ONICALL SLrGlobalVariable_Register_Bool(char* name, char* desc, uint32_t* data);
-uint16_t ONICALL SLrGlobalVariable_Register_String(char* name, char* desc, char* data);
-
-#endif
Index: Daodan/src/Daodan.c
===================================================================
--- Daodan/src/Daodan.c	(revision 444)
+++ Daodan/src/Daodan.c	(revision 445)
@@ -169,5 +169,5 @@
 }
 
-enum {s_unknown, s_options, s_patch, s_language} ini_section;
+enum {s_unknown, s_options, s_patch, s_bsl, s_language} ini_section;
 
 bool DDrIniCallback(char* section, bool newsection, char* name, char* value)
@@ -179,4 +179,6 @@
 		else if (!stricmp(section, "patch"))
 			ini_section = s_patch;
+		else if (!stricmp(section, "bsl"))
+			ini_section = s_bsl;
 		else if (!stricmp(section, "language"))
 			ini_section = s_language;
@@ -241,4 +243,7 @@
 			else
 				DDrStartupMessage("unrecognised patch \"%s\"", name);
+			break;
+		case s_bsl:
+			
 			break;
 		case s_language:
Index: Daodan/src/Daodan_BSL.c
===================================================================
--- Daodan/src/Daodan_BSL.c	(revision 444)
+++ Daodan/src/Daodan_BSL.c	(revision 445)
@@ -6,5 +6,5 @@
 #include "Daodan_Utility.h"
 #include "Daodan_Console.h"
-#include "BFW_ScriptingLanguage.h"
+#include "BFW_ScriptLang.h"
 #include "Oni.h"
 #include "Oni_Character.h"
@@ -13,6 +13,4 @@
 uint16_t ONICALL bsl_int32mul(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)
 {
-	if (numargs < 2)
-		return 1;
 	ret->value_int32 = args[0].value_int32 * args[1].value_int32;
 	ret->type = sl_int32;
@@ -22,7 +20,4 @@
 uint16_t ONICALL bsl_mul(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)
 {
-	if (numargs < 2)
-		return 1;
-	
 	double val1;
 	double val2;
@@ -45,6 +40,4 @@
 uint16_t ONICALL bsl_int32div(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)
 {
-	if (numargs < 2)
-		return 1;
 	ret->value_int32 = args[0].value_int32 / args[1].value_int32;
 	ret->type = sl_int32;
@@ -54,7 +47,4 @@
 uint16_t ONICALL bsl_div(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)
 {
-	if (numargs < 2)
-		return 1;
-	
 	double val1;
 	double val2;
@@ -77,7 +67,4 @@
 uint16_t ONICALL bsl_int32rand(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)
 {
-	if (numargs < 2)
-		return 1;
-	
 	int32_t start = 0;
 	int32_t end = 0;
@@ -127,5 +114,5 @@
 	if (numargs < 2)
 		return 1;
-
+	
 	char output[255];
 	int i;
@@ -141,4 +128,15 @@
 uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)
 {
+	DDrConsole_PrintF("%d", numargs);
+	
+	if (numargs < 1 || args[0].type != sl_str32)
+	{
+		DDrConsole_PrintF("Func \"%s\", File \"%s\", Line %d: semantic error, \"%s\": parameter list does not match: format:string arg1 arg2 ...", callinfo->name, callinfo->calllocation, callinfo->linenumber, callinfo->name);
+		return 0;
+	}
+	
+	if (!args[0].value_str32)
+		args[0].value_str32 = "";
+	
 	int ffi_ret;
 	char* str = NULL;
@@ -174,5 +172,5 @@
 	
 	if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, i, &ffi_type_sint32, ffi_args) != FFI_OK)
-		MessageBox(0, "", "", 0);
+		return 1;
 	ffi_call(&cif, (void*)snprintf, (void*)&ffi_ret, values);
 	str = malloc(ffi_ret + 1);
@@ -198,4 +196,4 @@
 	SLrScript_Command_Register_ReturnType("chr_getdamage","Gets the amount of damage a character has caused", "[chrindex:int]", sl_int32, bsl_getdamage);
 	
-	SLrScript_Command_Register_ReturnType("sprintf", "C-style sprintf.", "str1:format", sl_str32, bsl_sprintf);
+	SLrScript_Command_Register_ReturnType("sprintf", "C-style sprintf.", "format:string arg1 arg2 ...", sl_str32, bsl_sprintf);
 }
