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 4 417 12.07.2020, 10:15
Last Post: Sative
  [New G2O][Client] Free Camera Patrix 2 1,727 06.05.2020, 17:53
Last Post: Patrix
  [0.1.3] [server] ItemGroundSpawner HammelGammel 1 1,982 05.02.2020, 17:40
Last Post: demor140202
  [Client] Version check Quarchodron 2 1,675 25.08.2019, 13:06
Last Post: Quarchodron
  [Client] GUI Creator Quarchodron 6 3,109 12.08.2019, 22:05
Last Post: Arkhan
  [New G2O][Client-Side] bindKey Patrix 6 4,613 14.11.2018, 01:32
Last Post: Patrix
  [New G2O][Client-Side] OOP Camera Movement Patrix 1 2,121 20.10.2018, 13:22
Last Post: Patrix
  [0.1.4.*] [client/server] Simple anty-cheat Profesores 8 4,943 20.03.2018, 18:16
Last Post: Patrix
  [0.1.3] [client/server] BotCreator HammelGammel 22 13,123 08.02.2018, 21:02
Last Post: HammelGammel
  [G2O v.0.1.2][Server-Side] NPC Manager Quarchodron 16 9,047 21.01.2018, 18:59
Last Post: Quarchodron

Forum Jump:


Users browsing this thread: 1 Guest(s)