Modding Documentation GBbeta 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

GoreBox Modding Documentation

[V15.0.0 beta 1]

Basic

OpenConsole

Description : opens mod console

Usage: OpenConsole

CloseConsole

Description: closes mod console

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)

Description: Adds a Force to a registered Physics object

Usage: AddForce({"x":0, "y": 0, "z": 0, "mode": 0})

Mode Explained
Mode defines the ForceMode of the force applied to your physics object.

0 = Force : Add a continuous force to the rigidbody, using its mass.

1 = Acceleration : Add a continuous acceleration to the rigidbody, ignoring its mass.

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

Description: Deletes the registered Physics on an object

Returns true if a rigidbody was removed, and false if there was no rigidbody to be removed

Usage: RemoveRigidbody

Movement & Transform

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)

Description: Parents this object to another registered object

Usage: SetParent({"name": "parentName"})


POSITION

Move(x, y, z)

Description: Moves the object in a specified direction

Usage: Move({"x": 0, "y": 0, "z": 0})

MoveLocal(x, y, z)

Description: Moves the object in a specified direction, influenced by it and its parent's own rotation

Usage: MoveLocal({"x": 0, "y": 0, "z": 0})

SetPosition(x, y, z)

Description: Moves the object to a specified position

Usage: SetPosition({"x": 0, "y": 0, "z": 0})

SetLocalPosition(x, y, z)

Description: Moves the object to a specified local position, influenced by its parent's own position.

Usage: SetLocalPosition({"x": 0, "y": 0, "z": 0})

ROTATION

SetRotation(x, y, z)

Description: Rotates the object to a specified rotation

Usage: SetRotation({"x": 0, "y": 0, "z": 0})

SetLocalRotation(x, y, z)

Description: Rotates the object to a specified rotation, influenced by its parent's own rotation.

Usage: SetLocalRotation({"x": 0, "y": 0, "z": 0})

Rotate(x, y, z)

Description: Rotates the object in a specified direction

Usage: Rotate({"x": 0, "y": 0, "z": 0})


RotateLocal(x, y, z)

Description: Rotates the object in a specified direction, influenced by its parent's own rotation.

Usage: RotateLocal({"x": 0, "y": 0, "z": 0})

SCALE

SetScale(x, y, z)

Description: Sets the object's scale, influenced by its parent's own scale.

Usage: SetScale({"x": 1, "y": 1, "z": 1})

AddScale(x, y, z)

Description: Adds to the object's scale, influenced by its parent's own scale.

Use negative values to subtract scale.

Usage: AddScale({"x": 1, "y": 1, "z": 1})

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

while _events.len > 0

_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

print "ouch! I took " + damageAmount + " damage!"

if damageAmount < 5 then

print "could have been worse."

else then

print "still hurts."

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

Description: triggered every time the player dies

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

Description: triggered if the player gets knocked out

OnLocalWakeUp

Description: triggered once the player wakes up after being knocked out. OnLocalGetUp is usually
triggered right afterwards

OnLocalSpawned

Description: triggered every time the player (re)spawns

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

Description: triggered when an emote is ended

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.

OnKilledPlayer (key = player)


Description: triggered when the local player kills another player. provides the victim's name as a key.

ListenForChat / EndListenForChat
Triggers corresponding functions by the chat:

OnChatMessage(key = sender, key2 = message)

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

Instantiate(name, path, x, y, z, rotX, rotY, rotZ, rotW)

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.

Usage: Instantiate({"name":"spawnedDoll", "path":"AI/GoreDoll ", "x": 0, "y": 0, "z": 0, "rotX": 0,


"rotY": 0, "rotZ": 0, "rotW": 0})
Explanation: spawns a GoreDoll named "spawnedDoll" at coordinates 0, 0, 0 with default rotation

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)

Description: Destroys a stored object.

Usage: Destroy({"name": "spawnedDoll"})

Explanation: in this example, the GoreDoll we spawned using Instantiate will be deleted, as long as
the names match.

ExecuteScript(target, code)

Description: Executes a user script on the stored target object.

Usage: ExecuteScript({"target": "spawnedDoll", "code": "your code here"})

DestroySelf

Description: Destroys this object

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:

OnChatMessage = function (args)

if message == "?die" then

PlayerKill

end if

end function

SendChatMessage(sender, message)

Description: sends a chat message to everyone using a given name and message. Supports rich text.

Usage: SendChatMessage({"sender":"Bank", "message": username + " currently has " + cash +


"GB$"})

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.

Usage: SendChatMessage({"sender":"Bank", "message": "you currently have " + cash + "GB$"})

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)

Description: sends a local error message

Usage: SendErrorMessage({"message": "this is an error message"})


Currency

GiveCurrency(amount)

Description: gives the player a specified amount of GB$

Usage: GiveCurrency({"amount": 500})

RemoveCurrency(amount)

Description: removes a specified amount of the player's GB$

Usage: RemoveCurrency({"amount": 500})

DropCurrency(amount)

Description: makes the player drop a specified amount of GB$

Usage: DropCurrency({"amount": 500})

Player

PlayerHeal

Description: fully heals the player

Usage: PlayerHeal

PlayerKill

Description: kills the player

Usage: PlayerKill

PlayerEmote(emote)

Description: makes the player perform an emote with a specified name

Usage: PlayerEmote({"emote": "twerk"})


PlayerEndEmote

Description: makes the player stop emoting

Usage: PlayerEndEmote

PlayerCripple

Description: forces the player to crouch until death

Usage: PlayerCripple

PlayerProtect(duration)

Description: Triggers "spawn protection" on the player for a specified time. (Default = 4)

Usage: PlayerProtect({"duration": 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.

Usage: PlayerSetTeam({"team": "Maniac"})

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

Description: Makes the player enter ragdoll mode

Usage: PlayerRagdoll

PlayerGetUp

Description: Makes the player get up from ragdoll mode (if possible)

Usage: PlayerGetUp
PlayerTeleport(x, y, z)

Description: Teleports the player

Usage: PlayerTeleport({"x":0, "y":0, "z":0})

PlayerInfect(state)

Description: Infects or cures the player

Usage: PlayerInfect({"state": true})

Inventory

ClearInventory

Description: Removes all items from the inventory

Usage: ClearInventory

GiveItem(name)

Description: gives the player a specified item

Usage: GiveItem("name": "P90")

RemoveItem(name)

Description: strips the player of a specified item

Usage: RemoveItem("name": "P90")

Logic
StringContains(string, target)

Description: returns true if the string contains the target string. this is useful for checking something
for keywords.

Usage: StringContains({"string": "your message or string", target": "keyword to check for"})

Example:

if StringContains({"string": "hello, may I have some money?", "target": "money"}) then

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

Usage: RandomInt({"min":0, "max":10})

Example:

x = RandomInt({"min":0, "max":10})

print x

if x == 9 then

print "lucky number!"

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.

Usage: RandomFloat({"min":0, "max":10})


Example:

x = RandomFloat({"min":0, "max":10})

print x

if x >= 9.9 then

print "that had a 1% chance of happening!"

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

Description: x position of this object

posY

Description: y position of this object

posZ

Description: z position of this object

localPosX

Description: local x position of this object, influenced by the parent position

localPosY

Description: local y position of this object, influenced by the parent position

localPosZ

Description: local z position of this object, influenced by the parent position


rotX

Description: x rotation of this object

rotY

Description: y rotation of this object

rotZ

Description: z rotation of this object

localRotX

Description: local x rotation of this object, influenced by the parent rotation

localRotY

Description: local y rotation of this object, influenced by the parent rotation

localRotZ

Description: local z rotation of this object, influenced by the parent rotation

scaleX

Description: x scale of this object, influenced by the parent scale

scaleY

Description: y scale of this object, influenced by the parent scale

scaleZ

Description: z scale of this object, influenced by the parent scale


Data

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

Description: the game currency GB$

streak

Description: the current killstreak

infected

Description: infected state of the player (true or false)

isHost

Description: if the player is host (true or false)

dead

Description: if the player is dead

equippedWeapon

Description: the currently equipped weapon (changing this value manually has no effect)

name

Description: the name of this object

username

Description: the username of the player


Saving / Loading

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)

Description: securely saves a float value

Usage: SaveFloat({"key":"hunger", "value":34.2})

SaveInt(key, value)

Description: securely saves an int value

Usage: SaveInt({"key":"score", "value":100})

SaveString(key, value)

Description: securely saves a string

Usage: SaveString({"key":"rank", "value":"chief"})

GetFloat(key, defaultValue)

Description: loads a saved float value

Usage: GetFloat({"key":"hunger", " defaultValue":100})

GetInt(key, defaultValue)

Description: loads a saved int value

Usage: GetInt({"key":"score", " defaultValue":0})

GetString(key, defaultValue)

Description: loads a saved string

Usage: GetString({"key":"rank", " defaultValue ":"jobless"})

You might also like