Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DFScript v2 #51

Open
wants to merge 7 commits into
base: 1.20.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build
on:
push:
branches:
- '1.20.2'
- '1.20.4'

jobs:
build:
Expand Down
98 changes: 14 additions & 84 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,100 +10,30 @@ DFScript is a mod created for DiamondFire to allow scripting on the client. This

## About
DFScript adds the ability to add new features through the added
'scripting' ability. Scripting is constructing event based code (similar to DiamondFire) inside a client side menu, with the events and actions being simple client-based activities.
'scripting' ability. Scripting is constructing event based code (similar to DiamondFire) inside a web ui, with the events and actions being simple client-based activities.

For example, a script could play a sound when the player receives a message with their name in it, or automatically add the @ character in front of sent messages.
For example, a script could play a sound when the player receives a message with their name in it, or automatically add the @ character in front of sent messages.
___

To access the scripting menu, run `/scripts`, and a menu will appear showing all of the scripts you have installed. Here you can toggle, delete, edit and upload scripts.
*(A simple menu which can disable scripts can be accessed through the button in the top left.)*
To access the DFScript menu, run `/dfscript`, and a menu will appear showing many different options, you can then press **Installed Scripts** to view scripts you currently have installed, here you can toggle scripts on and off or press **Dashboard** to visit the scripting dashboard and create/install new scripts.
*(The same many can be accessed on the multiplayer connection screen)*

To install a script you can click 'Add' and browse through scripts that others have created, or select 'New Script' if you would like to create one yourself.
To install a script you can locate the one you wish to install via the [public directory](https://dfscript.techstreet.dev/public/) and then press **Install Script** the script will then automatically install on your client and be enabled.

## Creating Scripts
To create a new script, access the [dashboard](https://dfscript.techstreet.dev/) from here you can press the **New Script** button, and then name and version your script, it will be created and displayed in the main menu. From here, you can edit, upload and delete.

To create a new script, run `/script`, select 'Add', and 'New Script'. After naming your script, it will be created and displayed in the main menu. From here, you can edit, upload, delete, and toggle your script.

Here is what each of these actions do:
- ![Edit icon](https://i.imgur.com/T01dmur.png) Edit: From this menu, you can add options and code to your script.
- ![Upload icon]( https://i.imgur.com/0FuRXJ1.png) Upload: Uploads the script so that others with the mod can install and use it. (They can not modify the code)
- ![Delete icon](https://i.imgur.com/Ya9xyWH.png) Delete: Deletes your script permanently.
- ![enter image description here](https://i.imgur.com/Av7lZmu.png)**/**![enter image description here](https://i.imgur.com/I8PXtvr.png) Toggle: Toggles your script on and off. When a script is off, it does not run at all. (Red means script is currently on, green means script is off)

To edit your script, select the edit icon and a new menu will be opened. From here, you can add code, change your scripts description and add config options.

- ![Settings Icon](https://i.imgur.com/fy9SfQP.png) From here you can write a short description about your script to tell others who may use it any important information.
You can also add config options which users can change without accessing the code. The values of these options can be used in your code. (More info [later](https://github.com/not-first/DFScript-updated-readme-/edit/1.19.2/README.md#changing-parameters))



## Interactions
**Left click**
- Use on buttons to click them
- Use to add code to your script, and to add parameters to code blocks
- Use in your script menu to edit parameters of a code block
- Use to select text box

**Right Click**
- Use on code blocks in your script menu to bring up a small menu where you can:
- Delete the code block
- Insert code before the code block
- Insert new code after the code block
- Can also be used on buttons to click them

**Escape**
- Use in any menu to go back to the previous menu

**Scroll**
- Moves a menu up and down

## Editing Scripts
*Note that it is only possible to edit code in a script you have made yourself. Any downloaded script will still be able to be deleted, toggled, and have its options changed, but the code will be inaccessible.*

Select the 'Add' button to add code to your script. From there you can select the category, and a specific code block. There is a short description about each block if you hover over them to help you understand what they do.

All code is set in one menu. Just like in DiamondFire, all code must start with an event. When that event is triggered, the code inside it will run from top to bottom.

### Changing Parameters
Most code blocks need parameters inside them so they can execute properly. You can view what parameters a code blocks needs by hovering over its icon in your script menu. An asterisk after a parameter means that a value for it is not required and the code block can run without it.

To add values for these parameters, left click on the code block you would like to edit and a menu will be brought up. Any parameters already in the code block will show. To add values, click the 'Add' button, and a new menu with a text input box will appear.
___
This input screen has two important sections.
1. The text box. Here is where you input a number, string, name of a variable or any other type of value required. Make sure you have finished the value you would like to add to your code block before selecting a type.
2. The value type. Here is where you select what type of value you would like to add to your code block. For example, if I wanted to add a variable called 'score', I would type `score` in the text box, then click on the variable icon (magma cream). A variable named 'score' will be added to the code block.
Most value types and their icons such as a text, a number and a variable you may recognise from DiamondFire, but here are some ones you may not be familiar with:

- Client Value: *(Requires no text input.)* Selecting this value will bring up a menu containing values related to the client, very similar to DiamondFire's game values.
Some of these can be used in any scenario, such as the number of the players selected hotbar slot, or the players main hand item.
Others can only used if the code is under a certain event, such as the last received message *(pairs with the 'OnRecieveChat' event)* or the last received sound *(pairs with the 'OnRecieveSound' event)*.
- Config Value: *(Requires no text input.)* Selecting this value will bring up a menu of all the config options you have added to your script. These will act as a variable and return a value of the option.
For example, if I had created Option 1 as a string, and the user had set it to `complete`, the config value for options 1 would return 'complete' as a string.
These can be nearly any value type, so pay attention to make sure the code block you are using supports the value type.

*Currently, changing the order and contents of added parameters is not supported, so you will have to delete and redo if you make a mistake.*
## Disabling Scripts - !!
Sometimes when you are creating a script, you may accidentally make your client complete actions which are against DiamondFire rules, such as making your client spam, or other similar actions. If this is the case, immediately leave the server. In the top left if your multiplayer screen, there will be a button button (![Scripts icon]( https://i.imgur.com/Q2phpZz.png)) which will open up a version of the scripts menu where scripts can be disabled. When you rejoin the server the script will now be disabled. **You can edit code inside a disabled script, so make sure you have fixed the issue before re-enabling the script.**
If the issue came from a script you did not make, report the script in the [discord](https://discord.gg/gtfFwWEapx) so it can be removed.
## Downloading Scripts
To download a script that someone else has made, open the main scripts menu, select add, and there will be a list of scripts others have made as well as a search bar. Scripts with a star next to their name mean that they are verified and safe to use.
Sometimes when you are creating a script, you may accidentally make your client complete actions which are against DiamondFire rules, such as making your client spam, or other similar actions. If this is the case, immediately leave the server. In the top left if your multiplayer screen, there will be a button button (![Scripts icon](https://i.imgur.com/Q2phpZz.png)) which will open up a version of the DFScript menu where scripts can be disabled. When you rejoin the server the script will now be disabled.

**!! Unverified scripts may potentially be dangerous, not towards your computer, but they may make your client spam or do other activities not appreciated on DiamondFire. You can ask in the discord if you are unsure about a certain script. !!**

Selecting a script from here will bring up a menu showing information about the script such as the authors name, script ID, and if it has been approved or not.
Clicking the install button from here will add the script to your client. A message will be shown in chat verifying the script has been loaded. This downloaded script will appear in the normal scripts menu, just without the ability to upload it or edit its code.

## Commands and Files

All DFScript commands begin with `/scripts`.
- `/scripts` Opens the main script menu.
- `/scripts recursion (number)` Changes the number of events that can trigger in a single tick.
- `/scripts reload` Reloads all of the scripts on your machine. Use this is you are manually installing are changing scripts through files.
- `/scripts vars (script name)` Lists the values of all the variables in the selected script. Similar to DiamondFire's /p vars command.

To access script files go to `%appdata%\.minecraft\DFScript` on your machine. Here there will be a 'Scripts' folder, which contains all the scripts you have installed in the form of a json file. If a script manages text files, they will be in a sub folder called `scriptname.json-files`.
If the issue came from a script you did not make, report the script in the [discord](https://discord.gg/gtfFwWEapx) so it can be removed.

You can easily back up scripts here by copy and pasting the json file into another location. Pasting and deleting json files from this folder will do the same in-game, so be careful about what you change.
## Commands
All DFScript commands begin with `/dfscript`.
- `/dfscript` Opens the main DFScript menu.
- `/dfscript recursion (number)` Changes the number of events that can trigger in a single tick.
- `/dfscript reload` Downloads and reloads all of the scripts on your machine.
- `/dfscript vars (script name)` Lists the values of all the variables in the selected script. Similar to DiamondFire's /p vars command.
___

<p>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '7.1.2'
}
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.4
loader_version=0.15.3
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.7
# Mod Properties
mod_version=1.0-SNAPSHOT
maven_group=io.github.techstreet.dfscript
archives_base_name=DFScript
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.91.2+1.20.2
fabric_version=0.96.1+1.20.4
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
35 changes: 23 additions & 12 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

#
# Copyright 2015-2021 the original authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,10 +32,10 @@
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions $var�, �${var}�, �${var:-default}�, �${var+SET},
# ${var#prefix}�, �${var%suffix}, and $( cmd );
# * compound commands having a testable exit status, especially case;
# * various built-in commands including command�, �set, and ulimit.
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
Expand All @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -143,12 +140,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand All @@ -205,6 +210,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
15 changes: 9 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
Loading