Skip to content

Commit

Permalink
Merge pull request #52 from JimmyHelp/todos
Browse files Browse the repository at this point in the history
Todos
  • Loading branch information
skyrina authored Jun 19, 2024
2 parents 5f902fb + 3490a51 commit 878dcbf
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 15 deletions.
4 changes: 2 additions & 2 deletions docs/globals/Avatar/Avatar.md
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ avatar:getMaxTickCount()

### <code>getRenderCount()</code> \{#getRenderCount}

Gets the number of events.RENDER and events.POST_RENDER instructions of this avatar's last frame
Gets the number of instructions of this avatar's last frame from all render events (all events with render in their name) and the setXRender() functions from the models api

```lua
getRenderCount()
Expand All @@ -617,7 +617,7 @@ avatar:getRenderCount()

### <code>getMaxRenderCount()</code> \{#getMaxRenderCount}

Gets the maximum allowed instructions in events.RENDER and Events.POST_RENDER as permitted by the viewer
Gets the maximum allowed instructions as permitted by the viewer from all render events (all events with render in their name) and the setXRender() functions from the models api

```lua
getMaxRenderCount()
Expand Down
8 changes: 4 additions & 4 deletions docs/globals/Events/Events.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ end

function events.chat_send_message(msg)
host:setActionbar(msg)
-- return a modified message, makes sure you're always excited abotu everything
-- return a modified message, makes sure you're always excited about everything
return msg .. "!"
end
```
Expand All @@ -225,10 +225,10 @@ Calling the player without a <code>player:isLoaded()</code> check will error her

```lua
function events.chat_receive_message(raw, text)
host:setActionbar(msg)
host:setActionbar(raw)
-- Blocking any messages with my name so I can focus
if raw:find("joey") then
return nil
return false
end
return text
end
Expand All @@ -254,7 +254,7 @@ It have 5 arguments, as listed below:

(entity) - the entity, when rendered from an entity

(string) - the type of the rendering (LEFT_HAND, HEAD, BLOCK, …)
(mode) - the type of the rendering (LEFT_HAND, HEAD, BLOCK, etc)

If the return value is true, the skull will not render

Expand Down
5 changes: 3 additions & 2 deletions docs/globals/Models/Models.md
Original file line number Diff line number Diff line change
Expand Up @@ -1877,7 +1877,7 @@ models:setPrimaryTexture("Resource", "textures/entity/pig/pig.png")

Gets the primary texture of this part

Returns two values, first being the override type, second being the value, if any.
Returns two values, first being the override type, second being the texture object, if any.

```lua
getPrimaryTexture()
Expand All @@ -1893,7 +1893,8 @@ getPrimaryTexture()
**Example:**

```lua
local texType, tex = models:getPrimaryTexture()
local texType, tex = models:getPrimaryTexture() -- this saves both of the potential returns to two variables in a single line of code
log(textType, tex)
```

---
Expand Down
6 changes: 3 additions & 3 deletions docs/globals/Particles/Particle.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,9 @@ getVelocity()

**Returns:**

| Type | Description |
| ------------------------------------------------ | ------------------------ |
| <code>[Vector3](/globals/Vectors/Vector3)</code> | Gets the velocity of the |
| Type | Description |
| ------------------------------------------------ | --------------------------------- |
| <code>[Vector3](/globals/Vectors/Vector3)</code> | Gets the velocity of the particle |

**Example:**

Expand Down
12 changes: 10 additions & 2 deletions docs/globals/Raycast/Raycast.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ aabb(startX, startY, startZ, endX, endY, endZ, aabbs)
```lua
local eyePos = player:getPos() + vec(0, player:getEyeHeight(), 0)
local eyeEnd = eyePos + (player:getLookDir() * 20)
local aabb, hitPos, side, aabbHitIndex = raycast:aabb(eyePos, eyeEnd, { { vec(0, 0, 0), vec(1, 1, 1) } })
local hitLocation = { { vec(0, 0, 0), vec(1, 1, 1) } } -- this is the block location of 0,0,0 in the world
local aabb, hitPos, side, aabbHitIndex = raycast:aabb(eyePos, eyeEnd, hitLocation)
```

---
Expand Down Expand Up @@ -380,10 +381,17 @@ entity(startX, startY, startZ, endX, endY, endZ, predicate)

**Example:**

<!-- prettier-ignore -->
```lua
local eyePos = player:getPos() + vec(0, player:getEyeHeight(), 0)
local eyeEnd = eyePos + (player:getLookDir() * 20)
local entity, hitPos = raycast:entity(eyePos, eyeEnd)
local entity, hitPos = raycast:entity(eyePos, eyeEnd,function(x) -- x is the entity hit by the raycast
if x == player then -- if the entity hit is the player
return false -- don't include the player in the results
else
return true
end
end)
```

---
4 changes: 2 additions & 2 deletions docs/globals/World/World.md
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,8 @@ getPlayers()
**Example:**

```lua
for _, players in pairs(world.getPlayers()) do
log(players)
for _, value in pairs(world.getPlayers()) do
log(value)
end
```

Expand Down
4 changes: 4 additions & 0 deletions docs/tutorials/ActionWheel.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ action_wheel:setPage(mainPage)

function pings.actionClicked()
print("Hello World!")
-- animation example (commented out to avoid erroring):
-- animations.bbmodelname.animationname:play()
end

local action = mainPage:newAction()
Expand All @@ -147,6 +149,8 @@ This is an exmaple of the onToggle function, which swaps between two states. It
```lua
function pings.toggling(state)
models:setVisible(state)
-- animation toggle example (commented out to avoid erroring):
-- animations.bbmodelname.animationname:setPlaying(state)
end

local toggleaction = mainPage:newAction() -- If you're getting an error here it's probably because you didn't make the page
Expand Down
12 changes: 12 additions & 0 deletions docs/tutorials/Animations.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ There is another function that can play animations, <code>setPlaying(bool)</code

You can put a boolean value inside the parenthesis for the function and it will play the animation if the boolean is true, or stop it if the boolean is false

This is often used for toggles in the action wheel.

### setPlaying Example

By nature, setPlaying needs to be in a function that will run multiple times, we're going to use a tick event but you could use a ping or anything else
Expand Down Expand Up @@ -132,6 +134,16 @@ It only overrides while the animation is playing.

<img src={require("@site/static/img/animation/exampleOverride.png").default} width="400"></img>

## Special Keyframe Types

Blockbench animations have a special category of keyframes called Effects keyframes. There are three of them and Figura ignores Particle and Sound

### Instruction Keyframes

The third special keyframe type is Instruction, Instruction keyframes run lua code when the animation reaches that keyframe. This can be used to play sounds, spawn particles, literally anything. Remember that Lua code is what goes in this spot, not Molang.

Each instruction is its own 'scope' meaning that variables local to any of the scripts can't be accessed by the keyframes without specifically interfacing between them.

## Community Resources

### Jimmy's Animation Handler
Expand Down
63 changes: 63 additions & 0 deletions docs/tutorials/Commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Figura comes with a small set of commands that can help you use Figura. As Figura is a client-side mod these only affect the client.

## Normal Commands

### Debug

Usage: `/figura debug`

Debug generates a file in your Figura directory that contains information about your Figura mod settings and the avatar you currently have equipped. This includes the file sizes of all of the elements in the avatar.

### Docs

Usage: `/figura docs`

Docs contains all of the documentation you can find in the Globals and Enums section of this wiki, simply use autofill to discover all of the options.

### Emojis

Usage: `/figura emojis`

Emojis contains a list of all the emojis added by Figura. `/figura emojis all` can show you all of them at once.

### Export

Usage: `/figura export avatar`

Export, as the name suggests, exports certain files to your Figura directory. The most useful is `/figura export avatar` which puts your currently worn avatar's moon file into your directory. If you've lost your avatar and it's still on Figura's backend, you can retrieve its .moon file with this command.

### Links

`/figura links`

Links contains all the links for various Figura pages.

### Load

[WIP]

### Reload

`/figura reload`

Reload reloads your currently equipped avatar.

### Run

Usage: `/figura run log("Hello World")`

Run runs whatever lua code you type after it.

## Debug Mode Commands

More commands can be unlocked by turning Debug Mode on in Figura's settings.

### Backend2

[WIP]

### Set_Avatar

Usage: `/figura set_avatar targetuuid sourceuuid`

Set_avatar can be used to set the avatar of an entity using its uuid. targetuuid is the entity whose avatar is being set, and sourceuuid is the entity from where the avatar is coming from. For example, if you were to set a cow to have the avatar you're wearing, the cow's uuid would be the targetuuid and your uuid would be the sourceuuid.
19 changes: 19 additions & 0 deletions docs/tutorials/Keybinds.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,25 @@ function events.tick()
end
```

## Canceling A Key Press

A key press can be "cancelled" (Minecraft won't register it as being pressed) using `return`. Specifically, if you `return true` in the function for the key press it will cancel the press. Returning a non-truthy value will not cancel the key press, so you can use a toggling variable to control the return. Note that returning in the ping will not cancel the key press, only doing it inside the keybind's press function will cancel it.

Below is an example for cancelling the detection of the `w` key while also sending a ping.

<!-- prettier-ignore -->
```lua
function pings.examplePing()
log("Pressed!")
end
local exampleKey = keybinds:newKeybind("Keybind Name", "key.keyboard.w")
exampleKey.press = function()
pings.examplePing() return true
end
```

If you want to cancel without sending a ping, that is completely possible. But the return always has to be at the end of the function.

## Using A Vanilla Keybind

If you want to detect a vanilla action like attacking or walking forwards but want it to be compatible in the case that someone bound forward to an arrow key you can directly get the vanilla keybind and use it. There's multiple ways to accomplish this but we'll use the same method as previous examples.
Expand Down

0 comments on commit 878dcbf

Please sign in to comment.