# What's the best way to do this?

#1

Hi!

I have to do something slightly complicated (involving many, many nodes) and want to check I am doing it okay.

My game’s levels are stored as tables, which generate 6* grids. Each entry in the grid either generates an empty space, or a tile that you can walk on.

I’m making a level select screen, where the player click on buttons to be taken to levels. Each button is shaped like a miniature map of the level it represents, to give a player an idea of which level he is going to play (they kind of look like small letters of an alien alphabet). I’m doing this using GUI scripts.

So, there will be around 200 levels, there is one mini-map for each level, and each mini-map is made of a maximum of 64 nodes. If the player clicks on a node which is part of the mini-map of level one, the player is taken to level one. In total, there are likely to be around 7,500 nodes (generated dynamically. They will only increase in scale on mouse_over and get on_input stuff. That’s not too bad, right?)

So… I’m going to create a table called “levelselectbuttons” where each entry is a table with the individual nodes for each level.

Here’s me generating each node:
local roll = gui.new_box_node(new_position, new_size)
table.insert (self.levselbut[levelno], roll)

pprinting “self.levselbut” prints this:

{ --[[0x11d7a0da0]]
1 = { --[[0x11d7b6d40]]
1 = box@(130, 170, 0),
2 = box@(130, 180, 0),
3 = box@(130, 190, 0),
… etc …
30 = box@(170, 220, 0),
31 = box@(180, 170, 0),
32 = box@(180, 180, 0)
}
}

which is correct, right?

The question now is, what do i put in on_input?

where x is a level number:

• on mouse_over for any node stored in self.levselbut[x] should increase the scale of all nodes that are part of self.levselbut[x]
• on mouse_off the scale goes back to normal
• clicking on a node in self.levselbut[x] should take you to level x.

(the other question is: is this very taxing for the processor? I am aware that the normal node limit is 1024)

0 Likes

#2

I think we have an upper cap on the number of nodes. Can you created that many nodes? Do you really need to have all nodes visible at the same time?

0 Likes

#3

The number of available levels will increase as the player progresses. At the moment i am only generating 3 levels, which is about 40 nodes (the first levels are very small). I would guess the minimum total will be around 2400, assuming each level is made up of 50% land and 50% empty space, and there are 150 levels. Using my massive brain I could probably decrease that to around 1,600. Do you know what the node limit is? Can I change it?

edit: node limit is 512. I will try to find a way to avoid reaching this limit, i.e. by having 12 levels in each world, and allowing the user to access one world at at time. This will work fine because the maximum number of nodes in one level is 32, and 32*12 = 384.

0 Likes

#4

…okay, I have realised what i need to do here is to create one node that is slightly larger than the mini-map of the level, and use that for all interaction. Forget i even opened my mouth. I will try and post a video later of the desired effect.

1 Like