Is there a way, to set a variable changing only the enumeration/part of the designation?
Like;
*set st(semi random number)_cooking def_cooking (Mod Edit: I assume this is what you meant?).
Also to do the same with strings and booleans, and to do so in a fashion that doesn’t require a ton of code. If not, I want that, so bad. Would save sooo much work.
Oh and is there a way to add quotes inside a string?
Oh and here:
First thing might be possible with *setref, but it would take me a while to puzzle it out.
As for your second question:
Quotes: You can put quotes in your text by using backslashes, like this:
*set joke “she said it was “ironic”!”
If you write ${joke}, you’ll get:
she said it was “ironic”!
Oh right backslashes, I’ve read that before somewhere, thanks! That solves one problem at least. =)
I was hoping *setref would work, but in the example on the wiki, they only used it for labels, and those examples also seems like a close but no cigar kind of thing. There might be something there, I can almost taste it, but it looks like, on first glance, that there would be just as much code as just a set of *ifs, if not more… You would have to determine the *setrefs with *ifs anyways.
*if (st1)
…*setref “st1_cooking” 10
And that would be fine if it was just the one, but I’m dealing with over 53+ variables per individual here.
Would that work on numerals and booleans as well? Does the number have to be at the end or could you bake it in, like in my example? {“st”&n"_cooking"} ? Having real arrays would be the simplest though, is there a reason why we don’t have them?
The most likely reasons we don’t have real arrays is because a. They might be a pain to implement and b. The demand/requirement for them isn’t large enough.
You can refer to variables like that via name/string of course, but it wouldn’t work as an array, for obvious reasons (though you can emulate objects and their properties).
Well we do have support for logarithms…Can’t really imagine a use for those. And I’ll definately raise my hand and say I would very much like arrays if at all possible. And I would think many programmers would join me in that wish.
Would you perhaps care to make an example, please? I assume it has something to do with an alternate way of calling on these fake arrays? I only half-half know what I’m doing yet. =P
Most “programmers” would probably rather just use raw JS over CS, so that argument won’t get you far. Part of the appeal of Choicescript is how simple it is for people who haven’t programmed before (it’s designed for authors, not coders etc).
That’s not to say I wouldn’t personally like to see arrays, objects and many other things implemented into CS though (of course I would) but I can understand why they might not be.
What is it you want an example of, object emulation?
Well one could argue that the whole controversy with JS and the whole ‘could affect your chances of being published thing’, would be an incentive to see more official and supported tools being implemented. Naturally most people may not end up using it, but better a well stacked toolbox than one with just a hammer and a screwdriver, is how I see it. Those who know to use it will find joy in it, and arrays could definately ease things even for a hobby coder. I didn’t even know the term array until yesterday but I knew what it was I wanted to be able to do.
If these objects can help me do what I’m after, then yes please. Which is to set a large number of variables of all types, using as little code as possible, and to do so in an automated fashion.
So instead of doing this;
One can change the numbers so one doesn’t have to set each set of variables, e.g. st1 -st30, and h1-h8, individually. You can see why this would be a right slog to do the other way. And yes, there are all three kinds of variables in there, which is why I hesitate to use that fake array method.
Oh, no - for that, the array method will work just fine.
The data type doesn’t matter, I thought you were asking if you could loop through variables without a number (index) in their name, and to that the answer would have been no.
Yeah just see the above example and change strings to booleans/numbers or whatever you like as needed!
: )
I have been experimenting, but what I find is that it can only do about half of what I want it to. You can randomize or automize what you put into a SET variable, but you cannot randomize or automize a set variable?
What’s worse, the number has to be at the end of the variable for it to even work at all. Which means I would have about a gazillion lines of code to change just to rename the variables.
I could be wrong though, I am feeling rather sluggish atm. Or am I right in that you can’t do the array thing with the variable that you are setting, only with the value you are setting it to?
Aaaah! That was like staring at a mosaic or something, suddenly it just made sense. That’s great! And I don’t have to change the variables’ names either! Awesome, thank you! =) Now that I think about it, that was what JimD was talking about as well, d’oh. I’m slow on the uptake sometimes. Thanks y’all.