Added new nodes to DSL for a wider variety of commands and scripts.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
|
||||
@@ -68,6 +69,26 @@ public partial class NodeDisplay : PanelContainer
|
||||
result.node = new CraftNode();
|
||||
result.LoadCraft(nodeSanitized);
|
||||
break;
|
||||
case "while":
|
||||
result.node = new WhileNode();
|
||||
result.LoadWhile(nodeSanitized);
|
||||
break;
|
||||
case "until":
|
||||
result.node = new UntilNode();
|
||||
result.LoadUntil(nodeSanitized);
|
||||
break;
|
||||
case "for":
|
||||
result.node = new ForNode();
|
||||
result.LoadFor(nodeSanitized);
|
||||
break;
|
||||
case "if":
|
||||
result.node = new IfNode();
|
||||
result.LoadIf(nodeSanitized);
|
||||
break;
|
||||
case "else":
|
||||
result.node = new ElseNode();
|
||||
result.LoadElse(nodeSanitized);
|
||||
break;
|
||||
default:
|
||||
result.QueueFree();
|
||||
return null;
|
||||
@@ -76,6 +97,62 @@ public partial class NodeDisplay : PanelContainer
|
||||
return result;
|
||||
}
|
||||
|
||||
private void LoadElse(string content) { }
|
||||
|
||||
private void LoadIf(string content)
|
||||
{
|
||||
HBoxContainer valueContainer = GetNode<HBoxContainer>("./EditorDisplay/HBoxContainer/");
|
||||
string[] parts = content.Split(",");
|
||||
string itemString = parts[1].Replace("Item:", "").Trim();
|
||||
string comparatorString = parts[2].Replace("Comparator:", "").Trim();
|
||||
if (itemString.ToLower() != "empty")
|
||||
{
|
||||
IfNode ifNode = node as IfNode;
|
||||
if (ifNode != null)
|
||||
{
|
||||
ifNode.selectedItem = new Item { data = GameData.availableItems[itemString] };
|
||||
ifNode.comparator = comparatorString;
|
||||
}
|
||||
}
|
||||
string amountString = parts[3].Replace("Amount:", "").Trim();
|
||||
valueContainer.GetNode<SpinBox>("./Amount").Value = int.Parse(amountString);
|
||||
}
|
||||
|
||||
private void LoadFor(string content)
|
||||
{
|
||||
HBoxContainer valueContainer = GetNode<HBoxContainer>("./EditorDisplay/HBoxContainer/");
|
||||
string[] parts = content.Split(",");
|
||||
string amountExecuted = parts[1].Replace("AmountExecuted:", "").Trim();
|
||||
ForNode forNode = node as ForNode;
|
||||
if (forNode != null)
|
||||
{
|
||||
forNode.amountExecuted = int.Parse(amountExecuted);
|
||||
}
|
||||
string amountString = parts[2].Replace("Amount:", "").Trim();
|
||||
valueContainer.GetNode<SpinBox>("./Amount").Value = int.Parse(amountString);
|
||||
}
|
||||
|
||||
private void LoadUntil(string content) { }
|
||||
|
||||
private void LoadWhile(string content)
|
||||
{
|
||||
HBoxContainer valueContainer = GetNode<HBoxContainer>("./EditorDisplay/HBoxContainer/");
|
||||
string[] parts = content.Split(",");
|
||||
string itemString = parts[1].Replace("Item:", "").Trim();
|
||||
string comparatorString = parts[2].Replace("Comparator:", "").Trim();
|
||||
if (itemString.ToLower() != "empty")
|
||||
{
|
||||
WhileNode whileNode = node as WhileNode;
|
||||
if (whileNode != null)
|
||||
{
|
||||
whileNode.selectedItem = new Item { data = GameData.availableItems[itemString] };
|
||||
whileNode.comparator = comparatorString;
|
||||
}
|
||||
}
|
||||
string amountString = parts[3].Replace("Amount:", "").Trim();
|
||||
valueContainer.GetNode<SpinBox>("./Amount").Value = int.Parse(amountString);
|
||||
}
|
||||
|
||||
private static PackedScene GetPrefab(string nodeName, Dictionary<ProgramNode, PackedScene> DSLNodes)
|
||||
{
|
||||
foreach (ProgramNode programNode in DSLNodes.Keys)
|
||||
@@ -89,15 +166,13 @@ public partial class NodeDisplay : PanelContainer
|
||||
return null;
|
||||
}
|
||||
|
||||
public void LoadHarvest(string content)
|
||||
{
|
||||
}
|
||||
public void LoadHarvest(string content) { }
|
||||
|
||||
public void LoadMove(string content)
|
||||
{
|
||||
HBoxContainer valueContainer = GetNode<HBoxContainer>("./EditorDisplay/HBoxContainer/");
|
||||
string[] parts = content.Split(",");
|
||||
string positionValues = parts[1].Replace("Position: ", "").Replace("(", "").Replace(")", "");
|
||||
string positionValues = parts[1].Replace("Position:", "").Replace("(", "").Replace(")", "").Trim();
|
||||
int posX = int.Parse(positionValues.Split("|")[0]);
|
||||
int posY = int.Parse(positionValues.Split("|")[1]);
|
||||
int posZ = int.Parse(positionValues.Split("|")[2]);
|
||||
@@ -112,15 +187,13 @@ public partial class NodeDisplay : PanelContainer
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadExplore(string content)
|
||||
{
|
||||
}
|
||||
public void LoadExplore(string content) { }
|
||||
|
||||
public void LoadCraft(string content)
|
||||
{
|
||||
HBoxContainer valueContainer = GetNode<HBoxContainer>("./EditorDisplay/HBoxContainer/");
|
||||
string[] parts = content.Split(",");
|
||||
string itemString = parts[1].Replace("Item: ", "").Replace(" ", "");
|
||||
string itemString = parts[1].Replace("Item:", "").Trim();
|
||||
if (itemString.ToLower() != "empty")
|
||||
{
|
||||
CraftNode craftNode = node as CraftNode;
|
||||
@@ -129,7 +202,7 @@ public partial class NodeDisplay : PanelContainer
|
||||
craftNode.selectedItem = new Item { data = GameData.availableItems[itemString] };
|
||||
}
|
||||
}
|
||||
string amountString = parts[2].Replace("Amount: ", "");
|
||||
string amountString = parts[2].Replace("Amount:", "").Trim();
|
||||
valueContainer.GetNode<SpinBox>("./Amount").Value = int.Parse(amountString);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user