Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -------------------------------
- -- /lib/WorldSetup ------------
- -------------------------------
- --- This package keeps functions that define the layout of the game world
- -- Where the portals are, where the buildzones are, where the spawn area is, etc.
- -- no minecraft dependent code should be in here
- function getPortalLocations(settings)
- local portals_boxes = {}
- local x = settings.computer.x + math.floor(settings.spawnzone_size/2) + settings.portal_offset
- local y = settings.computer.y - 2
- local z = settings.computer.z - math.floor(settings.portal_count.z/2) * ( settings.portal_offset + settings.portal_size) - math.floor(settings.portal_size/2)
- for ix = 0, settings.portal_count.x - 1 do
- for iz=0, settings.portal_count.z - 1 do
- local xpos = x + ix * (settings.portal_offset + settings.portal_size)
- local ypos = y
- local zpos = z + iz * (settings.portal_offset + settings.portal_size)
- table.insert( portals_boxes, box(xpos, ypos, zpos, settings.portal_size, settings.portal_height, settings.portal_size))
- end
- end
- return portals_boxes
- end
- function getSpawnAreaLocation(settings)
- local x = settings.computer.x - math.floor(settings.spawnzone_size/2)
- local y = settings.computer.y
- local z = settings.computer.z - math.floor(settings.spawnzone_size/2)
- local w = settings.spawnzone_size + portal_size*settings.portal_count.x + portal_offset*(settings.portal_count.x+1) --TODO make this static with 3x3 portals in mind
- local l = settings.spawnzone_size
- local h = 3 -- the height of the fence around the spawn zone
- local spawn_zone = box(x,y,z,w,h,l) -- TODO maybe have that created by a initSpawnzone() function and stored in the game object as it could be needed to check player locations
- return spawn_zone
- end
- function getBuildzoneLocations(settings)
- BUILDZONE_WIDTH = GRIDCELL_SIZE * GRIDCELL_COUNT --TODO if we want to mimic a Manhattan-like grid, rectangular buildzones must be possible
- PLUG_LENGTH = math.floor(GRIDCELL_SIZE/3) -- the number of minecraft blocks which the crosses around each detector block that are made out of plug blocks will expand to
- NUMBER_OF_BUILDZONES = GAME_FIELD.countX*GAME_FIELD.countZ -- the number of games that can be active simultaneously
- --a platfrom encompassing all play areas (number of play areas is defined in GAME_FIELD)
- PLAY_AREAS = {
- x= computer.x + (PLAY_AREA_OFFSET.x - CATALOGUE_SLOT_OFFSET) * GRIDCELL_SIZE + 1 ,
- y=computer.y - 1,
- z = closestGridCoord(computer.z, GRIDCELL_SIZE, computer.z + SPAWNZONE_SIZE/2) + (PLAY_AREA_OFFSET.z - CATALOGUE_SLOT_OFFSET ) * GRIDCELL_SIZE + 1,
- dx = 2 * CATALOGUE_SLOT_OFFSET * GRIDCELL_SIZE + (GRIDCELL_SIZE-1) + BUILDZONE_WIDTH * GAME_FIELD.countX + (BUILDZONE_OFFSET * GRIDCELL_SIZE)*(GAME_FIELD.countX-1),
- dz = 2 * CATALOGUE_SLOT_OFFSET * GRIDCELL_SIZE + (GRIDCELL_SIZE-1) + BUILDZONE_WIDTH * GAME_FIELD.countZ + (BUILDZONE_OFFSET * GRIDCELL_SIZE)*(GAME_FIELD.countZ-1)
- }
- FIRST_ZONE = {
- x=computer.x + PLAY_AREA_OFFSET.x * GRIDCELL_SIZE + 1 + math.floor(GRIDCELL_SIZE/2),
- y=computer.y - 1,
- z=closestGridCoord(computer.z, GRIDCELL_SIZE, computer.z + SPAWNZONE_SIZE/2) + PLAY_AREA_OFFSET.z * GRIDCELL_SIZE + 1 + math.floor(GRIDCELL_SIZE/2),
- }
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement