Professional Documents
Culture Documents
Modding Documentation GBbeta 1
Modding Documentation GBbeta 1
Modding Documentation GBbeta 1
[V15.0.0 beta 1]
Basic
OpenConsole
Usage: OpenConsole
CloseConsole
Usage: CloseConsole
Physics
AddRigidbody
Description: Adds Physics to an Object, or registers an existing one fort he script to use.
Returns true if a rigidbody was added, and false if one already existed
Usage: AddRigidbody
AddForce(x, y, z, mode)
Mode Explained
Mode defines the ForceMode of the force applied to your physics object.
2 = Impulse : Add an instant force impulse to the rigidbody, using its mass.
3 = VelocityChange : Add an instant velocity change to the rigidbody, ignoring its mass.
RemoveRigidbody
Returns true if a rigidbody was removed, and false if there was no rigidbody to be removed
Usage: RemoveRigidbody
About parenting: if an object is parented to another object, that object will then move along with
the parent. This is also how rigs work and can be used to build more complex objects.
The children of parents will almost never need a rigidbody, as the parent alone having a rigidbody is
sufficient, and moves the children with it.
Having a rigidbody on a child would cause unpredictable issues with physics, unless a joint is
attached.
About local: local is always influenced by the parented object. Setting the local position and local
rotation to zero, would make it exactly the same as it's parent.
SetParent(parent)
Move(x, y, z)
MoveLocal(x, y, z)
Description: Moves the object in a specified direction, influenced by it and its parent's own rotation
SetPosition(x, y, z)
SetLocalPosition(x, y, z)
Description: Moves the object to a specified local position, influenced by its parent's own position.
ROTATION
SetRotation(x, y, z)
SetLocalRotation(x, y, z)
Description: Rotates the object to a specified rotation, influenced by its parent's own rotation.
Rotate(x, y, z)
Description: Rotates the object in a specified direction, influenced by its parent's own rotation.
SCALE
SetScale(x, y, z)
Description: Sets the object's scale, influenced by its parent's own scale.
AddScale(x, y, z)
Description: Adds to the object's scale, influenced by its parent's own scale.
Event Listeners
Important:
For listeners to work and call events, this code must always be executed. Place it at the end of your
script. Events will only start to be called once this loop is entered.
while true
_nextEvent = _events.pull
_nextEvent.invoke(_nextEvent.args)
end while
yield
end while
Examples:
Adding a listener: (description: script will from now on call player functions)
ListenForPlayer
Removing a listener: (description: script will from now on no longer call player functions)
EndListenForPlayer
Adding a function: (description: script will execute this code if "ListenForPlayer" is
implemented, and the player takes damage. it then accesses the damage key)
OnLocalTakeDamage = function (args)
damageAmount = args.damage
else then
end if
end function
ListenForPlayer / EndListenForPlayer
Triggers corresponding functions by the local player:
OnLocalTakeDamage(key = damage)
Description: triggered every time the player takes damage and provides the damage amount as a key
OnLocalDied
OnLocalInfected
Description: triggered when the player is either infected or cured (see Data > infected)
OnLocalHealed
Description: triggered every time the player is fully healed (example: toggled invincibility, got killstreak
heal, etc.)
OnLocalKnockout
OnLocalWakeUp
Description: triggered once the player wakes up after being knocked out. OnLocalGetUp is usually
triggered right afterwards
OnLocalSpawned
OnLocalRagdoll
Description: triggered every time the player goes into ragdoll mode
OnLocalGetUp
Description: triggered every time the player gets up from the ragdoll state
OnLocalEmote(key = emoteName)
Description: triggered each time the player uses an emote and provides the emote name as a key.
OnLocalEmoteEnd
ListenForServer / EndListenForServer
Triggers corresponding functions by the server:
OnPlayerJoined(key = player)
Description: triggered when a player enters the server and provides the player name as a key.
OnPlayerJoined(key = player)
Description: triggered when a player leaves the server and provides the player name as a key.
ListenForChat / EndListenForChat
Triggers corresponding functions by the chat:
Description: triggered when a chat message is received. This only accounts for messages sent by
players. Receives the username of the sender as key "sender", and the message itself as key 2
"message".
ListenForSceneChange / EndListenForSceneChange
Triggers corresponding functions by the game's scene:
OnSceneChanged(key = sceneName)
Description: triggered when a scene (map / level) is loaded. Provides the scene name.
ListenForInput / EndListenForInput
Triggers corresponding functions by the player input:
OnKeyPress(key = key)
Description: Triggered once a key is pressed and provides the key name.
OnKeyHold(key = key)
Description: Triggered while a key is held and provides the key name.
OnKeyLift(key = key)
Description: Triggered once a key is let go and provides the key name.
Objects
Description: creates an object with a given name from the game files using a path, at a specific
position and rotation. This object is automatically stored and can be used in things like Destroy, or
ExecuteScript.
Important: if you spawn multiple objects with the same name, it will be harder to get the correct
object you're looking for in things like Destroy or ExecuteScript.
In some cases, to avoid spawning multiple objects at the same time for each player, in an event that
occurs for everyone, it's best to only have the Host spawn the object. (using an if isHost statement)
Destroy(name)
Explanation: in this example, the GoreDoll we spawned using Instantiate will be deleted, as long as
the names match.
ExecuteScript(target, code)
DestroySelf
Usage: DestroySelf
Chat
Custom Commands: with the addition of chat API features, you can add custom commands.
messages sent by players that start with "?" will be seen as a custom command, and not sent into
the chat, but will be picked up by " OnChatMessage" if " ListenForChat" is implemented.
Example:
PlayerKill
end if
end function
SendChatMessage(sender, message)
Description: sends a chat message to everyone using a given name and message. Supports rich text.
Explanation: sends message in the chat under the name "bank" to everyone saying the username
and cash of the player which is executing this code.
SendChatMessageLocal(sender, message)
Description: sends a chat message to the person executing this code only, using a given name and
message. Supports rich text.
Explanation: sends message in the chat under the name "bank" to the player, which is executing this
code, telling them how much money they have.
SendErrorMessage(message)
GiveCurrency(amount)
RemoveCurrency(amount)
DropCurrency(amount)
Player
PlayerHeal
Usage: PlayerHeal
PlayerKill
Usage: PlayerKill
PlayerEmote(emote)
Usage: PlayerEndEmote
PlayerCripple
Usage: PlayerCripple
PlayerProtect(duration)
Description: Triggers "spawn protection" on the player for a specified time. (Default = 4)
PlayerSetTeam(team)
Description: Sets the Player Team to a specified team name. Currently, this is only for AI to know who
to target, and who not to.
Explanation: this code sets the player team to "Maniac", resulting in neutral NPCs to attack you on
sight, and Hostile NPCs to side with you.
Available Teams:
• Civilian
• Maniac
• Mutant
PlayerRagdoll
Usage: PlayerRagdoll
PlayerGetUp
Description: Makes the player get up from ragdoll mode (if possible)
Usage: PlayerGetUp
PlayerTeleport(x, y, z)
PlayerInfect(state)
Inventory
ClearInventory
Usage: ClearInventory
GiveItem(name)
RemoveItem(name)
Logic
StringContains(string, target)
Description: returns true if the string contains the target string. this is useful for checking something
for keywords.
Example:
SendChatMessage({"sender":"Bank", "message":"sure!"})
GiveCurrency({"amount":500})
end if
Explanation: in the example, it is checked if the message contains the word "money". if it does, then
the code sends a message using the name "bank" and gives the player 500GB$
RandomInt(min, max)
Description: returns a random int between "min" and "max". the upper limit specified in the method
is exclusive. This means that if you use RandomInt({"min":0, "max":10}), it will return a random
integer between 0 and 9
Example:
x = RandomInt({"min":0, "max":10})
print x
if x == 9 then
end if
RandomFloat(min, max)
Description: returns a random float between "min" and "max". the upper limit specified in the
method is exclusive. This means that if you use RandomFloat({"min":0, "max":10}), it will return a
random float number that is greater than or equal to 0.0 and strictly less than 10.0. In other words, it
could return 0.0, 9.9999, or any number in between, but it will never return 10.0 exactly.
x = RandomFloat({"min":0, "max":10})
print x
end if
Transform Data
Overall Description: you can directly access or modify all these values freely.
Overall Usage Example : posX = 3 / x = posX (posX could be any other one of the values listed
below)
posX
posY
posZ
localPosX
localPosY
localPosZ
rotY
rotZ
localRotX
localRotY
localRotZ
scaleX
scaleY
scaleZ
Overall Description: you can directly access or modify all these values freely.
Overall Usage Example : cash = 300 / x = cash (cash could be any other one of the values listed
cash
streak
infected
isHost
dead
equippedWeapon
Description: the currently equipped weapon (changing this value manually has no effect)
name
username
Key and value explained: key is the name of the saved value, while value is what you're trying to save
/ load later using the same key.
if you want to save and load a score for example, just save your score as the value, and use the key "score" so
the script knows what to save it as. once you want to load your score, load it using the key you saved it with.
SaveFloat(key, value)
SaveInt(key, value)
SaveString(key, value)
GetFloat(key, defaultValue)
GetInt(key, defaultValue)
GetString(key, defaultValue)