0 Favourites

# Instruct room creation with a large number.

• 9 posts
• Hello! I want to insert objects into a room by having a local variable store a number that instructs what objects to place, and using that in conjunction with a loop to place objects in the level. The issue I am having is that apparently the number is too large to store in a local variable. The loop to place objects works fine, it's the local variable that is giving me the problem.

Example:

This is a room, where each "0" is an empty space, and each "1" is a wall.

``````000000000000
011100001110
010000000010
010110011010
000100001000
000100001000
010110011010
010000000010
011100001110
000000000000
[/code:h8v6gkr1]

When the line breaks are removed, it becomes:
[code:h8v6gkr1]000000000000011100001110010000000010010110011010000100001000000100001000010110011010010000000010011100001110000000000000[/code:h8v6gkr1]

That's a pretty long number, and Construct2 jumbles it when it is placed into a local variable:
[code:h8v6gkr1]11100001110010002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000[/code:h8v6gkr1]

Where and how can I store a lot of these large numbers? Is there a way to compress these numbers without having to program in a way to de-compress them? Thank you in advance.``````
• Wouldn't putting it into array be the best option?

Using a dictionary object would work too, but these kind of things scream array..

• Wouldn't putting it into array be the best option?

Using a dictionary object would work too, but these kind of things scream array..

How would you do this?

I tried placing the value into an array but the array also jumbles the number.

• I would put every number 0 and 1 in it's own x,y place in the array so the array would look like your first code..

• I would put every number 0 and 1 in it's own x,y place in the array so the array would look like your first code..

Wouldn't I then need to input each 0 and 1 manually whenever I want to load a new level layout... ?

• Offcourse not..

put the 0's and 1's in a string and create a function to parse the string to the array..

I guess you should put the numbers in a string anyway..

Maybe you could use the string directly..

• Might be easier if you converted from binary.

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• > Wouldn't putting it into array be the best option?

> Using a dictionary object would work too, but these kind of things scream array..

>

How would you do this?

I tried placing the value into an array but the array also jumbles the number.

Sounds like the array size is not set. There is a set size action. Try using it on-start.

If you dont set the size properly, it can get really messy. Remember it is 0 based.

• I figured out a solution that worked well for me. I created a text file that contains every room layout, back to back. It is referenced using AJAX. Each room layout consists of 120 characters, so I'm using "mid" to reference a random level layout like so:

mid ( ajax.LastData, ( whichLevel*120 ), 120 ), where "whichLevel" is a random number from 0 to [total number of layouts I make minus one.]

I am using a spreadsheet to make sure I don't lose levels in the giant text file.

• 9 posts