LHUtils Reference

LHUtils.lua

Overview

This file contains helper methods needed by the LevelHelper 2 API. Users should also find this methods useful.

Instance Methods

colorFromString

  colorFromString(str)
Parameters
str

The string representing a color value.

Discussion

Given a string like "{{255, 200}, {255, 255}}", returns a table like {red = 255, green = 200, blue=255, alpha=255}

Declared In
LHUtils.lua

filenameExtension

  filenameExtension(path)
Parameters
path

A string representing the path.

local GHUtils =  require("GameDevHelperAPI.GHUtils");
local ext = GHUtils.filenameExtension("Assets/image.png");
--will return "png"

Discussion

Returns the extention given a path string.

Declared In
LHUtils.lua

getPathFromFilename

  getPathFromFilename(path)
Parameters
path

A string representing the path.

local GHUtils =  require("GameDevHelperAPI.GHUtils");
local ext = GHUtils.getPathFromFilename("Assets/image.png");
--will return "Assets/"

Discussion

Returns the path without the filename.

Declared In
LHUtils.lua

jsonFileContent

  jsonFileContent(filename, base)
Parameters
filename

The path to the json file.

base

Optional parametter. Where it should look for the file. Default is system.ResourceDirectory.

Discussion

Loads json file and returns contents as a string.

Declared In
LHUtils.lua

LHDeepCopy

  LHDeepCopy(t)
Discussion

Copies a lua table by value

Declared In
LHUtils.lua

LHDegreesToRadians

  LHDegreesToRadians(angle)
Parameters
angle

A numeric value representing an angle in degrees.

Discussion

Returns the angle in radians

Declared In
LHUtils.lua

LHRadiansToDegrees

  LHRadiansToDegrees(angle)
Parameters
angle

A numeric value representing an angle in radians.

Discussion

Returns the angle in degrees

Declared In
LHUtils.lua

pointFromString

  pointFromString(str)
Parameters
str

The string representing a point value.

Discussion

Given a string like "{500, 400}", returns a table like {x = 500, y = 400}

Declared In
LHUtils.lua

rectFromString

  rectFromString(str)
Parameters
str

The string representing a rect value.

Discussion

Given a string like "{{500, 400},{100,100}}", returns a table like {origin={x = 500, y = 400},size={width = 100, height = 100}}

Declared In
LHUtils.lua

replaceOccuranceOfStringWithString

  replaceOccuranceOfStringWithString(str, tofind, toreplace)
Parameters
str

The string to use for the replace action.

toFind

The string that should be replaced.

toreplace

The string that should be be used.

local GHUtils =  require("GameDevHelperAPI.GHUtils");
local ext = GHUtils.replaceOccuranceOfStringWithString("Assets/image.png", "png", "JPG");
--will return "Assets/image.JPG"

Discussion

Replace all occurances of a string with another string.

Declared In
LHUtils.lua

sizeFromString

  sizeFromString(str)
Parameters
str

The string representing a size value.

Discussion

Given a string like "{500, 400}", returns a table like {width = 500, height = 400}

Declared In
LHUtils.lua

stripExtension

  stripExtension(path)
Parameters
path

A string representing the path.

local GHUtils =  require("GameDevHelperAPI.GHUtils");
local ext = GHUtils.stripExtension("Assets/image.png");
--will return "Assets/image"

Discussion

Returns the path without the extension.

Declared In
LHUtils.lua
Last updated: 2015-3-15

Back to top

Copyright © VLADU BOGDAN DANIEL PFA.