Skip to content

Uncaught Error: voxel-stitch requires game-shell #9

@z3t0

Description

@z3t0

It seems to think that game-shell isnt there even though it is...

// Require

require('voxel-registry')   // TODO: learn
require('voxel-keys')
require('voxel-chunkborder')
require('voxel-mesher') // TODO: learn - > Needed by voxel-chunkborder
require('voxel-stitch') // TODO: learn - > Needed by voxel-mesher
require('game-shell')   // TODO: learn - > Needed by voxel-stitch

var createGame = require('voxel-engine')
var voxel = require('voxel')
var texturePath = require('programmerart-textures')('');
var game = createGame({
    generate: function(x, y, z) {
        return y === 1 ? 1 : 0
    },
    texturePath: texturePath,
    materials: [
        ['blocks/grass_top', 'blocks/dirt', 'blocks/grass_side'], 'blocks/stone', 'blocks/dirt'
    ],
    materialFlatColor: false,
    controls: {
        discreteFire: true
    },
    lightsDisabled: false,
    fogDisabled: false,
    playerHeight: 1.62,
    generateChunks: true,
    keybindings: {
        'W': 'forward',
        'A': 'left',
        'S': 'backward',
        'D': 'right',
        '<up>': 'forward',
        '<left>': 'left',
        '<down>': 'backward',
        '<right>': 'right',
        '<mouse 0>': 'firecheck', // Middle mouse button
        '<mouse 1>': 'fire',
        '<mouse 2>': 'mouse2',
        '<mouse 3>': 'alt', // left mouse button
        '<space>': 'jump',
        '<shift>': 'crouch',
        '<control>': 'cotnrol'
    }
})



// Terrain

// Plugins
// Need to use stackgl ndarray
// var registry = require('voxel-registry')
// var land = require('voxel-land')


// var createLand = require('voxel-land')
// var land = createLand(game, {})
// land.enable()

//

// generateTerrain()

function generateTerrain() {
    // TODO: better terrain generation
    var terrain = require('voxel-perlin-terrain')
    var chunkSize = 32

    var seed = 'foo'
    var floorHeight = 0
    var ceilingHeight = 5
    var scaleFactor = 20;

    // initialize your noise with a seed, floor height, ceiling height and scale factor
    var generateChunk = terrain(seed, floorHeight, ceilingHeight, scaleFactor)

    game.voxels.on('missingChunk', function(p) {
        console.log("Generating Chunks")
        var voxels = generateChunk(p, chunkSize)
        var chunk = {
            position: p,
            dims: [chunkSize, chunkSize, chunkSize],
            voxels: voxels
        }
        game.showChunk(chunk)
    })
}

// Highlighting
/*
    voxel-highlight @ https://github.com/maxogden/voxel-highlight
    Allows us to select blocks to destroy them and also to select adjacent
    blocks so that we can place new blocks
*/

var highlight = require('voxel-highlight')
var adjacentBlock;
var block;
var hlColor = '#00CC00' // Green

var highlight = require('voxel-highlight')
var hl = highlight(game, {
    color: hlColor
});

hl.on('highlight', function(voxelPos) {
    block = voxelPos
});
hl.on('remove', function(voxelPos) {
    block = null
});
hl.on('highlight-adjacent', function(voxelPos) {
    adjacentBlock = voxelPos
    game.setBlock(adjacentBlock, 1)
    console.log('Placed: ' + adjacentBlock)
});
hl.on('remove-adjacent', function(voxelPos) {
    adjacentBlock = null
});

// Append game to body
var container = document.body
game.appendTo(container)

// Player
var createPlayer = require('voxel-player')(game)
var playerTexture = 'textures/player.png' // Minecraft Skint
var player = createPlayer(playerTexture)

player.possess()
player.position.set(0, 100, 0); // Makes sure player doesnt spawn inside a block

// Allows player to fly

// var fly = require('voxel-fly')
// var makeFly = fly(game)
// makeFly(player)
// makeFly(game.controls.target())


// Controls

controls()

function controls() {

    //Mouse Input
    document.body.addEventListener('mousedown', mousePressed)

    function mousePressed(event) {
        switch (event.button) {
            case 0: // Left mouse button
                var position = block
                if (game.getBlock(position) != 0) {
                    game.setBlock(position, 0)
                    console.log('Break: ' + position)
                } else {
                    console.log('No Block')
                }

                break;

            case 1: // Middle mouse button
                var position = block
                var type = game.getBlock(position)
                console.log('BlockType: ' + type + ' : ' + position)
                break;


        }
    }

}

// Audio

play = require('play-audio')

play('audio/background.ogg').autoplay().controls().loop()
play('audio/block.ogg').preload()

game.on('setBlock', function(pos, val, old) {
    play('audio/block.ogg').volume(1.0).play().on('ended', function() {})
})

// Plugins 

var createPlugins = require('voxel-plugins');
var plugins = createPlugins(game, {
    require: require
});
plugins.add('voxel-registry', {})
plugins.add('game-shell', {})
plugins.add('voxel-stitch', {})
plugins.add('voxel-mesher', {})
plugins.add('voxel-chunkborder', {}) // F9 to toggle, default solid blue
plugins.loadAll()

var registry = game.plugins.get('voxel-registry');

// Keybindings
var keys = game.plugins.get('voxel-keys');

// Example for adding a keybinding, opts.keybindings is used
// keys.down.on('left', function() {
//     console.log('the key corresponding to the left keybinding was pressed');
// });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions