Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[0.1.3] [client/server] Utility Scripts
#1
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:

  1. Extract G2O_Module_Util.7z
  2. Move resulting folder in the root folder of your server
  3. 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
Reply
#2
Update with a bunch of fixes
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Server] ORM Quarchodron 3 3,434 08.07.2020, 10:19
Last Post: Quarchodron
  [0.1.3] [server] ItemGroundSpawner HammelGammel 1 4,034 05.02.2020, 18:40
Last Post: demor140202
  [Client] Version check Quarchodron 2 4,007 25.08.2019, 14:06
Last Post: Quarchodron
  [Client] GUI Creator Quarchodron 6 7,510 12.08.2019, 23:05
Last Post: Arkhan
  [New G2O][Client-Side] bindKey Patrix 6 8,956 14.11.2018, 02:32
Last Post: Patrix
  [0.1.4.*] [client/server] Simple anty-cheat Profesores 8 10,239 20.03.2018, 19:16
Last Post: Patrix
  [0.1.3] [client/server] BotCreator HammelGammel 22 26,537 08.02.2018, 22:02
Last Post: HammelGammel
  [G2O v.0.1.2][Server-Side] NPC Manager Quarchodron 16 17,467 21.01.2018, 19:59
Last Post: Quarchodron
  [New G2O][Client-Side] Key Combination Patrix 1 3,775 23.12.2017, 13:16
Last Post: Patrix
  [CLIENT]Draw(Line/Color) Tommy 0 3,111 19.12.2017, 04:23
Last Post: Tommy

Forum Jump:


Users browsing this thread: 1 Guest(s)