Non-threaded

Forums » Feature Wishing Well » Read Thread

Suggestions for improvements and additions to the site.
This feature was rejected 6/27/2012: Automatically rejected as part of the FWW clean out.

Scripting - Loops and Arrays

18 years ago

Hey alex,

here i am asking for loops and arrays again. I hope you have the PM discussing this, maybe you will change your mind on this?

Scripting - Loops and Arrays

18 years ago

Hey, loops and arrays - I can think of some uses for them already! One thing I'd love to do on this site, is a randomly generated dungeon crawl, and I could use loops and arrays to generate the map! Think of it, every time you played the game, it would be a different adventure!

You could work out the page id's of the rooms in your dungeon, then make a MAP(X, Y) array that had the page id's randomly assigned to it, to get the layout of the dungeon! Then just script the links, so they grabbed the destination page id from the array when you left a room!

Scripting - Loops and Arrays

18 years ago

Excellent Example!!

Back when i suggested this to alex, my main number one concern was arrays, i really wanted this happen, because then you could group a certain variables like:

[%monsterhealth, %monsterattack, %monsterdefense] and so on.. but this loop idea is incredible! im trying to find the PM i sent to alex, because i had some real nice examples and support for this idea, but i am having trouble locating it.

Scripting - Loops and Arrays

18 years ago
(Yes, I realize that you also gave me an example -- however, your example could be worked-around by expanding to multiple variables)

Scripting - Loops and Arrays

18 years ago

Finally! An example =-) I like it! Great idea. So, what would it look like?

I'm thinking, from a programming standpoint (my programming), I'd want to identify arrays differently. Perhaps, a double percent? So ...

%SOMEVAR <-- normal variable
%%SOMEARY(...) <-- some array variable

Of course, we'll need loops too. I like to keep things simple, so I'm thinking of only doing a DO-WHILE loop:

WHILE <condition> DO
BEGIN
  ...
END

Example:

%VAR := 0
WHILE %VAR < 100 DO
BEGIN
  %%ARR(%VAR) := 1D4
END

Scripting - Loops and Arrays

18 years ago

I'd like to use arrays for coordinate systems, such as moving around a map where locations have X and Y coordinates. If you're adding arrays, is it possible for you to add double arrays.

That is, ARRAY(%VARX, %VARY) instead of just ARRAY(%VAR)

The DO-WHILE Loop sounds really good! I can't wait!

Scripting - Loops and Arrays

18 years ago

something tells me that we are going to need a "Mag for Dummies" book soon. lol i dotn know what arrays and loops are at all. i sorta get the concepts in this thread but it sounds pretty tough to accomplish. any possibilities of a set of dummy buttons on the editor alex? lol seriously...

nate

Scripting - Loops and Arrays

18 years ago

Easy enough. I will implement with an unlimited amount of dimensions. So you could do, %%VARARR( %VARA, %VARB, %VARC ) if you really wanted.

 

Scripting - Loops and Arrays

18 years ago

I should add, these will not really be "multi-dimensional" arrays. Behind the scenes, when you do something like:

%%VARARR( 1 , 2 )

It will translate and look up the value like:

%%VARARR( "1~2" )

Or something like that. The reason I bring this up is that, this means it will not be possible to programmatically know the dimensions of an array. But honestly I can never see that being needed.

I will also expose Pages, Chapters, etc as arrays. Will think more about it later. Seems like it could be useful.

Scripting - Loops and Arrays

18 years ago
Sounds really good!

Scripting - Loops and Arrays

18 years ago
As long as we can group variables (and maybe chapters too) then I'm hyped.

Scripting - Loops and Arrays

18 years ago
If we can group chapters by using loops and arrays then... we need this Alex!

Another example Solo, would be if you have multiple storylines, all with their own multiple chapters. The chapters get all confusing, even when you name the character they're dedicated to.

Instead of:

Riraneit Cutflail
Riraneit Marsage
Relixane Marsage
Riraneit Bandits
Relixane Military

You could have:

Riraneit: Cutflail, Marsage, Bandits
Relixane: Marsage, Military

It'd be a hell of a lot easier.

Scripting - Loops and Arrays

18 years ago
Be careful of infinite loops...

Scripting - Loops and Arrays

18 years ago
I thought it was impossible to get an infinite loop.. or is that only in passwords?

Scripting - Loops and Arrays

18 years ago

Lol. I remember a program I was writing once, that I infinite looped. Had to reboot my computer, because the program wouldn't let Alt-Tab work. Then I booted up my computer, loaded the program editor back up again to fix the problem, and without thinking, ran the program again - back into the infinite loop. Very annoying :)

October: A loop is just a bit of scripting code that repeats itself until a condition is met. So, an infinite loop is easy to make, by accidentally giving the loop a condition that can't ever be met.

For example, a variable might equal 1. You then create a loop that says, keep adding +1 to the variable, until the variable equals 0. It would start at 1, go to 2, go to 3, etc, and never reach zero, so it would just keep on going. While the loop is running, the program is stuck at that spot, and won't do anything else until the loop ends. Unless you are able to CTRL-ALT-DELETE and force the program to end, you're stuck.

Scripting - Loops and Arrays

18 years ago
lol i did that once and my computer froze :P (it was an old computer :P)

Scripting - Loops and Arrays

18 years ago
Today, all that happens is, is that the browser says the script in going slow.  Do you want to abort it or something like that.  Say no twice, and well, expect a reset.  :)

Scripting - Loops and Arrays

18 years ago
Bump.

Seriously, this'd be heaps helpful for massive storygames.