Commit 1b0a5bfc authored by nanahira's avatar nanahira Committed by GitHub

Merge pull request #4 from Yumekaki/patch-2

automatically gets external script
parents 6d909b48 db508261
......@@ -276,18 +276,29 @@ public bool OpenScript(bool openinthis, string addrequire)
FileMode.OpenOrCreate,FileAccess.Write))
{
StreamWriter sw = new StreamWriter(fs, new UTF8Encoding(false));
if (c.id > 0) { //card script
sw.WriteLine("--" + c.name);
sw.WriteLine("local m=" + id.ToString());
sw.WriteLine("local cm=_G[\"c\"..m]");
if (addrequire.Length > 0)
sw.WriteLine("xpcall(function() require(\"expansions/script/" + addrequire + "\") end,function() require(\"script/" + addrequire + "\") end)");
sw.WriteLine("function cm.initial_effect(c)");
sw.WriteLine("\t");
sw.WriteLine("end");
} else { //module script
sw.WriteLine("--Module script \"" + addrequire + "\"");
}
if (string.IsNullOrEmpty(addrequire))
{
// OCG script
sw.WriteLine("--" + c.name);
sw.WriteLine("function c" + id.ToString() + ".initial_effect(c)");
sw.WriteLine("\t");
sw.WriteLine("end");
}
else
{
// DIY script
sw.WriteLine("--" + c.name);
sw.WriteLine("local m=" + id.ToString());
sw.WriteLine("local cm=_G[\"c\"..m]");
sw.WriteLine("xpcall(function() require(\"expansions/script/" + addrequire + "\") end,function() require(\"script/" + addrequire + "\") end)");
sw.WriteLine("function cm.initial_effect(c)");
sw.WriteLine("\t");
sw.WriteLine("end");
}
/*else
{ //module script
sw.WriteLine("--Module script \"" + addrequire + "\"");
}*/
sw.Close();
fs.Close();
}
......
......@@ -23,7 +23,28 @@ namespace DataEditorX
{
public partial class DataEditForm : DockContent, IDataForm
{
public string addrequire;
private string addrequire_str;
public string addrequire
{
get
{
if (!string.IsNullOrEmpty(addrequire_str))
return addrequire_str;
else
{
string cdbName = Path.GetFileNameWithoutExtension(nowCdbFile);
if (cdbName.Length > 0 && File.Exists(GetPath().GetModuleScript(cdbName)))
return cdbName;
}
return "";
}
set
{
addrequire_str = value;
}
}
#region 成员变量/构造
TaskHelper tasker = null;
string taskname;
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment