package structures.data.actions.library;

import structures.data.DataAction;
import structures.data.actions.params.CheckboxParam;
import structures.data.actions.params.DoubleParam;
import structures.data.actions.params.StringParam;

public class SetGlobalVariable extends DataAction {

	public SetGlobalVariable(){
		init(new StringParam("EditVariableKey"),
				new DoubleParam("EditVariableValue"),
				new CheckboxParam("RelativeVariable?"));
	}

	@Override
	public String getTitle() {
		return "SetGlobalVariable";
	}

	@Override
	public String getDescription() {
		if((boolean) get("RelativeVariable?").getValue()){
			return String.format("change %s by %.2f", get("EditVariableKey").getValue(), get("EditVariableValue").getValue());
		}
		else{
			return String.format("make %s equal %.2f", get("EditVariableKey").getValue(), get("EditVariableValue").getValue());
		}
	}

	@Override
	protected String getSyntax() {
		return "library.set_variable('%s', %f, %b);";
	}

}

@@ -161,22 +161,22 @@
 .params.
-Double
+Groovy
 Param;%0Ai
@@ -332,28 +332,24 @@
 gParam(%22
-Edit
 Variable
 Key%22),%0A%09
@@ -340,19 +340,21 @@
 Variable
-Key
+ Name
 %22),%0A%09%09%09%09
@@ -361,33 +361,21 @@
 new 
-Double
+Groovy
 Param(%22
-EditVariable
 Valu
@@ -410,25 +410,16 @@
 Relative
-Variable?
 %22));%0A%09%7D%0A
@@ -471,30 +471,27 @@
 urn %22Set
+ 
 Global
+ 
 Var
-iable
 %22;%0A%09%7D%0A%0A%09
@@ -538,16 +538,17 @@
 ) %7B%0A%09%09if
+ 
 ((boolea
@@ -567,17 +567,8 @@
 tive
-Variable?
 %22).g
@@ -577,16 +577,17 @@
 Value())
+ 
 %7B%0A%09%09%09ret
@@ -609,33 +609,40 @@
 at(%22
-c
+C
 hange 
+global '
 %25s
+'
  by %25
-.2f
+s
 %22, get(%22
 Edit
@@ -633,36 +633,32 @@
 y %25s%22, get(%22
-Edit
 Variable
 Key%22).getVal
@@ -637,35 +637,37 @@
 %22, get(%22Variable
-Key
+ Name
 %22).getValue(), g
@@ -674,116 +674,352 @@
 et(%22
-EditVariableValue%22).getValue());%0A%09%09%7D%0A%09%09else%7B%0A%09%09%09return String.format(%22make %25s equal %25.2f%22, get(%22Edit
+Value%22).getValue());%0A%09%09%7D%0A%09%09else%7B%0A%09%09%09return String.format(%22Set global '%25s' to %25s%22, get(%22Variable Name%22).getValue(), get(%22Value%22).getValue());%0A%09%09%7D%0A%09%7D%0A%0A%09@Override%0A%09public String compileSyntax() %7B%0A%09%09if ((boolean) get(%22Relative%22).getValue()) %7B%0A%09%09%09return String.format(%22globals.%25s = globals.%25s + %25s;%5Cn%22, get(%22Variable Name%22).getValue(), get(%22
 Variable
 Key%22
@@ -1018,11 +1018,13 @@
 able
-Key
+ Name
 %22).g
@@ -1043,20 +1043,124 @@
 et(%22
-EditVariable
+Value%22).getValue());%0A%09%09%7D else %7B%0A%09%09%09return String.format(%22globals.%25s = %25s;%5Cn%22, get(%22Variable Name%22).getValue(), get(%22
 Valu
@@ -1172,32 +1172,35 @@
 etValue());%0A%09%09%7D%0A
+%09%09%0A
 %09%7D%0A%0A%09@Override%0A%09
@@ -1243,45 +1243,12 @@
 urn 
-%22library.set_variable('%25s', %25f, %25b);%22
+null
 ;%0A%09%7D

Set Global Variable action created