Live2D看板娘代码引用

本文介绍了如何使用Live2D看板娘插件的PHP后端API,包括模型、皮肤的切换方式,如单模型单皮肤、多组皮肤递归切换,以及详细的目录结构和接口用法。还涵盖了常见问题及解决方法,如模板地址修改和对话内容调整。
摘要由CSDN通过智能技术生成

下载相关插件

Live2D 看板娘插件 (https://www.fghrsh.net/post/123.html) 上使用的后端 API

特性

- 原生 PHP 开发,无需伪静态,开箱即用
- 支持 模型、皮肤 的 顺序切换 和 随机切换
- 支持 单模型 单皮肤 切换、多组皮肤 递归穷举
- 支持 同分组 多个模型 或 多个路径 的 加载切换

目录结构

│  model_list.json              // 模型列表

├─model                         // 模型路径
│  └─GroupName                  // 模组分组
│      └─ModelName              // 模型名称

├─add                           // 更新皮肤列表
├─get                           // 获取模型配置
├─rand                          // 随机切换模型
├─rand_textures                 // 随机切换皮肤
├─switch                        // 顺序切换模型
├─switch_textures               // 顺序切换皮肤
└─tools
        modelList.php           // 列出模型列表
        modelTextures.php       // 列出皮肤列表
        name-to-lower.php       // 文件名格式化

添加模型

单模型 单皮肤 切换
    - 单次加载只输出一个皮肤
    - 皮肤放在 `textures` 文件夹,自动识别

shell

│  index.json
│  model.moc
│  textures.cache       // 皮肤列表缓存,自动生成

├─motions
│      idle_01.mtn
│      idle_02.mtn
│      idle_03.mtn

└─textures
        default-costume.png
        school-costume.png
        winter-costume.png

单模型 多组皮肤 递归穷举
    - 多组皮肤 组合模型、穷举组合
    - 皮肤文件夹按 `texture_XX` 命名
    - 添加 `textures_order.json` 列出组合


shell
│  index.json
│  model.moc
│  textures.cache
│  textures_order.json

├─motions
│      idle_01.mtn
│      idle_02.mtn
│      idle_03.mtn

├─texture_00
│      00.png

├─texture_01
│      00.png
│      01.png
│      02.png

├─texture_02
│      00.png
│      01.png
│      02.png

└─texture_03
       00.png
       01.png

textures_order.json
[
    ["texture_00"],
    ["texture_01","texture_02"],
    ["texture_03"]
]

textures.cache
[
    ["texture_00/00.png","texture_01/00.png","texture_02/00.png","texture_03/00.png"],
    ["texture_00/00.png","texture_01/00.png","texture_02/00.png","texture_03/01.png"],
    ["texture_00/00.png","texture_01/01.png","texture_02/01.png","texture_03/00.png"],
    ["texture_00/00.png","texture_01/01.png","texture_02/01.png","texture_03/01.png"],
    ["texture_00/00.png","texture_01/02.png","texture_02/02.png","texture_03/00.png"],
    ["texture_00/00.png","texture_01/02.png","texture_02/02.png","texture_03/01.png"]
]

同分组 多个模型 或 多个路径 切换
    - 修改 `model_list.json` 添加多个模型

shell

├─model
│  ├─Group1
│  │  ├─Model1
│  │  │      index.json
│  │  │
│  │  └─Model2
│  │          index.json
│  │
│  ├─Group2
│  │  └─Model1
│  │          index.json
│  │
│  └─GroupName
│     └─ModelName
│          │  index.json
│          │  model.moc
│          │
│          ├─motions
│          └─textures

 

model_list.json
{
    "models": [
        "GroupName/ModelName",
        [
            "Group1/Model1",
            "Group1/Model2",
            "Group2/Model1"
        ]
    ],
    "messages": [
        "Example 1",
        "Example 2"
    ]
}

接口用法

- `/add/` - 检测 新增皮肤 并更新 缓存列表
- `/get/?id=1-23` 获取 分组 1 的 第 23 号 皮肤
- `/rand/?id=1` 根据 上一分组 随机切换
- `/switch/?id=1` 根据 上一分组 顺序切换
- `/rand_textures/?id=1-23` 根据 上一皮肤 随机切换 同分组其他皮肤
- `/switch_textures/?id=1-23` 根据 上一皮肤 顺序切换 同分组其他皮肤

常见问题

1、修改模板地址

1、打开assets文件夹,找到waifu-tips.js文件

2、搜索http://,将地址进行过更换,一共三处

2、添加/修改对话

1、打开assets文件夹,找到waifu-tips.json文件

2、找到想要更换语句的动作(mouseover:悬停 click:单击 seasons:节日)

3、查询要更改的语句/添加新增的语句

3、引用“一言”接口后显示语句修改

1、打开assets文件夹,找到waifu-tips.js文件

2、查找showHitokoto方法,更改显示内容

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值