Skip to content

Commit

Permalink
a bunch of stuff idk i kinda forgot this was connected to github
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAwesomeOwl committed Aug 30, 2024
1 parent d2ce81b commit f9d5904
Show file tree
Hide file tree
Showing 12 changed files with 387 additions and 162 deletions.
103 changes: 103 additions & 0 deletions docs/codeblocks/action.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
## Syntax
Action syntax is as follows:
```tc
target:Action(arguments){tags};
```

### Arguments

Arguments are values seperated by commas. Arguments with no value are converted to empty slots.
```tc
default:SendMessage("Hello","world!");
default:SendMessage( ,"Slot 2 string", , ,"Slot 5 string");
```

### Tags

Tag syntax can be thought of as a dictionary:
```tc
default:SendMessage("Tags!"){"Alignment Mode" = "Centered", "Inherit Styles" = "True"};
```
To use a variable as the tag value, a default must be provided immediately after:
```tc
default:SendMessage("Tags!"){"Alignment Mode" = global messageMode ? "Centered"};
```
If you are using the vscode extension, you can use the autocomplete shortcut (`ctrl+space` by default) to quickly insert tag names and values.

Arguments and tags are both optional and can be left out, making all of these valid action calls:
```tc
default:StopSounds(snd["Pling"]);
default:StopSounds{"Sound Source" = "Jukebox/Note Blocks"};
default:StopSounds;
```

## Player Actions

Player actions use the following targets:

- `default`
- `killer`
- `damager`
- `shooter`
- `victim`
- `allPlayers`
- `selection`

```tc title="Examples"
default:GivePotionEffect(pot["Saturation"]){"Effect Particles" = "None", "Overwrite Effect" = "False"};
default:SetVisualShoulderParrot{"Shoulder" = "Left", "Type" = "Cyan"};
allPlayers:SendMessage(s"<green>%default<white>has joined!");
selection:SetToCreativeMode;
victim:Heal(game.EventDamage/2);
shooter:GiveItems(item["Arrow"]);
```


## Entity Actions

Entity actions use the following targets:

- `selectionEntity`
- `defaultEntity`
- `killerEntity`
- `damagerEntity`
- `shooterEntity`
- `victimEntity`
- `allEntities`
- `allMobs`
- `projectile`
- `lastEntity`

```tc title="Examples"
defaultEntity:Teleport(default.Location + vec[0,10,0]);
defaultEntity:EatGrass;
selectionEntity:Damage(5);
projectile:SetArrowNoClip{"Has NoClip" = "Enable"};
allMobs:FaceLocation(default.Location)
lastEntity:SetTag("owner","%default");
```

## Game Actions

Game actions use the `game` target.

```tc title="Examples"
game:SpawnMob(item["zombie_spawn_egg"],game.EventBlockLocation);
game:CancelEvent;
game:SummonLightning(victim.Location);
game:SetBlock(loc[10,50,10],item["beacon"]);
```

1 change: 1 addition & 0 deletions docs/codeblocks/set_var.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Math operations can be done much easier by using [Expressions](../language_features/expressions.md). You should only do math via setvar actions when you want absolute control over the template's codeblocks, otherwise its easier to let the compilier handle it for you.
3 changes: 3 additions & 0 deletions docs/dingus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Dignus

## oh great heavens
Empty file.
44 changes: 44 additions & 0 deletions docs/getting_started/plot_setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Plot Setup

If you haven't already installed the VSCode extension and CodeUtils, see [Installation](/getting_started/installation.md)

!!! warning "Don't delete your code!"
Always make sure to start with an empty plot. Never run terracotta on plots made using normal DiamondFire coding because there is no way to recover code terracotta may overwrite.

## Creating a Project
First, create a project folder to hold all your plot's code and open it in VSCode. Then from the Run and Debug menu, click `create a launch.json file` and select `Terracotta` from the list of langauges. In the newly created `launch.json` file, make sure to set `plotSize` appropriately for the plot you will be compiling to.

Plot Type | Plot Size
- | -
Basic | `50`
Large | `100`
Massive | `300`
Mega | `300`

??? info "All `launch.json` parameter explanations"
- `folder`: The folder to compile. Pretty self-explanatory.
- `exportMode`: Can be either `"sendToCodeClient"` or `"saveToFiles"`
- `"sendToCodeClient"`: When running, automatically place compiled templates via CodeClient
- `"saveToFiles"`: (CURRENTLY UNIMPLEMENTED!) When running, save all compiled templates to files
- `autoSwitchToDev`: If in play or build mode upon compiling, automatically enter dev mode. If left disabled, trying to compile while in build or play mode will fail. Only applies if `exportMode` is `"sendToCodeClient"`.
- `autoSwitchToPlay`: Automatically enter play mode after all compiled templates have been placed.
- `plotSize`: Used by the codeline splitter to know what length templates should be limited to. If you want to "disable" the codeline splitter, just set this to a very high number.

## Compiling a Project
Terracotta script files have the extension `.tc`. Create a script in your project folder to test with:

``` tc title="test.tc"
PLAYER_EVENT Join;
default:SendMessage("Hello world!");
```

In your Minecraft client, run the command `/auth`. This gives Terracotta permission to manipulate your plot using CodeClient. You will need to do this every time you restart either Minecraft or VSCode, but not every time you compile.

Once all that's complete, press f5 or click the green play symbol at the top of Run and Debug to compile your plot.

!!! warning
Sometimes CodeClient will give up while trying to place code. If this happens, run `/abort` in your Minecraft client and try recompiling.

If you find yourself getting stuck in a plot border, run `/worldplot <your plot size>`.

5 changes: 5 additions & 0 deletions docs/getting_started/syntax_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TODO

semicolons

non whitespace signifigant
154 changes: 14 additions & 140 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,152 +1,26 @@
this is obviously heavily work in progress
# Terracotta

# very good and awesome documentation
[DiamondFire](https://www.mcdiamondfire.com) is a Minecraft server where you can make your own minigames using block code.

# THIS CHANGE IS DEPLOYED VIA GITHUB ACTIONS!
I do not like block code.

```tc
FUNCTION numbergame;
Terracotta is a text-based programming language that compiles to DiamondFire templates with the goal of *actually* making plot development easier. Unlike previous text-to-df languages, Terracotta makes no compromises when it comes to functionality or convenience. Everything you can do with DiamondFire blocks is just as easy or easier in Terracotta.

"\u{13487137887} dingus \n akjshdg"
To get started, visit [Installation Guide]() and [Plot Setup](getting_started/plot_setup.md)

dict:Get:num;
## Why Terracotta is awesome

line i: num = saved ["%default number"];
- Expressions. Almost anywhere you can put a value in Terracotta, you can write an expression. You never have to think about %math again!

default:SendMessage("The number game!! compiled with terracotta");
- Automatic codeline splitting. Codelines that are too long for your plot will be automatically split into
multiple functions.

repeat Forever {
line i += 1;
line rainbowIndex += 1;
- Human-compatable syntax. Terracotta looks and feels like an actual programming language, not like bytecode.

line timeUnit = "Seconds";
default:SendActionBar(s"The number: <green>" + line i);
- Intellisense/autocomplete support. Remembering specific names of actions sucks, so you can get autocomplete to do it for you. Also supports completion of variable names, function names, action tags, potion effect ids, etc.

if (default ? IsSprinting) {
line rngResult = num:Random(1, 20);
- Compiled code templates are placed automatically. Going from Terracotta code to a playable plot is as easy as pressing `f5`. (thanks CodeClient!)

#fish mode
if (default ? IsSwimming) {
#increase the number EVEN FASTER!
line i += 12345678912345;
- Only code templates that actually changed will be re-placed, making Terracotta usable for large plots.

default:SetRemainingAir(line rngResult * 30);
line msg = txt:ParseExpression("<blue>" + "!"*line rngResult + " <aqua>FISHMODE!!!!!! <rainbow:%var(rainbowIndex)>" + line i + " <blue>" + "!"*line rngResult);
}
#normal sprint mode
else {
line msg = txt:ParseExpression("<light_purple>" + "!"*line rngResult + " <white>The number: <rainbow:%var(rainbowIndex)>" + line i + " <light_purple>" + "!"*line rngResult);
}
default:SendActionBar(line msg: txt);
line timeUnit = "Ticks"; #FAST
}
if (default ? IsSneaking) {
default:PlaySound(snd["Anvil Land"]);
default:SendActionBar(s"<red>You have killed the loop!!! How dare you");
break;
}
if (line i < 0) {
line rngResult = num:Random(1, 200);
line msg = txt:ParseExpression("<red><obfuscated>" + "!"*line rngResult + " <reset><dark_red>what have you done... <#FF0000>" + line i + " <red><obfuscated>" + "!"*line rngResult);
default:SendActionBar(line msg: txt);
}
saved ["%default number"] = line i;
#reset code
if (default ? IsStandingOnBlock("nether_wart_block")) {
#launching code
default:LaunchTowardLocation(loc:Align(default.Location - vec[0,1,0]), -100);
default:GivePotionEffect(pot["Slow Falling",1,2 * 20]);
if (line i < 0) {
default:SendActionBar("&c&lFIRST, FIX YOUR MISTAKES");
line timeUnit = "Seconds";
} else {
line i = 0;
default:SendMessage("You have been reset");
default:SendActionBar; #clear action bar
}
}
wait(1){"Time Unit" = line timeUnit ? "Seconds"};
}
```

```tc
#100% accurate nether gen open sourced????
LAGSLAYER_CANCEL; PLAYER_EVENT Join;
default:SetToCreativeMode;
#var declarations
saved netherSpawnLoc: loc;
call setupVars;
# fake loading screen
local loadTime = 3*20;
default:SendTitle("&aGenerating...","real not clickbait",local loadTime);
default:GivePotionEffect(pot["Mining Fatigue",255,4*20]){"Show Icon" = "False","Effect Particles" = "None"};
default:GivePotionEffect(pot["Invisibility",255,4*20]){"Show Icon" = "False","Effect Particles" = "None"};
default:GivePotionEffect(pot["Blindness",1,4*20]){"Show Icon" = "False","Effect Particles" = "None"};
start loadLoop;
#teleport to nether
wait(0.5*20);
default:Teleport(global overworldPortalLoc);
wait(5);
#teleport to spawn
wait(2*20); #wait until player has been shoved back into plot bounds to avoid messing with getNetherLoc()
call getNetherLoc(line shiftedLoc, global netherSpawnLoc);
default:Teleport(line shiftedLoc);
default:SendTitle("","");
default:SetToAdventureMode;
default:SetAllowFlight{"Allow Flight" = "Enable"};
default:GivePotionEffect(pot["Fire Resistance"]){"Effect Particles" = "None","Show Icon" = "False"};
wait(5);
start interactionEntity;
line poweredByLoc: loc;
call getNetherLoc(line poweredByLoc, loc[345,84,338]);
global hasSpawnedEntities = 1;
game:SpawnTextDisplay(line poweredByLoc,"POWERED BY:");
lastEntity:SetDisplayScale(5,5,5);
lastEntity:SetDisplayBillboard{"Billboard Type" = "Fixed"};
lastEntity:SetTextDisplayBackground("#000000",0);
lastEntity:SetTextDisplayTextShadow{"Text Shadow" = "Disable"};
lastEntity:SetDisplayRotationFromEulerAngles(0,180,0);
lastEntity:SetDisplayBrightness(15,15);
```


```tc
FUNCTION DispText;
PARAM text: txt;
PARAM spawnAt: loc;
PARAM size: optional plural any = vec[1,1,1];;
if (var?IsType(line size){"Variable Type" = "Number"}) {
line size = vec[line size,line size,line size];
}
game:SpawnTextDisplay(line spawnAt,line text);
lastEntity:SetDisplayScale(line size);
lastEntity:SetDisplayRotationFromEulerAngles(loc:GetCoordinate(line spawnAt){"Coordinate" = "Pitch"},loc:GetCoordinate(line spawnAt){"Coordinate" = "Yaw"},0);
lastEntity:SetTextDisplayBackground("#000000",0);
lastEntity:SetTextDisplayTextShadow{"Text Shadow" = "Disable"};
lastEntity:SetDisplayBillboard{"Billboard Type" = "Fixed"};
lastEntity:SetTextDisplayLineWidth(3785);
```
And of course, being a text based programming language, you get all sorts of nice things you don't get through normal DiamondFire like comments, copy+paste, easily readable code, etc.
Loading

0 comments on commit f9d5904

Please sign in to comment.