improve docs
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
## What does attempt to index a nil value mean!?
|
||||
It means you tried to access a field of something that doesn't exist, for example:
|
||||
```lua
|
||||
```
|
||||
local thisIsNil = nil
|
||||
print(thisIsNil.what)
|
||||
print(thisIsNil.something())
|
||||
@@ -10,20 +10,22 @@ print(thisIsNil.something())
|
||||
|
||||
## Why i'm getting "Cannot access field test of userdata<something>" errors?
|
||||
Because you are trying to access a field in a C# class that doesn't exist.
|
||||
```lua
|
||||
```
|
||||
print(Item.thisDoesntExist)
|
||||
```
|
||||
|
||||
## What is "Attempt to access instance member "Drop" from a static userdata"
|
||||
It means you are trying to access a member that requires an instance to accessed, for example:
|
||||
```lua
|
||||
Item.Drop() -- there's a static global class called Item, but because it's static, you can't call item specific things on it, this will error.
|
||||
```
|
||||
-- there's a static global class called Item, but because it's static, you can't call item specific
|
||||
-- things on it, this will error.
|
||||
Item.Drop()
|
||||
Item.ItemList[1].Drop() -- this won't error, it will drop the first item ever created.
|
||||
```
|
||||
|
||||
## I'm getting a super big error with things related to the C# side
|
||||
It usually happens when you call something on the C# side and you provide nil inputs, you can get a better idea of it by analyzing the error message and trying to link it your lua code, for example:
|
||||
```lua
|
||||
```
|
||||
Game.SendMessage(nil)
|
||||
```
|
||||
This will result in
|
||||
@@ -36,7 +38,7 @@ Character senderCharacter, PlayerConnectionChangeType changeType)
|
||||
You can easily tell that the error has something to do with chat messages, and by looking back at your Lua code you can easily see whats causing it.
|
||||
|
||||
## How do i list all clients, characters and items?
|
||||
```lua
|
||||
```
|
||||
for _, client in pairs(Client.ClientList) do
|
||||
|
||||
end
|
||||
@@ -52,7 +54,7 @@ end
|
||||
|
||||
## Running pairs() on an enumerator doesn't work!
|
||||
pairs() Returns an enumerator that iterates through the entire table keys, if you already have an enumerator, you can just pass it in directly.
|
||||
```lua
|
||||
```
|
||||
-- get first item ever created and loop through all the items stored inside it.
|
||||
for item in Item.ItemList[1].OwnInventory.AllItems do
|
||||
|
||||
@@ -60,7 +62,7 @@ end
|
||||
```
|
||||
|
||||
## How do i spawn an item?
|
||||
```lua
|
||||
```
|
||||
local prefab = ItemPrefab.GetItemPrefab("screwdriver")
|
||||
local firstPlayerCharacter = Client.ClientList[1].Character
|
||||
|
||||
@@ -77,7 +79,7 @@ end)
|
||||
|
||||
## How do i give a character a certain affliction
|
||||
|
||||
```lua
|
||||
```
|
||||
local burnPrefab = AfflictionPrefab.Prefabs["burn"]
|
||||
|
||||
local char = Character.CharacterList[1]
|
||||
@@ -90,7 +92,7 @@ char.CharacterHealth.ApplyAffliction(limb, burnPrefab.Instantiate(100))
|
||||
|
||||
## How do i get the amount of a affliction that a character has?
|
||||
|
||||
```lua
|
||||
```
|
||||
local char = Character.CharacterList[1]
|
||||
|
||||
print(char.CharacterHealth.GetAffliction("burn"))
|
||||
@@ -100,7 +102,7 @@ print(char.CharacterHealth.GetAffliction("burn", char.AnimController.Limbs[1]))
|
||||
|
||||
## How do i send a private chat message?
|
||||
|
||||
```lua
|
||||
```
|
||||
local chatMessage = ChatMessage.Create("Sender name", "text here", ChatMessageType.MessageBox, nil, nil)
|
||||
Game.SendDirectChatMessage(chatMessage, ChatMessageType.MessageBox)
|
||||
```
|
||||
Reference in New Issue
Block a user