What I'm trying to do is clear an array (as the input may have varying lengths), get a string split and put it in said array and then get the arrays length and put it in a global number.
But what is throwing me for a loop is how to actually access said values and arrays. as they are a global values and an array object. Like I said. total beginner.
I moved this to the scripting section.
It would probably be easier to help if you shared your code so far - have you got something written and you're stuck about what to do next? Or are you asking about where to start?
the problem is more that my code is probably not making any sense as I do not know how to access other parts. what I'm doing is as following
var x = inputString.value.toLowerCase();
CommandArray = x.split(' ');
inputstring is a global string. CommandArray is an Array object. and I'm activating this script in block ( which as I just thought of won't even call the code as of now)
but I might have been looking for answers in the wrong spot, as I was trying to search through the How do I?.. forum
It looks OK so far, just make sure CommandArray is declared somewhere first (e.g. let CommandArray;) since you can't assign to a variable that doesn't exist. Assuming you've done that, then you can just use CommandArray like an array.
That's just the problem. I know that I need to define it before I can assign values. but how do I assign it to this array.
that's what I'm having trouble with understanding.
Allright. I'm following so far. Does this mean I also can't access the global variables in the event sheet? And if so, what would be the workaround for these cases?
I understand what you mean, I just haven't a single clue as to how I would do that.
Here is a very basic example of the flow I described,
the function splitString takes a string splits it then uses the runtime to call a function on the event sheet to populate the ArrayObject
after that you can use the array how ever you want. hopefully this helps
Develop games in your browser. Powerful, performant & highly capable.
this is amazing piranha, a very clear example of how to do this, thanks a lot!