2017 © Pedro Peláez
 

library vlib

PHP Library for Valve data formats and utilities.

image

nikkiii/vlib

PHP Library for Valve data formats and utilities.

  • Sunday, September 20, 2015
  • by nikkiii
  • Repository
  • 2 Watchers
  • 2 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

VLib

This is by no means stable, bla bla bla. It works for what I wrote it for, and will be updated as I need more features, or if you need more features, just submit an issue., (*1)

Capabilities

  • Opening VPK Archives and extracting data
  • Opening BSP maps and extracting entities and pakfiles
  • Easy usage of Language files/keys via LangWrapper

Installation

Install it using Composer:, (*2)

composer require nikkiii/vlib, (*3)

Usage

To open a BSP file:, (*4)

<?php
require_once 'vendor/autoload.php';

use VLib\BSP\BSPFile;

$fh = fopen('path/to/map.bsp', 'r');

$bsp = new BSPFile($fh);

// $bsp->version = format version

// $bsp->entities = entities

// $bsp->pakfile = pak file, use openArchive() to get a ZipArchive.

To open a VPK file (Uses Flysystem for universal filesystem access):, (*5)

<?php
require_once 'vendor/autoload.php';

use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;

use VLib\VPK\VPKArchive;

$filesystem = new Filesystem(new Local('/path/to/dir/with/vpks'));

$vpk = new VPKArchive($filesystem, 'pak01_dir.vpk');

$entry = $vpk->get('resource/l4d360ui_english.txt');

// To get a stream:
$stream = $entry->stream();

// To automatically call stream_get_contents:
$contents = $entry->getData();

Using LangWrapper (Ideally you'd load this data from VPKArchive using KeyValues, Warning: You'll probably need to use mb_convert_encoding from UCS-2LE to UTF-8 on language files), (*6)

<?php
require_once 'vendor/autoload.php';

use VLib\KeyValues\LangWrapper;

$tokens = [
    'Something' => 'Blabla'
];

$data = [
    'nested' => [
        'key' => '#Something'
    ]
];

$lang = new LangWrapper($tokens, $data);

echo $lang->get('nested.key'); // Blabla

To open a DEM file:, (*7)

<?php
require_once 'vendor/autoload.php';

use VLib\DEM\DEMFile;

$dem = new DEMFile('some_file.dem'); // Either string or resource (open file handle)

// $dem->... contains properties

The Versions

20/09 2015

dev-master

9999999-dev https://github.com/nikkiii/vbsp

PHP Library for Valve data formats and utilities.

  Sources   Download

ISC

The Requires

 

by Nikki

bsp source engine vpk valve formats