Added more string lua functions

This commit is contained in:
pasky1382 2014-01-20 17:06:09 +00:00
parent cb600e5bf7
commit 08504fc25a
4 changed files with 54 additions and 2 deletions

View File

@ -117,6 +117,7 @@
<Compile Include="lua\EmuLuaLibrary.Movie.cs" />
<Compile Include="lua\EmuLuaLibrary.NES.cs" />
<Compile Include="lua\EmuLuaLibrary.SNES.cs" />
<Compile Include="lua\EmuLuaLibrary.String.cs" />
<Compile Include="lua\LuaDocumentation.cs" />
<Compile Include="lua\LuaFile.cs" />
<Compile Include="lua\LuaFileList.cs" />

View File

@ -19,7 +19,6 @@ namespace BizHawk.Client.Common
"ror",
"rshift",
"check",
"signed",
};
}
}

View File

@ -12,6 +12,14 @@ namespace BizHawk.Client.Common
{
"hex",
"binary",
"trim",
"replace",
"toupper",
"tolower",
"startswith",
"substring",
"contains",
"endswith",
};
}
}
@ -29,6 +37,50 @@ namespace BizHawk.Client.Common
return binary;
}
public static string string_trim(object str)
{
return Convert.ToString(str);
}
public static string string_replace(object str, object str2, object replace)
{
return Convert.ToString(str).Replace(Convert.ToString(str2), Convert.ToString(replace));
}
public static string string_toupper(object str)
{
return Convert.ToString(str).ToUpper();
}
public static string string_tolower(object str)
{
return Convert.ToString(str).ToLower();
}
public static string string_substring(object str, object position, object length)
{
return Convert.ToString(str).Substring((int) position,(int) length);
}
public static string string_remove(object str, object position, object count)
{
return Convert.ToString(str).Remove((int) position,(int) (count));
}
public static bool string_contains(object str, object str2)
{
return Convert.ToString(str).Contains(Convert.ToString(str2));
}
public static bool string_startswith(object str, object str2)
{
return Convert.ToString(str).StartsWith(Convert.ToString(str2));
}
public static bool string_endswith(object str, object str2)
{
return Convert.ToString(str).EndsWith(Convert.ToString(str2));
}
}
}

View File

@ -94,7 +94,7 @@ namespace BizHawk.Client.EmuHawk
new NESLuaLibrary().LuaRegister(lua, Docs);
new SavestateLuaLibrary().LuaRegister(lua, Docs);
new SNESLuaLibrary().LuaRegister(lua, Docs);
//new StringLuaLibrary().LuaRegister(lua, Docs);
new StringLuaLibrary().LuaRegister(lua, Docs);
Docs.Sort();
}