Support default value for state

Change-Id: I566a16753016dd2673ee1d298baca61a90175757
diff --git a/dev/js/src/state.js b/dev/js/src/state.js
index 7d0d25e..f68408f 100644
--- a/dev/js/src/state.js
+++ b/dev/js/src/state.js
@@ -20,8 +20,8 @@
     /**
      * Constructor
      */
-    create : function (value) {
-      return Object.create(this)._init(value);
+    create : function (values) {
+      return Object.create(this)._init(values);
     },
 
 
@@ -38,7 +38,6 @@
       else {
         t.values = [values];
       }
-      t.value = t.values[0];
       return t;
     },
 
@@ -71,9 +70,24 @@
 
 
     /**
+     * Set the state to a default value.
+     * This will only be set, if no other value is set yet.
+     */
+    setIfNotYet : function (value) {
+      if (this.value == undefined) {
+        this.set(value);
+      };
+    },
+
+
+    /**
      * Get the state value
      */
     get : function () {
+      if (this.value == undefined) {
+        this.value = this.values[0];
+      };
+
       return this.value;
     },
 
@@ -101,7 +115,7 @@
     roll : function () {
       let next = 0;
       for (let i = 0; i < this.values.length - 1; i++) {
-        if (this.value == this.values[i]) {
+        if (this.get() == this.values[i]) {
           next = i+1;
           break;
         };