28.12.2017, 02:38
(This post was last modified: 10.03.2019, 01:59 by HammelGammel.)
Description:
Library with various, hopefully useful utility functions written in Squirrel. Required for some of my other scripts.
Please report any problems you find here: Issue Tracker
Installation:
Util.nut
Static class with miscellaneous utility methods
CellSystem.nut
Allows adding elements to a grid of cells by their position. This can be used to then get all elements in grids around a given position. When lots of elements exist that have to do distancechecks to all other elements, this can reduce the amount of elements to check and thus decrease overhead.
Example: 1000 bots are scattered around the map. Normally, distancechecks would have to be done from all bots to all other bots to check if bot is within viewing distance. With a CellSystem, only bots in surrounding cells have to even be considered for a refined distancecheck.
Factions.nut
Allows creating factions and relations between them
RealTimeEvent.nut
Static class that allows creating events that are executed at a given real world time. For example: replenish appletree after 10 hours, save serverstate every hour.
Download
Repository
Library with various, hopefully useful utility functions written in Squirrel. Required for some of my other scripts.
Please report any problems you find here: Issue Tracker
Installation:
- Extract G2O_Module_Util.7z
- Move resulting folder in the root folder of your server
- Add the following to your config.xml:
Code:
<!-- Module Util -->
<import src="G2O_Module_Util/scripts.xml" />
Util.nut
Static class with miscellaneous utility methods
Code:
getAngleDelta(angle1, angle2)
reverseTable(table)
round(value, decimalPlaces)isFirstWord(string, word)
lerp(val1, val2, delta)
lerpAngle(from, to, delta)
moveOnAngle(x, y, z, angle, delta)
integerToBool(value)
stringToBool(inString)
tableToString(inTable)
stringToTable(inString)
valueToString(value)
stringToValue(inString)
splitString(string, delimiter)
addToTime(date, dateDelta)
isTimeLater(date1, date2)
getDeltaGameTimeMinutes(startTime, endTime)
isTimeBetween(startTime, endTime, currentTime)
cloneArray(inArray)
getNearestPlayer(x, y, z, maxDistance)
CellSystem.nut
Allows adding elements to a grid of cells by their position. This can be used to then get all elements in grids around a given position. When lots of elements exist that have to do distancechecks to all other elements, this can reduce the amount of elements to check and thus decrease overhead.
Example: 1000 bots are scattered around the map. Normally, distancechecks would have to be done from all bots to all other bots to check if bot is within viewing distance. With a CellSystem, only bots in surrounding cells have to even be considered for a refined distancecheck.
Code:
getAdjacentCells(x, z, radius)
getContentNear(x, z, radius)
getIndexByPos(x, z)
addToCellByPos(x, z, identifier, value)
addToCell(index, identifier, value)
removeFromCell(index, identifier)
clearCell(index)
constructor(gridSize)
Factions.nut
Allows creating factions and relations between them
Code:
isEnemyNameFaction(name)
isEnemyFaction(fac)
addEnemyFaction(fac)
getFaction(name)
areFactionsEnemies(fac1, fac2)
getName()
getEnemyFactions()
constructor(name)
RealTimeEvent.nut
Static class that allows creating events that are executed at a given real world time. For example: replenish appletree after 10 hours, save serverstate every hour.
Code:
add(date, function, reschedule, repeat)
remove(tag)
check()
Download
Repository