登陆 注册 QQ登陆
快捷导航
查看: 9|回复: 0

[模组分享] Scarpet additions (scarpet-additions)-MOD模组

[复制链接]

4999

主题

60

回帖

1万

积分

龙❁妻

Rank: 8Rank: 8

经验
10280 EP
金粒
5181 粒
绿宝石
20 块
爱心
0 点
发表于 2025-8-10 19:12:15 | 显示全部楼层 |阅读模式 IP:浙江宁波
Scarpet additions (scarpet-additions)Github |相关wiki |源站链接支持: fabricAdds some miscellaneous new functions like http requests to the scarpet language



https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@2.8.0/assets/cozy/social/github-singular_vector.svg]

https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@2.8.0/assets/cozy/social/discord-singular_vector.svg]

![scarpet-additions](链接)

A https://modrinth.com/mod/carpet]Carpet mod extension for some additional https://github.com/gnembon/fabric-carpet/wiki/Scarpet]scarpet functions

**Reqires https://modrinth.com/mod/carpet]Carpet mod**

Functions

`convert_color(color,model,output)`

Converts a color from one `model` to another.

`color` -> List: Depending on specified `model`

`model` -> String: Input color model, can be `RGB`, `RGBA` or `HSB`

* RGB: List of a red, green and blue value

* RGBA: List of a red, green, blue and alpha value

* HSB: List of a hue, saturation and brightnes value

`output` -> String: Output color model, can be `RGB`, `RGBA`, `HEX` or `NUM`

* RGB: List of a red, green and blue value

* RGBA: List of a red, green, blue and alpha value

* HEX: String of hex characters (without leading \'#\') Can be used for `format()`

* NUM: Number representing the color as 4 bytes: 0xRRGGBBAA. Can be used for `\'color\'` parameter in `draw_shape()`

Examples:

convert_color([255,128,0],\'rgb\',\'hex\'); -> \'FF8000\'

convert_color([255,128,0],\'rgb\',\'num\'); -> 0xff7f00ff

convert_color([0,255,255],\'hsb\',\'hex\'); -> \'FF0000\'

convert_color([120,255,255],\'hsb\',\'hex\'); -> \'00FF00\'

Example:

py

__on_tick() -> (

    if((tick_time() % 2) == 0,

        headerHue = tick_time()%360;

        headerGlossIndex = (floor(tick_time()/3)%40)-10;

        header = [];

        title = \'MinecraftServer\';

        for(range(length(title)),

            if(abs(_-headerGlossIndex) < 3,
                c = convert_color([headerHue,abs(_-headerGlossIndex)/3*255,255],\'hsb\',\'hex\');
            ,
                if(_ < 7,
                    c = convert_color([headerHue,255,190],\'hsb\',\'hex\');
                ,
                    c = convert_color([headerHue,255,255],\'hsb\',\'hex\');
                );
            );
            put(header,null,str(\'b#%s %s\',c,slice(title,_,_+1)));
        );
        header = format(header);
        footer = format(\'r to the server!\');
        set_tab_text(header,footer);
  )
);

`http_request(options)`
Performs a http request specified by the given `options`.
This call is blocking, so you should use it in a `task()`!
The `options` parameter is a map value with the following keys:
* `uri` (String): The URI to request from* `method` (String, optional): The http request method. For example `GET`, `POST`, `DELETE`,... Defaults to `GET`* `headers` (Map, optional): Each map entry is a string key pointing to a string, or list of strings* `body` (String): The body for `POST` or other requests
The function returns a map with the following entries:
* `status_code` (number): The status code of the request* `body` (String): The body returned from the request* `headers` (Map: string -> [strings]): The received response headers* `uri` (String): The originally requested URI
Note that the response body is not parsed as json or html escaped.Use the `escape_html` and `unescape_html` functions,as well as the scarpet-builtins `encode_json` and `decode_json`.
Example usage:
js// simple get request and parsing
response = http_request({\'uri\'->\'https://opentdb.com/api.php?amount=1\'});
print(\'Response: \' + response);
if(response:\'status_code\' != 200,print(\'Request failed: \' + response:\'status_code\');,body = decode_json(response:\'body\');print(\'\\n\\nBody: \' + body);
question_data = body:\'results\':0;question = unescape_html(question_data:\'question\');answer = unescape_html(question_data:\'correct_answer\');
print(\'\\n\\n\\n\' + question + \'\\n\' + answer););
`escape_html(html)`
Returns the escaped html string (e.g. `\"` -> `\"`)
`unescape_html(html)`
Returns
来自Modrinth所有游戏版本1.21.31.21.41.21.51.21.61.21.71.21.81.20.51.20.61.211.21.11.20.41.201.20.11.20.21.19.41.19.11.19所有类型fabric1.1.3scarpet-additions-1.21.3-1.1.3.jar下载1.1.3#Release* http requests failing will now throw a custom scarpet exception type `http_request_error`展开版本: 1.1.3支持游戏: 1.21.3, 1.21.4, 1.21.5, 1.21.6, 1.21.7, 1.21.8类型:FabricRelease下载次数: 3101.1.2scarpet-additions-1.20.5-1.1.2.jar下载1.1.2#Release* Updated to MC 1.20.5展开版本: 1.1.2支持游戏: 1.20.5, 1.20.6, 1.21, 1.21.1类型:FabricRelease下载次数: 2971.1.1scarpet-additions-1.20.4-1.1.1.jar下载1.1.1#Release* Updated to MC 1.20.4展开版本: 1.1.1支持游戏: 1.20.4类型:FabricRelease下载次数: 1961.1.0scarpet-additions-1.20-1.1.0.jar下载1.1.0#Release* Updated to Minecraft 1.20展开版本: 1.1.0支持游戏: 1.20, 1.20.1, 1.20.2类型:FabricRelease下载次数: 3351.0.4scarpet-additions-1.19.4-1.0.4.jar下载1.0.4#Release* Updated to Minecraft 1.19.4展开版本: 1.0.4支持游戏: 1.19.4类型:FabricRelease下载次数: 1421.0.3scarpet-additions-1.19.2-1.0.3.jar下载1.0.3#Release* Reworked `http` function to be more versatile, and renamed to `http_request`* Added `escape_html` and `unescape_html` functions, since the http function no longer parses and escapes json automatically* Added a discord link to the Modmenu page展开版本: 1.0.3支持游戏: 1.19.1类型:FabricRelease下载次数: 1271.0.2scarpet-additions-1.19.1-1.0.2.jar下载1.0.2#Release* `http()` function works now展开版本: 1.0.2支持游戏: 1.19.1类型:FabricRelease下载次数: 1161.0.1scarpet-additions-1.19.1-1.0.1.jar下载1.0.1#Release* Updated to minecraft 1.19.1展开版本: 1.0.1支持游戏: 1.19.1类型:FabricRelease下载次数: 1,8071.0.0scarpet-additions-1.19-1.0.0.jar下载1.0.0#ReleaseInitial modrinth releasePrevious releases can be found [here](https://github.com/replaceitem/scarpet-additions/releases)展开版本: 1.0.0支持游戏: 1.19类型:FabricRelease下载次数: 154全部版本
文章类型:收录layui.use([\'form\'], function(){
var form = layui.form;
});

游客,如果您要查看本帖隐藏内容请回复
Scarpet additions
楼主 2025-8-10 19:12:15 回复 收起回复
小僵尸论坛感谢有你~
回复 论坛版权

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 手机动态码快速登录

本版积分规则



官方

新浪微博 腾讯微博 微信公众号 投稿规则 版权声明 捐助我们

官方QQ①群: 291907844 (点击加群)
官方QQ②群: 421312192
官方QQ③群: 528726532

介绍

我的世界(Minecraft)小僵尸论坛
收录了来自各地的我的世界(MC)爱好者们的各种资源

须知: 切勿滥用举报,任何与举报相关的信息必须属实!

"Minecraft"以及"我的世界"为Mojang Synergies AB的商标 本站与Mojang以及微软公司没有从属关系

QQ|Archiver|手机版|小黑屋|Minecraft(我的世界)小僵尸论坛 |网站地图

GMT+8, 2025-8-23 20:27 , Processed in 0.210634 second(s), 48 queries .

快速回复 返回顶部 返回列表