1
0
mirror of https://github.com/tacigar/maidroid.git synced 2024-11-16 07:10:21 +01:00

Compare commits

...

64 Commits

Author SHA1 Message Date
tacigar
ec56bc4325
Update README.md 2020-10-26 17:20:04 +09:00
tacigar
3b414ef40a
Merge pull request #175 from Rui-Minetest/patch-2
Use global_exists to test for the existence
2018-06-14 23:14:14 +09:00
tacigar
b574f4495a
Merge pull request #174 from Rui-Minetest/patch-1
Add nil check for egg_entity
2018-06-14 23:13:48 +09:00
Rui
a01a1a2cb5
Use global_exists to test for the existence 2018-01-05 18:28:44 +09:00
Rui
a29f888a54
Add nil check for egg_entity 2018-01-05 18:24:47 +09:00
tacigar
d2899c8672 Merge pull request #166 from chu-hai/nametag
Fix nametag
2017-01-15 08:51:11 +09:00
Chuhai
0525e26809 Fix nametag
Set default value from existing data.
Change item decrement timing.
Use is_maidroid() method.
2017-01-12 22:25:10 +09:00
tacigar
cb5305573d Merge pull request #164 from tacigar/tacigar/nametag
Modify nametag
2017-01-11 17:43:42 +09:00
tacigar
9973025ff7 Modify nametag 2017-01-11 10:57:26 +09:00
tacigar
9f1aabfc3a Merge pull request #161 from chu-hai/dummy_item
Improve dummy_item
2017-01-10 20:00:27 +09:00
Chuhai
ac8c7f6a30 Improve dummy_item. Use saved ObjectRef instead of minetest.get_objects_inside_radius() 2017-01-10 01:31:18 +09:00
tacigar
750802fd00 Merge pull request #160 from tacigar/tacigar/dummy_item
Fix bug of dummy item
Close #145
2017-01-09 23:45:53 +09:00
tacigar
44f2177a95 Fix bug of dummy item 2017-01-09 23:30:14 +09:00
tacigar
74654691dd Merge pull request #158 from Rui-Minetest/remove_product_name
Remove self.product_name
2017-01-09 09:59:32 +09:00
tacigar
d5caabe6b4 Merge pull request #156 from chu-hai/capture_rod
Add capture rod
2017-01-08 23:02:58 +09:00
Chuhai
52e6f40894 Move craftrecipe to crafting.lua 2017-01-08 22:38:11 +09:00
Rui
b66f560eea Remove self.product_name 2017-01-08 22:17:23 +09:00
Chuhai
796d63d741 Fix captured edd's description 2017-01-08 21:43:06 +09:00
Chuhai
20bd1f84f7 Add capture rod 2017-01-08 21:29:23 +09:00
tacigar
6064c2a62c Merge pull request #154 from tacigar/tacigar/readme
Update README.md
2017-01-08 19:22:11 +09:00
tacigar
d0cc89f404 Update README.md 2017-01-08 19:21:40 +09:00
tacigar
711c9ad9f7 Merge pull request #149 from tacigar/tacigar/toucher
Add Torcher Core
2017-01-08 11:43:30 +09:00
tacigar
7e090ce75d Update set_attach rotation 2017-01-08 11:41:38 +09:00
tacigar
e05dd18d7f Merge pull request #153 from tacigar/tacigar/readme
Update README-ja
2017-01-08 10:24:35 +09:00
tacigar
08bd42cb39 Update README-ja 2017-01-08 10:23:39 +09:00
tacigar
67b260ce5a Merge pull request #152 from tacigar/tacigar/readme
Update README-ja
2017-01-08 10:22:45 +09:00
tacigar
6344183aae Update README-ja 2017-01-08 10:22:20 +09:00
tacigar
2aa8e65dcb Merge pull request #151 from tacigar/tacigar/readme
Tacigar/readme
2017-01-08 09:49:35 +09:00
tacigar
af4db79642 Use a new logo in README 2017-01-08 09:49:11 +09:00
tacigar
c311f575c4 Add logo.xcf 2017-01-08 09:47:47 +09:00
tacigar
1f4c4fa8d7 Merge pull request #150 from tacigar/tacigar/readme
Update REAMD-ja
2017-01-08 00:09:07 +09:00
tacigar
0b2e1678a9 Update REAMD-ja 2017-01-08 00:07:03 +09:00
tacigar
d94f6fa8b7 Update dye_item_map of core_writer 2017-01-07 20:47:41 +09:00
tacigar
0cc9807d04 Add toucher core texture 2017-01-07 20:46:29 +09:00
tacigar
11305efe59 Add torcher core 2017-01-07 20:30:34 +09:00
tacigar
fbf93ecf2d Add maidroid#get_front method 2017-01-07 19:34:31 +09:00
tacigar
0664cb9050 Merge pull request #148 from tacigar/tacigar/readme
Update README
2017-01-07 18:56:11 +09:00
tacigar
a3e0589ca3 Update README 2017-01-07 18:54:47 +09:00
tacigar
50aeecef27 Merge pull request #147 from tacigar/tacigar/inventory
Add on_move and allow_move
2017-01-07 18:46:59 +09:00
tacigar
0011c39158 Add on_move and allow_move 2017-01-07 18:45:53 +09:00
tacigar
9185079c8b Merge pull request #144 from tacigar/tacigar/farming_v0.4.15
Fix bug for farming in v0.4.15
Close #143
2017-01-07 17:46:43 +09:00
tacigar
4ee3ef55dd Update on_step 2017-01-07 17:38:49 +09:00
tacigar
434d2ede0d Merge pull request #135 from HybridDog/pdisc_core
Programmable maidroid core
2017-01-06 22:22:40 +09:00
tacigar
7ed8b8172a Use farming.place_seed api for v0.4.15 2017-01-03 23:48:54 +09:00
tacigar
641e7e7613 Add owner's info 2017-01-03 23:16:21 +09:00
Hybrid Dog
2798eb6045 add doc file
A  maidroid/script/instruction_set_doc.lua
2017-01-03 15:10:19 +01:00
Hybrid Dog
9628c8efe2 drop self.thread in on_stop and add getvelocity, getacceleration and jump instructions
M  maidroid_core/cores/ocr.lua
2017-01-03 14:42:09 +01:00
Hybrid Dog
13013b7aa2 Add a maidroid core for player made programs 2017-01-03 14:42:09 +01:00
tacigar
e0b5ea3653 Merge pull request #142 from tacigar/tacigar/modify
Modify various
2017-01-03 10:44:52 +09:00
tacigar
4b32c4c5cd Modify various 2017-01-03 10:43:56 +09:00
tacigar
4fa83404d5 Merge pull request #140 from tacigar/tacigar/saving_data
Fix get_staticdata and on_activate, and remove core_name field of maidroid.
2017-01-02 09:17:33 +09:00
tacigar
158e9bde5d remove core_name field of maidroid and fix 2017-01-01 23:12:38 +09:00
tacigar
02f4d13af0 Update maidroid's get_staticdata and on_activate 2017-01-01 22:46:27 +09:00
tacigar
e238fe69f5 Merge pull request #138 from HybridDog/luacheck_fixes
remove unused code and use elapsed of node timer (the interval is configurable)
Thanks!
2017-01-01 09:31:19 +09:00
Hybrid Dog
73183a5a36 support node timer interval which is not 1 second
M  maidroid_tool/api.lua
2016-12-30 18:34:45 +01:00
Hybrid Dog
a5e36b9c50 remove unused parameters and variables
M  maidroid_tool/api.lua
2016-12-30 18:34:45 +01:00
tacigar
25f3bbaba5 Merge pull request #137 from tacigar/tacigar/directory
Update the directory structure
Close #136
2016-12-30 09:56:25 +09:00
tacigar
66770868f3 Update the directory structure 2016-12-30 09:46:25 +09:00
tacigar
8eff58524d Merge pull request #132 from tacigar/tacigar/soil
Update wet -> soil
2016-12-28 13:05:02 +09:00
tacigar
931391ea3f Update wet -> soil 2016-12-28 13:04:28 +09:00
tacigar
fa6e294977 Merge pull request #131 from tacigar/tacigar/directory
Update directory structure
2016-12-28 12:56:08 +09:00
tacigar
a2ee95fa72 Update directory structure 2016-12-28 12:54:04 +09:00
tacigar
ece313bd7a Merge pull request #130 from tacigar/tacigar/readme
Update READMEs
Close #120
2016-12-28 09:05:54 +09:00
tacigar
e0e904c44b Update READMEs 2016-12-28 09:04:38 +09:00
90 changed files with 899 additions and 286 deletions

View File

@ -1,77 +1,155 @@
# Maidroid
<img src="http://i.imgur.com/7HTh30v.png" />
<img src="http://i.imgur.com/wF1BBe6.gif" />
<img src=http://i.imgur.com/oWjrLtK.png>
## Overview
この MOD は Maidroid というメイドのロボットと, その Maidroid に農業やプレイヤーの追跡など, 様々なことをさせるコア, それらに関連する種々のツールを提供します.
Minecraft の著名な MOD, littleMaidMob にインスパイアされて開発を始めました.
Maidroid MOD は, Minecraft のMOD `littleMaidMob` にインスパイアされて開発を始めた, 孤独な Minetest の世界にメイドのロボットを追加する MOD です。
## 使い方
## Usage
### Maidroid の卵の作成
Maidroid を作り出すには, まず空の卵と卵に命を吹き込むための, Maidroid-Egg Writer を作成しなければなりません.
それらのレシピを以下に示します.
1. 空の卵と Maidroid-Egg Writer を後に示すレシピに従ってクラフトテーブルで作成します.
2. Maidroid-Egg Writer を設置し, 右クリックして formspec を開きます.
3. `Egg` と書かれたスロットに先に作成しておいた空の卵, `Fuel` と書かれたスロットに石炭, `Dye` と書かれたスロットに染料を配置します.
4. すると, Maidroid-Egg Writer が起動し, 浮いた卵が回転を始めます.
5. しばらく待つと, 命の吹き込まれた Maidroid の卵が完成しますので, 再度 Maidroid-Egg Writer を右クリックし取り出してください.
<img src="http://i.imgur.com/6ZGQF4J.png" />
<img src="http://i.imgur.com/Y5tzPGM.png" />
### コアの作成
次に, Maidroid-Egg Writer 設置, 右クリックし, `Egg` と書かれたスロットに先ほど作成した空の卵を置きます.
また, `Fuel` と書かれたスロットには石炭を, `Dye` と書かれたスロットには染料を設置します.
この染料の色によって, 生成される卵の種類が変化します.
以下に染料と, 生成される卵の対応を示します.
1. 空のコアと Core Writer を後に示すレシピに従ってクラフトテーブルで作成します.
2. Core Writer を設置し, 右クリックして formspec を開きます.
3. `Core` と書かれたスロットに先に作成しておいた空のコア, `Fuel` と書かれたスロットに石炭, `Dye` と書かれたスロットに染料を配置します.
4. すると, Core Writer が起動し, 上のコアが回転を始めます.
5. しばらく待つと, 情報が書き込まれたコアが完成しますので, 再度 Core Writer を右クリックし取り出してください.
|染料|Egg|
|:--|:--|
|dye:white|maidroid:maidroid_mk1_egg|
|dye:grey|maidroid:maidroid_mk2_egg|
|dye:dark_grey|maidroid:maidroid_mk3_egg|
|dye:black|maidroid:maidroid_mk4_egg|
|dye:blue|maidroid:maidroid_mk5_egg|
|dye:cyan|maidroid:maidroid_mk6_egg|
|dye:green|maidroid:maidroid_mk7_egg|
|dye:dark_green|maidroid:maidroid_mk8_egg|
|dye:yellow|maidroid:maidroid_mk9_egg|
|dye:orange|maidroid:maidroid_mk10_egg|
|dye:brown|maidroid:maidroid_mk11_egg|
|dye:red|maidroid:maidroid_mk12_egg|
|dye:pink|maidroid:maidroid_mk13_egg|
|dye:magenta|maidroid:maidroid_mk14_egg|
|dye:violet|maidroid:maidroid_mk15_egg|
### Maidroid の起動
しばらく待つと, 空の卵に命が吹き込まれ, 新しい卵に変換されます.
この卵を取り出し地面に投げつけると, Maidroid が誕生します.
1. 先に作成しておいた, 命の吹き込まれた Maidroid の卵を床に投げつけ, Maidroid を生成します.
2. 生成された Maidroid を右クリックし, `Core` と書かれたスロットに先ほど作成したコアを配置します.
3. すると, Maidroid はそのコアの情報に従って行動を始めます.
この状態では, Maidroid は止まったままです.
Maidroid を動かすためには, Core, つまり Maidroid の脳を埋め込む必要があります.
Core を作り出す手順は Maidroid を作り出す手順と非常に似ています.
まず, 空の Core と Core に情報を書き込む為の Core Writer を作成します.
それらのレシピを以下に示します.
### レシピ / 染料と卵 / 染料とコア
<img src="http://i.imgur.com/Sxnr38Y.png">
<img src="http://i.imgur.com/97VENIl.png">
クラフトテーブルで作成するノードやアイテムのレシピを以下に示します.
Core Writer を設置 & 右クリックし, `Core` スロットに空の Core, `Fuel` スロットに石炭, `Dye` スロットに染料を設置します.
Maidroid-Egg Writer 同様, 設置される染料の種類によって, 生成される Core の種類が変化します.
以下に染料と, 生成される Core の対応を示します.
```
b = dye:black c = default:cobble d = default:diamond
f = farming:cotton o = default:obsidian p = default:paper
s = default:steel_ingot w = bucket:bucket_water z = default:bronze_ingot
|染料|Core|説明|
|:--|:--|:--|
|`dye:red`|`maidroid_core:basic`|プレーヤーを追いかけてくる. |
|`dye:yellow`|`maidroid_core:farming`|農耕をする. |
Core Writer Egg Writer Nametag Empty Core Empty Egg
Core が生成されたら早速 Maidroid に埋め込みましょう.
Maidroid を右クリックし, Core と書かれたスロットに先ほど作成した Core を設置します.
すると, Maidroid が動き始めるでしょう.
| s | d | s | | d | w | d | | | f | | | s | s | s | | z | z | z |
| c | s | c | | c | s | c | | p | p | p | | s | o | s | | z | s | z |
| c | c | c | | s | c | s | | s | b | s | | s | s | s | | z | z | z |
```
## Dependencies
次に, 染料と対応する卵から生まれる Maidroid について以下に示します.
<table>
<tr>
<td>White</td><td><img src=http://i.imgur.com/lsdq79e.png> Mk1</td>
<td></td>
<td>Grey</td><td><img src=http://i.imgur.com/9ffUTjB.png> Mk2</td>
<td></td>
<td>Dark Grey</td><td><img src=http://i.imgur.com/HWtLvqb.png> Mk3</td>
</tr>
<tr>
<td>Black</td><td><img src=http://i.imgur.com/GoHRTRC.png> Mk4</td>
<td></td>
<td>Blue</td><td><img src=http://i.imgur.com/JTZTCS9.png> Mk5</td>
<td></td>
<td>Cyan</td><td><img src=http://i.imgur.com/hHw6mbD.png> Mk6</td>
</tr>
<tr>
<td>Green</td><td><img src=http://i.imgur.com/YdzOgvM.png> Mk7</td>
<td></td>
<td>Dark Green</td><td><img src=http://i.imgur.com/UXB52Ce.png> Mk8</td>
<td></td>
<td>Yellow</td><td><img src=http://i.imgur.com/hcd9vk4.png> Mk9</td>
</tr>
<tr>
<td>Orange</td><td><img src=http://i.imgur.com/6UjS63j.png> Mk10</td>
<td></td>
<td>Brown</td><td><img src=http://i.imgur.com/ayz4uP3.png> Mk11</td>
<td></td>
<td>Red</td><td><img src=http://i.imgur.com/rqknHh7.png> Mk12</td>
</tr>
<tr>
<td>Pink</td><td><img src=http://i.imgur.com/UNALjMo.png> MK13</td>
<td></td>
<td>Magenta</td><td><img src=http://i.imgur.com/iorRtmf.png> Mk14</td>
<td></td>
<td>Violet</td><td><img src=http://i.imgur.com/UX3w1Cx.png> Mk15</td>
</tr>
</table>
最後に, 染料とコアとの対応と, 各コアの簡易的な説明を以下に示します.
<table>
<tr>
<td>Red</td><td><img src=http://i.imgur.com/DlMzSGK.png> Basic Core</td><td>プレイヤーを追跡する. 荷物持ちに使える.</td>
</tr>
<tr>
<td>Yellow</td><td><img src=http://i.imgur.com/ALor72m.png> Farming Core</td><td>農業を行う.</td>
</tr>
<tr>
<td>White</td><td><img src=http://i.imgur.com/ypI2Fs6.png> OCR Core</td><td>プログラムが書かれた本を読み実行. 要 pdisc MOD.</td>
</tr>
<tr>
<td>Orange</td><td>Torcher Core</td><td>プレイヤーを追跡し, 暗い所を松明で照らす.</td>
</tr>
</table>
## 各コアの詳細
### Basic Core
このコアが埋め込まれた Maidroid はプレイヤーを追跡します.
Maidroid 自体の場所移動に使えますし, あるいは荷物持ちくらいにはなると思われます.
### Farming Core
このコアが埋め込まれた Maidroid は農業をします.
Farming Core を埋め込んだ状態で種を持たせれば, 土壌に種を植え始めます.
また, 収穫の時期になったら自動で回収して回ります.
このコアが埋め込まれた状態では柵を飛び越えないので, 農地の周りを柵で囲むことをお勧めします.
### OCR Core
pdisc MOD と連携するコアです.
このコアが埋め込まれた Maidroid は, 自身のインベントリ内のプログラムが書かれた本を読み, そのプログラムを実行します. 例えば, 以下のようなプログラムが書かれた本を OCR Core が埋め込まれた Maidroid に読ませると, 一秒ごとにビープ音とジャンプをします. 本のタイトルは `main` としなければなりません.
```
start: sleep 1
beep
jump 0.9
jmp start
```
### Torcher Core
このコアが埋め込まれた Maidroid はプレイヤーを追跡し, 自分の周りが暗いと判断したら松明を設置し, 周りを照らしてくれます.
採掘の際には結構役に立つと思われます.
## 依存 MOD
- bucket
- default
- dye
- [pdisc?](https://github.com/HybridDog/pdisc)
## Lisense
## 必要条件
- Minetest v0.4.14 以降
## ライセンス
- Source Code : [LGPLv2.1](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt) or later
- Resources : [CC-BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/) or later
## Contributers

149
README.md
View File

@ -1,81 +1,130 @@
※ This repository has not been actively updated for a long time.
# Maidroid
<img src="http://i.imgur.com/7HTh30v.png" />
<img src="http://i.imgur.com/wF1BBe6.gif" />
<img src=http://i.imgur.com/oWjrLtK.png>
## Overview
This mod is inspired littleMaidMob mod (for Minecraft), and provides maid robots called 'maidroid', cores that command them to do farming, following their owner and so on, involved tools.
Maidroid MOD is a MOD for Minetest which adds maid robots, inspired by littleMaidMob.
## How to Use
## Usage
### Create Maidroid Eggs
First, in order to create a maidroid, you have to craft an empty egg and an egg writer that convert eggs.
Those recipe is as follows.
1. Create an empty egg and Maidroid-Egg Writer by following the recipe below.
2. Place Maidroid-Egg Writer and open formspec by right-clicking it.
3. Put an empty egg into the slot labeled `Egg`, a coal into `Fuel`, and a dye into `Dye`.
4. Then, Maidroid-Egg Writer activates.
5. A short time later, a new maidroid egg will be created.
<img src="http://i.imgur.com/6ZGQF4J.png" />
<img src="http://i.imgur.com/Y5tzPGM.png" />
### Create Cores
After you place an egg writer node, and rightclick it, you have to place an empty egg to the slot labeled `Egg`, a coal to the slot labeled `Fuel`, and a dye to the slot labeled `Dye`.
The kind of the dye placed decides a egg produced.
The correspondences are as follows.
1. Create an empty core and Core Writer by following the recipe below.
2. Place Core Writer and open formspec by right-clicking it.
3. Put an empty core into the slot labeled `Core`, a coal into `Fuel`, and a dye into `Dye`.
4. Then, Core Writer activates.
5. A short time later, a new core will be created.
|Dye|Egg|
|:--|:--|
|dye:white|maidroid:maidroid_mk1_egg|
|dye:grey|maidroid:maidroid_mk2_egg|
|dye:dark_grey|maidroid:maidroid_mk3_egg|
|dye:black|maidroid:maidroid_mk4_egg|
|dye:blue|maidroid:maidroid_mk5_egg|
|dye:cyan|maidroid:maidroid_mk6_egg|
|dye:green|maidroid:maidroid_mk7_egg|
|dye:dark_green|maidroid:maidroid_mk8_egg|
|dye:yellow|maidroid:maidroid_mk9_egg|
|dye:orange|maidroid:maidroid_mk10_egg|
|dye:brown|maidroid:maidroid_mk11_egg|
|dye:red|maidroid:maidroid_mk12_egg|
|dye:pink|maidroid:maidroid_mk13_egg|
|dye:magenta|maidroid:maidroid_mk14_egg|
|dye:violet|maidroid:maidroid_mk15_egg|
### Activate Maidroid
After a while, the empty egg will be converted to an new egg.
If you take and use it, a new maidroid will be born.
1. Throw the egg created, then a new maidroid will be spawned.
2. Open formspec by right-clicking the maidroid, and put the core created into `Core` slot.
3. Then, the maidroid will be activated.
The maidroid, however, doesn't move now.
In order to have them move, you have to put a Core that is their brain.
You can create a core in a similar way to a maidroid egg.
First, you have to create an empty core and a core writer.
Those recipe is as follows.
### Recipes / Dye and Egg / Dye and Core
<img src="http://i.imgur.com/Sxnr38Y.png">
<img src="http://i.imgur.com/97VENIl.png">
```
b = dye:black c = default:cobble d = default:diamond
f = farming:cotton o = default:obsidian p = default:paper
s = default:steel_ingot w = bucket:bucket_water z = default:bronze_ingot
After you place a core writer node, rightclick it, and place a empty core to the slot labeled `Core`, a coal to the slot labeled `Fuel`, and a dye to the slot labeled `Dye`.
The correspondences of dyes and cores are as follows.
Core Writer Egg Writer Nametag Empty Core Empty Egg
|Dye|Core|Description|
|:--|:--|:--|
|`dye:red`|`maidroid_core:basic`|Following the player.|
|`dye:yello`|`maidroid_core:farming`|Farming.|
| s | d | s | | d | w | d | | | f | | | s | s | s | | z | z | z |
| c | s | c | | c | s | c | | p | p | p | | s | o | s | | z | s | z |
| c | c | c | | s | c | s | | s | b | s | | s | s | s | | z | z | z |
```
When a new core is created, put it to the maidroid.
Rightclick it, and put the core to the slot labeled `Core`.
The maidroid will start.
<table>
<tr>
<td>White</td><td><img src=http://i.imgur.com/lsdq79e.png> Mk1</td>
<td></td>
<td>Grey</td><td><img src=http://i.imgur.com/9ffUTjB.png> Mk2</td>
<td></td>
<td>Dark Grey</td><td><img src=http://i.imgur.com/HWtLvqb.png> Mk3</td>
</tr>
<tr>
<td>Black</td><td><img src=http://i.imgur.com/GoHRTRC.png> Mk4</td>
<td></td>
<td>Blue</td><td><img src=http://i.imgur.com/JTZTCS9.png> Mk5</td>
<td></td>
<td>Cyan</td><td><img src=http://i.imgur.com/hHw6mbD.png> Mk6</td>
</tr>
<tr>
<td>Green</td><td><img src=http://i.imgur.com/YdzOgvM.png> Mk7</td>
<td></td>
<td>Dark Green</td><td><img src=http://i.imgur.com/UXB52Ce.png> Mk8</td>
<td></td>
<td>Yellow</td><td><img src=http://i.imgur.com/hcd9vk4.png> Mk9</td>
</tr>
<tr>
<td>Orange</td><td><img src=http://i.imgur.com/6UjS63j.png> Mk10</td>
<td></td>
<td>Brown</td><td><img src=http://i.imgur.com/ayz4uP3.png> Mk11</td>
<td></td>
<td>Red</td><td><img src=http://i.imgur.com/rqknHh7.png> Mk12</td>
</tr>
<tr>
<td>Pink</td><td><img src=http://i.imgur.com/UNALjMo.png> MK13</td>
<td></td>
<td>Magenta</td><td><img src=http://i.imgur.com/iorRtmf.png> Mk14</td>
<td></td>
<td>Violet</td><td><img src=http://i.imgur.com/UX3w1Cx.png> Mk15</td>
</tr>
</table>
<table>
<tr>
<td>Red</td><td>Basic Core</td><td>Maidroids embeded this core will follow a player.</td>
</tr>
<tr>
<td>Yellow</td><td>Farming Core</td><td>Maidroids embeded this core will do farming. Embed this core and put seed into them, then they will plant the seeds. And the plant will be grown, they mow it. The farmlang should be surrounded by fences, because maidroids embeded this core cannot jump over fences.</td>
</tr>
<tr>
<td>White</td><td>OCR Core</td><td>Maidroids embeded this core will read a book written a program in their inventory, and execute the program. Program example:
<pre><code>start: sleep 1
beep
jump 0.9
jmp start
</code></pre>
</tr>
<tr>
<td>Orange</td><td>Torcher Core</td><td>Maidroids embeded this core will follow a player, and put torch if it is dark.</td>
</tr>
</table>
## Dependencies
- bucket
- default
- dye
- [pdisc](https://github.com/HybridDog/pdisc)?
## Requirements
- Minetest v0.4.14 or later
## Forum Topic
The forum topic for this mod on the Minetest Forums is located at:
* https://forum.minetest.net/viewtopic.php?f=9&t=14808
- https://forum.minetest.net/viewtopic.php?f=9&t=14808
## License
- The source code of Maidroid is available under the [LGPLv2.1](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt) or later license.
- The resouces included in Maidroid are available under the [CC-BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/) or later license.
## Contributers

View File

@ -61,12 +61,13 @@ end
-- maidroid.maidroid.get_core_name returns a name of a maidroid's current core.
function maidroid.maidroid.get_core_name(self)
return self.core_name
local inv = self:get_inventory()
return inv:get_stack("core", 1):get_name()
end
-- maidroid.maidroid.get_core returns a maidroid's current core definition.
function maidroid.maidroid.get_core(self)
local name = self:get_core_name(self)
local name = self:get_core_name()
if name ~= "" then
return maidroid.registered_cores[name]
end
@ -94,8 +95,8 @@ function maidroid.maidroid.get_nearest_player(self, range_distance)
return player
end
-- maidroid.maidroid.get_front_node returns a node that exists in front of the maidroid.
function maidroid.maidroid.get_front_node(self)
-- maidroid.maidroid.get_front returns a position in front of the maidroid.
function maidroid.maidroid.get_front(self)
local direction = self:get_look_direction()
if math.abs(direction.x) >= 0.5 then
if direction.x > 0 then direction.x = 1 else direction.x = -1 end
@ -109,7 +110,12 @@ function maidroid.maidroid.get_front_node(self)
direction.z = 0
end
local front = vector.add(vector.round(self.object:getpos()), direction)
return vector.add(vector.round(self.object:getpos()), direction)
end
-- maidroid.maidroid.get_front_node returns a node that exists in front of the maidroid.
function maidroid.maidroid.get_front_node(self)
local front = self:get_front()
return minetest.get_node(front)
end
@ -210,6 +216,25 @@ function maidroid.maidroid.change_direction_randomly(self)
self:set_yaw_by_direction(direction)
end
-- maidroid.maidroid.update_infotext updates the infotext of the maidroid.
function maidroid.maidroid.update_infotext(self)
local infotext = ""
local core_name = self:get_core_name()
if core_name ~= "" then
if self.pause then
infotext = infotext .. "this maidroid is paused\n"
else
infotext = infotext .. "this maidroid is active\n"
end
infotext = infotext .. "[Core] : " .. core_name .. "\n"
else
infotext = infotext .. "this maidroid is inactive\n[Core] : None\n"
end
infotext = infotext .. "[Owner] : " .. self.owner_name
self.object:set_properties{infotext = infotext}
end
---------------------------------------------------------------------
-- maidroid.manufacturing_data represents a table that contains manufacturing data.
@ -243,25 +268,13 @@ do
})
local function on_activate(self, staticdata)
-- attach to the nearest maidroid.
local all_objects = minetest.get_objects_inside_radius(self.object:getpos(), 0.1)
for _, obj in ipairs(all_objects) do
local luaentity = obj:get_luaentity()
if maidroid.is_maidroid(luaentity.name) then
self.object:set_attach(obj, "Arm_R", {x = 0.075, y = 0.60, z = -0.20}, {x = 0, y = 90, z = 0})
self.object:set_properties{textures={"maidroid:dummy_empty_craftitem"}}
return
end
end
self.object:set_properties{textures={"maidroid:dummy_empty_craftitem"}}
end
local function on_step(self, dtime)
local all_objects = minetest.get_objects_inside_radius(self.object:getpos(), 0.1)
for _, obj in ipairs(all_objects) do
local luaentity = obj:get_luaentity()
if maidroid.is_maidroid(luaentity.name) then
if self.maidroid_object then
local luaentity = self.maidroid_object:get_luaentity()
if luaentity then
local stack = luaentity:get_wield_item_stack()
if stack:get_name() ~= self.itemname then
@ -276,21 +289,23 @@ do
return
end
end
-- if cannot find maidroid, delete empty item.
self.object:remove()
return
end
minetest.register_entity("maidroid:dummy_item", {
hp_max = 1,
visual = "wielditem",
visual_size = {x = 0.025, y = 0.025},
collisionbox = {0, 0, 0, 0, 0, 0},
physical = false,
textures = {"air"},
on_activate = on_activate,
on_step = on_step,
itemname = "",
hp_max = 1,
visual = "wielditem",
visual_size = {x = 0.025, y = 0.025},
collisionbox = {0, 0, 0, 0, 0, 0},
physical = false,
textures = {"air"},
on_activate = on_activate,
on_step = on_step,
itemname = "",
maidroid_object = nil
})
end
@ -300,7 +315,7 @@ end
function maidroid.register_core(core_name, def)
maidroid.registered_cores[core_name] = def
minetest.register_craftitem(core_name, {
minetest.register_tool(core_name, {
stack_max = 1,
description = def.description,
inventory_image = def.inventory_image,
@ -311,7 +326,7 @@ end
function maidroid.register_egg(egg_name, def)
maidroid.registered_eggs[egg_name] = def
minetest.register_craftitem(egg_name, {
minetest.register_tool(egg_name, {
description = def.description,
inventory_image = def.inventory_image,
stack_max = 1,
@ -323,6 +338,8 @@ function maidroid.register_egg(egg_name, def)
new_maidroid:get_luaentity():set_yaw_by_direction(
vector.subtract(user:getpos(), new_maidroid:getpos())
)
new_maidroid:get_luaentity().owner_name = user:get_player_name()
new_maidroid:get_luaentity():update_infotext()
itemstack:take_item()
return itemstack
@ -341,34 +358,17 @@ function maidroid.register_maidroid(product_name, def)
maidroid.manufacturing_data[product_name] = 0
end
local function update_infotext(self)
if self.core_name ~= "" then
local infotext = ""
if self.pause then
infotext = infotext .. "this maidroid is paused\n"
else
infotext = infotext .. "this maidroid is active\n"
end
infotext = infotext .. "[Core] : " .. self.core_name
self.object:set_properties{infotext = infotext}
return
end
self.object:set_properties{infotext = "this maidroid is inactive"}
end
-- create_inventory creates a new inventory, and returns it.
local function create_inventory(self)
self.inventory_name = self.product_name .. "_" .. tostring(self.manufacturing_number)
self.inventory_name = product_name .. "_" .. tostring(self.manufacturing_number)
local inventory = minetest.create_detached_inventory(self.inventory_name, {
on_put = function(inv, listname, index, stack, player)
if listname == "core" then
local core_name = stack:get_name()
local core = maidroid.registered_cores[core_name]
core.on_start(self)
self.core_name = core_name
update_infotext(self)
self:update_infotext()
end
end,
@ -386,11 +386,11 @@ function maidroid.register_maidroid(product_name, def)
on_take = function(inv, listname, index, stack, player)
if listname == "core" then
local core = maidroid.registered_cores[self.core_name]
self.core_name = ""
local core_name = stack:get_name()
local core = maidroid.registered_cores[core_name]
core.on_stop(self)
update_infotext(self)
self:update_infotext()
end
end,
@ -400,7 +400,37 @@ function maidroid.register_maidroid(product_name, def)
end
return stack:get_count()
end,
on_move = function(inv, from_list, from_index, to_list, to_index, count, player)
if to_list == "core" or from_list == "core" then
local core_name = inv:get_stack(to_list, to_index):get_name()
local core = maidroid.registered_cores[core_name]
if to_list == "core" then
core.on_start(self)
elseif from_list == "core" then
core.on_stop(self)
end
self:update_infotext()
end
end,
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
if to_list == "wield_item" then
return 0
end
if to_list == "main" then
return count
elseif to_list == "core" and maidroid.is_core(inv:get_stack(from_list, from_index):get_name()) then
return count
end
return 0
end,
})
inventory:set_size("main", 16)
inventory:set_size("core", 1)
inventory:set_size("wield_item", 1)
@ -427,53 +457,35 @@ function maidroid.register_maidroid(product_name, def)
local function on_activate(self, staticdata)
-- parse the staticdata, and compose a inventory.
if staticdata == "" then
self.product_name = product_name
self.manufacturing_number = maidroid.manufacturing_data[product_name]
maidroid.manufacturing_data[product_name] = maidroid.manufacturing_data[product_name] + 1
create_inventory(self)
-- attach dummy item to new maidroid.
minetest.add_entity(self.object:getpos(), "maidroid:dummy_item")
else
-- if static data is not empty string, this object has beed already created.
local data = minetest.deserialize(staticdata)
self.product_name = data["product_name"]
self.manufacturing_number = data["manufacturing_number"]
self.nametag = data["nametag"]
self.owner_name = data["owner_name"]
local inventory = create_inventory(self)
local core_name = data["inventory"]["core"]
local items = data["inventory"]["main"]
local wield_item = data["inventory"]["wield_item"]
if core_name ~= "" then -- set a core
local core_stack = ItemStack(core_name)
core_stack:set_count(1)
inventory:add_item("core", core_stack)
self.core_name = core_name
for list_name, list in pairs(data["inventory"]) do
inventory:set_list(list_name, list)
end
for _, item in ipairs(items) do -- set items
local item_stack = ItemStack(item["name"])
item_stack:set_count(item["count"])
inventory:add_item("main", item_stack)
end
if wield_item["name"] ~= "" then
local item_stack = ItemStack(wield_item["name"])
item_stack:set_count(wield_item["count"])
inventory:add_item("wield_item", item_stack)
end
end
update_infotext(self)
self:update_infotext()
self.object:set_nametag_attributes{
text = self.nametag
}
-- attach dummy item to new maidroid.
local dummy_item = minetest.add_entity(self.object:getpos(), "maidroid:dummy_item")
dummy_item:set_attach(self.object, "Arm_R", {x = 0.065, y = 0.50, z = -0.15}, {x = -45, y = 0, z = 0})
dummy_item:get_luaentity().maidroid_object = self.object
local core = self:get_core()
if core ~= nil then
core.on_start(self)
@ -487,33 +499,21 @@ function maidroid.register_maidroid(product_name, def)
local function get_staticdata(self)
local inventory = self:get_inventory()
local data = {
["product_name"] = self.product_name,
["manufacturing_number"] = self.manufacturing_number,
["nametag"] = self.nametag,
["inventory"] = {
["main"] = {},
["core"] = self.core_name,
["wield_item"] = nil,
},
["owner_name"] = self.owner_name,
["inventory"] = {},
}
-- set main list.
for _, item in ipairs(inventory:get_list("main")) do
local count = item:get_count()
local itemname = item:get_name()
if count ~= 0 then
local itemdata = {count = count, name = itemname}
table.insert(data["inventory"]["main"], itemdata)
-- set lists.
for list_name, list in pairs(inventory:get_lists()) do
data["inventory"][list_name] = {}
for i, item in ipairs(list) do
data["inventory"][list_name][i] = item:to_string()
end
end
do -- set wield_item list.
local item = self:get_wield_item_stack()
local count = item:get_count()
local itemname = item:get_name()
local itemdata = {count = count, name = itemname}
data["inventory"]["wield_item"] = itemdata
end
return minetest.serialize(data)
end
@ -542,12 +542,17 @@ function maidroid.register_maidroid(product_name, def)
-- on_step is a callback function that is called every delta times.
local function on_step(self, dtime)
-- if owner didn't login, the maidroid does nothing.
if not minetest.get_player_by_name(self.owner_name) then
return
end
-- pickup surrounding item.
pickup_item(self)
-- do core method.
if (not self.pause) and self.core_name ~= "" then
local core = maidroid.registered_cores[self.core_name]
local core = self:get_core()
if (not self.pause) and core then
core.on_step(self, dtime)
end
end
@ -563,21 +568,20 @@ function maidroid.register_maidroid(product_name, def)
-- on_punch is a callback function that is called when a player punch then.
local function on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir)
local core = self:get_core()
if self.pause == true then
self.pause = false
if self.core_name ~= "" then
local core = maidroid.registered_cores[self.core_name]
if core then
core.on_resume(self)
end
else
self.pause = true
if self.core_name ~= "" then
local core = maidroid.registered_cores[self.core_name]
if core then
core.on_pause(self)
end
end
update_infotext(self)
self:update_infotext()
end
-- register a definition of a new maidroid.
@ -599,9 +603,8 @@ function maidroid.register_maidroid(product_name, def)
-- extra initial properties
pause = false,
product_name = "",
manufacturing_number = -1,
core_name = "",
owner_name = "",
-- callback methods.
on_activate = on_activate,
@ -615,6 +618,7 @@ function maidroid.register_maidroid(product_name, def)
get_core = maidroid.maidroid.get_core,
get_core_name = maidroid.maidroid.get_core_name,
get_nearest_player = maidroid.maidroid.get_nearest_player,
get_front = maidroid.maidroid.get_front,
get_front_node = maidroid.maidroid.get_front_node,
get_look_direction = maidroid.maidroid.get_look_direction,
set_animation = maidroid.maidroid.set_animation,
@ -627,6 +631,7 @@ function maidroid.register_maidroid(product_name, def)
has_item_in_main = maidroid.maidroid.has_item_in_main,
change_direction = maidroid.maidroid.change_direction,
change_direction_randomly = maidroid.maidroid.change_direction_randomly,
update_infotext = maidroid.maidroid.update_infotext,
})
-- register maidroid egg.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 670 B

View File

@ -1,30 +0,0 @@
#/bin/bash
declare -a arr=()
arr[1]='gray92'
arr[2]='gray68'
arr[3]='gray36'
arr[4]='gray17'
arr[5]='blue'
arr[6]='cyan'
arr[7]='green'
arr[8]='DarkGreen'
arr[9]='yellow'
arr[10]='orange'
arr[11]='brown'
arr[12]='red'
arr[13]='pink'
arr[14]='magenta'
arr[15]='violet'
for ((i=1; i<16; i++)); do
type=$(($i % 3 + 1))
maidroid_type="maidroid_type${type}.png"
output="../maidroid_maidroid_mk${i}.png"
color=${arr[i]}
convert +level-colors $color,White maidroid_hair.png maidroid_hair_tmp.png
composite maidroid_hair_tmp.png $maidroid_type $output
rm maidroid_hair_tmp.png
done

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1008 B

Binary file not shown.

View File

@ -1,5 +1,3 @@
#/bin/bash
declare -a arr=()
arr[1]='gray92'
arr[2]='gray68'
@ -16,12 +14,3 @@ arr[12]='red'
arr[13]='pink'
arr[14]='magenta'
arr[15]='violet'
for ((i=1; i<16; i++)); do
output="../maidroid_maidroid_mk${i}_egg.png"
color=${arr[i]}
convert +level-colors $color,White egg_pattern.png egg_pattern_tmp.png
composite egg_pattern_tmp.png egg.png $output
rm egg_pattern_tmp.png
done

View File

@ -0,0 +1,12 @@
#/bin/bash
. ./colors.sh
for ((i=1; i<16; i++)); do
output="../textures/maidroid_maidroid_mk${i}_egg.png"
color=${arr[i]}
convert +level-colors $color,White img/maidroid_egg_pattern.png img/maidroid_egg_pattern_tmp.png
composite img/maidroid_egg_pattern_tmp.png img/maidroid_empty_egg.png $output
rm img/maidroid_egg_pattern_tmp.png
done

View File

@ -0,0 +1,15 @@
#/bin/bash
. ./colors.sh
for ((i=1; i<16; i++)); do
type=$(($i % 3 + 1))
maidroid_type="img/maidroid_type${type}.png"
output="../models/maidroid_maidroid_mk${i}.png"
color=${arr[i]}
convert +level-colors $color,White img/maidroid_hair.png img/maidroid_hair_tmp.png
composite img/maidroid_hair_tmp.png $maidroid_type $output
rm img/maidroid_hair_tmp.png
done

View File

Before

Width:  |  Height:  |  Size: 334 B

After

Width:  |  Height:  |  Size: 334 B

View File

Before

Width:  |  Height:  |  Size: 337 B

After

Width:  |  Height:  |  Size: 337 B

View File

Before

Width:  |  Height:  |  Size: 668 B

After

Width:  |  Height:  |  Size: 668 B

View File

Before

Width:  |  Height:  |  Size: 1015 B

After

Width:  |  Height:  |  Size: 1015 B

View File

Before

Width:  |  Height:  |  Size: 1008 B

After

Width:  |  Height:  |  Size: 1008 B

View File

Before

Width:  |  Height:  |  Size: 963 B

After

Width:  |  Height:  |  Size: 963 B

View File

@ -0,0 +1,23 @@
-- See also the pdisc mod's instruction list.
local instr = {
{"getpos", "<v x>, <v y>, <v z>", "Gets the maidroid's position."},
{"getvelocity", "<v x>, <v y>, <v z>", "Gets the maidroid's velocity."},
{"getacceleration", "<v x>, <v y>, <v z>", "Gets the maidroid's acceleration."},
{"getyaw", "<v yaw>", "Gets the maidroid's yaw."},
{"setyaw", "<n yaw>", "Sets the maidroid's yaw in radians."},
{"jump", "[<n heigth>]", "Makes the droid jump, if height is invalid (height ∈ ]0,2]), it's set to 1, if it's a variable, it's set to a bool indicating whether the jump succeeded."},
{"beep", "", "Execute this every second while the droid walks backwards, pls."},
}
o = "Instructions:\n\n"
for i = 1,#instr do
i = instr[i]
o = o .. i[1] .. " " .. i[2] .. "\n"
.. " " .. i[3] .. "\n\n" -- TODO: max 80 letters each line
end
print(o)

Binary file not shown.

View File

@ -14,6 +14,7 @@ end
local function on_stop(self)
self.state = nil
self.object:setvelocity{x = 0, y = 0, z = 0}
self:set_animation(maidroid.animation_frames.STAND)
end
local function on_step(self, dtime)

View File

@ -28,7 +28,7 @@ local function is_plantable_place(pos)
local lpos = vector.add(pos, {x = 0, y = -1, z = 0})
local lnode = minetest.get_node(lpos)
return node.name == "air"
and minetest.get_item_group(lnode.name, "wet") > 0
and minetest.get_item_group(lnode.name, "soil") > 1
end
-- is_mowable_place reports whether maidroid can mow.
@ -241,7 +241,14 @@ plant = function(self, dtime)
if is_plantable_place(self.destination) then
local stack = self:get_wield_item_stack()
local itemname = stack:get_name()
minetest.add_node(self.destination, {name = itemname, param2 = 1})
local pointed_thing = {
type = "node",
under = vector.add(self.destination, {x = 0, y = -1, z = 0}),
above = self.destination,
}
farming.place_seed(stack, minetest.get_player_by_name(self.owner_name), pointed_thing, stack:get_name())
stack:take_item(1)
self:set_wield_item_stack(stack)
end

166
maidroid_core/cores/ocr.lua Normal file
View File

@ -0,0 +1,166 @@
------------------------------------------------------------
-- Copyright (c) 2016 tacigar. All rights reserved.
-- https://github.com/tacigar/maidroid
------------------------------------------------------------
local maidroid_instruction_set = {
-- popular (similars in lua_api) information gathering functions
getpos = function(_, thread)
local pos = thread.droid.object:getpos()
return true, {pos.x, pos.y, pos.z}
end,
getvelocity = function()
local vel = self.vel
return true, {vel.x, vel.y, vel.z}
end,
getacceleration = function(_, thread)
local acc = thread.droid.object:getacceleration()
return true, {acc.x, acc.y, acc.z}
end,
getyaw = function(_, thread)
return true, thread.droid.object:getyaw()
end,
-- other info functions
-- popular actions for changing sth
setyaw = function(params, thread)
if #params ~= 1 then
return false, "wrong number of arguments"
end
local p = params[1]
if type(p) ~= "number" then
return false, "unsupported argument"
end
thread.droid.object:setyaw(p)
return true
end,
-- other actions
jump = function(params, thread)
-- test if it can jump
local droid = thread.droid
if droid.vel.y ~= 0
or droid.vel_prev.y ~= 0 then
return true, false
end
-- get the strength of the jump
local h = tonumber(params[1])
if not h
or h <= 0
or h > 2 then
h = 1
end
-- play sound
local p = droid.object:getpos()
p.y = p.y - 1
local node_under = minetest.get_node(p).name
local def = minetest.registered_nodes[node_under]
if def
and def.sounds then
local snd = def.sounds.footstep or def.sounds.dig
if snd then
p.y = p.y + .5
minetest.sound_play(snd.name, {pos = p, gain = snd.gain})
end
end
-- perform jump
droid.vel.y = math.sqrt(-2 * h * droid.object:getacceleration().y)
droid.object:setvelocity(droid.vel)
return true, true
end,
beep = function(_, thread)
minetest.sound_play("maidroid_beep", {pos = thread.droid.object:getpos()})
return true
end,
}
local function mylog(log)
-- This happens to the maidroids messages
minetest.chat_send_all("maidroid says " .. log)
end
-- the program is loaded from a "default:book_written" with title "main"
-- if it's not present, following program is used in lieu:
local dummycode = [[
beep
print $No book with title "main" found.
]]
local function get_code(self)
local list = self:get_inventory():get_list"main"
for i = 1,#list do
local stack = list[i]
if stack:get_name() == "default:book_written" then
local data = minetest.deserialize(stack:get_metadata())
if data
and data.title == "main" then
return data.text
end
end
end
end
local function on_start(self)
self.object:setacceleration{x = 0, y = -10, z = 0}
self.object:setvelocity{x = 0, y = 0, z = 0}
self.vel = {x = 0, y = 0, z = 0}
self.vel_prev = self.vel
local parsed_code = pdisc.parse(get_code(self) or dummycode)
self.thread = pdisc.create_thread(function(thread)
thread.flush = function(self)
mylog(self.log)
self.log = ""
return true
end
table.insert(thread.is, 1, maidroid_instruction_set)
thread.droid = self
end, parsed_code)
self.thread:suscitate()
end
local function on_step(self)
local thread = self.thread
if not thread.stopped then
return
end
self.vel_prev = self.vel
self.vel = self.object:getvelocity()
thread:try_rebirth()
end
local function on_resume(self)
self.thread:continue()
end
local function on_pause(self)
self.thread:flush()
end
local function on_stop(self)
self.thread:exit()
self.thread = nil
self.object:setvelocity{x = 0, y = 0, z = 0}
end
-- register a definition of a new core.
maidroid.register_core("maidroid_core:ocr", {
description = "OCR programmable maidroid core",
inventory_image = "maidroid_core_ocr.png",
on_start = on_start,
on_stop = on_stop,
on_resume = on_resume,
on_pause = on_pause,
on_step = on_step,
})

View File

@ -0,0 +1,136 @@
------------------------------------------------------------
-- Copyright (c) 2016 tacigar. All rights reserved.
-- https://github.com/tacigar/maidroid
------------------------------------------------------------
local state = {IDLE = 0, ACCOMPANY = 1}
local PLACE_TIME = 4
local function on_start(self)
self.state = state.IDLE
self.object:setacceleration{x = 0, y = -10, z = 0}
self.object:setvelocity{x = 0, y = 0, z = 0}
self.time_counter = -1
self.is_placing = false
end
local function on_stop(self)
self.state = nil
self.object:setvelocity{x = 0, y = 0, z = 0}
self:set_animation(maidroid.animation_frames.STAND)
self.time_counter = nil
self.is_placing = nil
end
local function is_dark(pos)
local light_level = minetest.get_node_light(pos)
return light_level <= 5
end
local function on_step(self, dtime)
if self.is_placing then
if self.time_counter >= PLACE_TIME then
self.time_counter = -1
if self.state == state.IDLE then
self:set_animation(maidroid.animation_frames.STAND)
elseif self.state == state.ACCOMPANY then
self:set_animation(maidroid.animation_frames.WALK)
end
local owner = minetest.get_player_by_name(self.owner_name)
local wield_stack = self:get_wield_item_stack()
local front = self:get_front()
local pointed_thing = {
type = "node",
under = vector.add(front, {x = 0, y = -1, z = 0}),
above = front,
}
if wield_stack:get_name() == "default:torch" then
local res_stack, success = minetest.item_place_node(wield_stack, owner, pointed_thing)
if success then
res_stack:take_item(1)
self:set_wield_item_stack(res_stack)
end
end
self.is_placing = false
else
self.time_counter = self.time_counter + 1
end
end
local player = self:get_nearest_player(10)
if player == nil then
self:set_animation(maidroid.animation_frames.STAND)
return
end
local position = self.object:getpos()
local player_position = player:getpos()
local direction = vector.subtract(player_position, position)
local velocity = self.object:getvelocity()
if vector.length(direction) < 3 then
if self.state == state.ACCOMPANY then
self:set_animation(maidroid.animation_frames.STAND)
self.state = state.IDLE
self.object:setvelocity{x = 0, y = velocity.y, z = 0}
end
if not self.is_placing then
local front = self:get_front() -- if it is dark, set touch.
local wield_stack = self:get_wield_item_stack()
if is_dark(front)
and (wield_stack:get_name() == "default:torch"
or self:move_main_to_wield(function (itemname) return itemname == "default:torch" end)) then
self.time_counter = 0
self.is_placing = true
self:set_animation(maidroid.animation_frames.MINE)
end
end
else
if self.state == state.IDLE then
self:set_animation(maidroid.animation_frames.WALK)
self.state = state.ACCOMPANY
end
self.object:setvelocity{x = direction.x, y = velocity.y, z = direction.z} -- TODO
if not self.is_placing then
local front = self:get_front() -- if it is dark, set touch.
local wield_stack = self:get_wield_item_stack()
if is_dark(front)
and (wield_stack:get_name() == "default:torch"
or self:move_main_to_wield(function (itemname) return itemname == "default:torch" end)) then
self.time_counter = 0
self.is_placing = true
self:set_animation(maidroid.animation_frames.WALK_MINE)
end
end
end
self:set_yaw_by_direction(direction)
-- if maidroid is stoped by obstacle, the maidroid must jump.
if velocity.y == 0 and self.state == state.ACCOMPANY then
local front_node = self:get_front_node()
if front_node.name ~= "air" and minetest.registered_nodes[front_node.name] ~= nil
and minetest.registered_nodes[front_node.name].walkable then
self.object:setvelocity{x = direction.x, y = 5, z = direction.z}
end
end
end
-- register a definition of a new core.
maidroid.register_core("maidroid_core:torcher", {
description = "maidroid core : torcher",
inventory_image = "maidroid_core_torcher.png",
on_start = on_start,
on_stop = on_stop,
on_resume = on_start,
on_pause = on_stop,
on_step = on_step,
})

View File

@ -1 +1,2 @@
maidroid
pdisc?

View File

@ -12,3 +12,7 @@ dofile(maidroid_core.modpath .. "/cores/_aux.lua")
dofile(maidroid_core.modpath .. "/cores/empty.lua")
dofile(maidroid_core.modpath .. "/cores/basic.lua")
dofile(maidroid_core.modpath .. "/cores/farming.lua")
dofile(maidroid_core.modpath .. "/cores/torcher.lua")
if minetest.global_exists("pdisc") then
dofile(maidroid_core.modpath .. "/cores/ocr.lua")
end

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 559 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 B

Binary file not shown.

Binary file not shown.

View File

@ -3,9 +3,11 @@
-- https://github.com/tacigar/maidroid
------------------------------------------------------------
maidroid_tool._aux = {}
-- maidroid_tool.shared.generate_writer is a shared
-- function called for registering egg writer and core writer.
function maidroid_tool.register_writer(nodename, options)
function maidroid_tool._aux.register_writer(nodename, options)
local description = options.description
local formspec = options.formspec
local tiles = options.tiles
@ -16,12 +18,11 @@ function maidroid_tool.register_writer(nodename, options)
local on_deactivate = options.on_deactivate
local empty_itemname = options.empty_itemname
local dye_item_map = options.dye_item_map
local is_mainitem = options.is_mainitem
local on_metadata_inventory_put_to_main = options.on_metadata_inventory_put_to_main
local on_metadata_inventory_take_from_main = options.on_metadata_inventory_take_from_main
-- can_dig is a common callback.
local function can_dig(pos, player)
local function can_dig(pos)
local meta = minetest.get_meta(pos)
local inventory = meta:get_inventory()
return (
@ -52,7 +53,7 @@ function maidroid_tool.register_writer(nodename, options)
-- if time is positive, this node is active.
if time >= 0 then
if time <= duration then
meta:set_float("time", time + 1)
meta:set_float("time", time + elapsed)
meta:set_string("formspec", formspec.active(time))
else
meta:set_float("time", -1)
@ -94,9 +95,7 @@ function maidroid_tool.register_writer(nodename, options)
end
-- allow_metadata_inventory_put is a common callback.
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
local inventory = meta:get_inventory()
local function allow_metadata_inventory_put(_, listname, _, stack)
local itemname = stack:get_name()
if (listname == "fuel" and itemname == "default:coal_lump") then
@ -110,7 +109,7 @@ function maidroid_tool.register_writer(nodename, options)
end
-- allow_metadata_inventory_move is a common callback for the node.
local function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
local function allow_metadata_inventory_move(pos, from_list, from_index, _, to_index, _, player)
local meta = minetest.get_meta(pos)
local inventory = meta:get_inventory()
local stack = inventory:get_stack(from_list, from_index)
@ -130,11 +129,10 @@ function maidroid_tool.register_writer(nodename, options)
inventory:set_size("dye", 1)
end
local function on_metadata_inventory_put(pos, listname, index, stack, player)
local function on_metadata_inventory_put(pos, listname)
local timer = minetest.get_node_timer(pos)
timer:start(0.25)
local meta = minetest.get_meta(pos)
if listname == "main" then
if on_metadata_inventory_put_to_main ~= nil then
on_metadata_inventory_put_to_main(pos) -- call on_metadata_inventory_put_to_main callback.
@ -142,15 +140,16 @@ function maidroid_tool.register_writer(nodename, options)
end
end
local function on_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
local function on_metadata_inventory_move(pos, from_list, from_index, _, to_index, _, player)
local meta = minetest.get_meta(pos)
local inventory = meta:get_inventory()
local stack = inventory:get_stack(from_list, from_index)
-- listname is not set here, is it? ~Hybrid Dog
on_metadata_inventory_put(pos, listname, to_index, stack, player)
end
local function on_metadata_inventory_take(pos, listname, index, stack, player)
local function on_metadata_inventory_take(pos, listname)
if listname == "main" then
if on_metadata_inventory_take_from_main ~= nil then
on_metadata_inventory_take_from_main(pos) -- call on_metadata_inventory_take_from_main callback.
@ -158,7 +157,7 @@ function maidroid_tool.register_writer(nodename, options)
end
end
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
local function allow_metadata_inventory_take(_, _, _, stack)
return stack:get_count() -- maybe add more.
end
@ -187,7 +186,7 @@ function maidroid_tool.register_writer(nodename, options)
end -- end register inactive node.
do -- register a definition of an active node.
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
local function allow_metadata_inventory_take(_, listname, _, stack)
if listname == "main" then
return 0
end

View File

@ -0,0 +1,132 @@
local rod_uses = 100
minetest.register_tool("maidroid_tool:capture_rod", {
description = "maidroid tool : capture rod",
inventory_image = "maidroid_tool_capture_rod.png",
on_use = function(itemstack, user, pointed_thing)
if (pointed_thing.type ~= "object") then
return
end
local obj = pointed_thing.ref
local luaentity = obj:get_luaentity()
if not maidroid.is_maidroid(luaentity.name) then
if luaentity.name == "__builtin:item" then
luaentity:on_punch(user)
end
return
end
local drop_pos = vector.add(obj:getpos(), {x = 0, y = 1, z = 0})
local maidroid_name = string.split(luaentity.name, ":")[2]
local stack = ItemStack("maidroid_tool:captured_" .. maidroid_name .. "_egg")
stack:set_metadata(luaentity:get_staticdata())
obj:remove()
minetest.add_item(drop_pos, stack)
itemstack:add_wear(65535 / (rod_uses - 1))
minetest.sound_play("maidroid_tool_capture_rod_use", {pos = drop_pos})
minetest.add_particlespawner({
amount = 20,
time = 0.2,
minpos = drop_pos,
maxpos = drop_pos,
minvel = {x = -1.5, y = 2, z = -1.5},
maxvel = {x = 1.5, y = 4, z = 1.5},
minacc = {x = 0, y = -8, z = 0},
maxacc = {x = 0, y = -4, z = 0},
minexptime = 1,
maxexptime = 1.5,
minsize = 1,
maxsize = 2.5,
collisiondetection = true,
vertical = false,
texture = "maidroid_tool_capture_rod_star.png",
player = user
})
return itemstack
end
})
for name, _ in pairs(maidroid.registered_maidroids) do
local maidroid_name = string.split(name, ":")[2]
local egg_def = maidroid.registered_eggs[name .. "_egg"]
local inv_img = "maidroid_tool_capture_rod_plate.png^" .. egg_def.inventory_image
minetest.register_tool("maidroid_tool:captured_" .. maidroid_name .. "_egg", {
description = "maidroid tool : captured " .. egg_def.description,
inventory_image = inv_img,
groups = {not_in_creative_inventory = 1},
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then
if pointed_thing.type == "object" then
local luaentity = pointed_thing.ref:get_luaentity()
if luaentity.name == "__builtin:item" then
luaentity:on_punch(user)
end
end
return
end
local meta = itemstack:get_metadata()
local obj = minetest.add_entity(pointed_thing.above, name)
local luaentity = obj:get_luaentity()
luaentity:set_yaw_by_direction(vector.subtract(user:getpos(), obj:getpos()))
luaentity:on_activate(meta)
-- FIXME: this is workaround
maidroid.manufacturing_data[name] = maidroid.manufacturing_data[name] - 1
local pos = vector.add(obj:getpos(), {x = 0, y = -0.2, z = 0})
minetest.sound_play("maidroid_tool_capture_rod_open_egg", {pos = pos})
minetest.add_particlespawner({
amount = 30,
time = 0.1,
minpos = pos,
maxpos = pos,
minvel = {x = -2, y = 1.0, z = -2},
maxvel = {x = 2, y = 2.5, z = 2},
minacc = {x = 0, y = -5, z = 0},
maxacc = {x = 0, y = -2, z = 0},
minexptime = 0.5,
maxexptime = 1,
minsize = 0.5,
maxsize = 2,
collisiondetection = false,
vertical = false,
texture = "maidroid_tool_capture_rod_star.png^[colorize:#ff8000:127",
player = user
})
local rad = user:get_look_horizontal()
minetest.add_particle({
pos = pos,
velocity = {x = math.cos(rad) * 2, y = 1.5, z = math.sin(rad) * 2},
acceleration = {x = 0, y = -3, z = 0},
expirationtime = 1.5,
size = 6,
collisiondetection = false,
vertical = false,
texture = "(" .. inv_img .. "^[resize:32x32)^[mask:maidroid_tool_capture_rod_mask_right.png",
player = user
})
minetest.add_particle({
pos = pos,
velocity = {x = math.cos(rad) * -2, y = 1.5, z = math.sin(rad) * -2},
acceleration = { x = 0, y = -3, z = 0},
expirationtime = 1.5,
size = 6,
collisiondetection = false,
vertical = false,
texture = "(" .. inv_img .. "^[resize:32x32)^[mask:maidroid_tool_capture_rod_mask_left.png",
player = user
})
itemstack:take_item()
return itemstack
end,
})
end

View File

@ -8,6 +8,8 @@ do -- register core writer
local dye_item_map = {
["dye:red"] = "maidroid_core:basic",
["dye:yellow"] = "maidroid_core:farming",
["dye:white"] = "maidroid_core:ocr",
["dye:orange"] = "maidroid_core:torcher"
}
local node_box = {
@ -148,7 +150,7 @@ do -- register core writer
core_entity.object:remove()
end
maidroid_tool.register_writer("maidroid_tool:core_writer", {
maidroid_tool._aux.register_writer("maidroid_tool:core_writer", {
description = "maidroid tool : core writer",
formspec = formspec,
tiles = tiles,

View File

@ -29,3 +29,13 @@ minetest.register_craft{
{"default:steel_ingot", "dye:black", "default:steel_ingot"},
},
}
minetest.register_craft{
output = "maidroid_tool:capture_rod",
recipe = {
{ "wool:white", "dye:pink", "default:mese_crystal"},
{ "", "default:steel_ingot", "dye:pink"},
{"default:steel_ingot", "", "wool:white"},
},
}

View File

@ -1,5 +1,6 @@
bucket
default
dye
wool
maidroid
maidroid_core

View File

@ -162,10 +162,12 @@ do -- register egg writer
local function on_metadata_inventory_take_from_main(pos)
local egg_entity = get_nearest_egg_entity(pos)
egg_entity.object:remove()
if egg_entity then
egg_entity.object:remove()
end
end
maidroid_tool.register_writer("maidroid_tool:egg_writer", {
maidroid_tool._aux.register_writer("maidroid_tool:egg_writer", {
description = "maidroid tool : egg writer",
formspec = formspec,
tiles = tiles,

View File

@ -8,8 +8,9 @@ maidroid_tool = {}
maidroid_tool.modname = "maidroid_tool"
maidroid_tool.modpath = minetest.get_modpath(maidroid_tool.modname)
dofile(maidroid_tool.modpath .. "/api.lua")
dofile(maidroid_tool.modpath .. "/_aux.lua")
dofile(maidroid_tool.modpath .. "/core_writer.lua")
dofile(maidroid_tool.modpath .. "/egg_writer.lua")
dofile(maidroid_tool.modpath .. "/crafting.lua")
dofile(maidroid_tool.modpath .. "/nametag.lua")
dofile(maidroid_tool.modpath .. "/capture_rod.lua")

View File

@ -8,7 +8,7 @@ local formspec = "size[4,1.25]"
.. default.gui_bg_img
.. default.gui_slots
.. "button_exit[3,0.25;1,0.875;apply_name;Apply]"
.. "field[0.5,0.5;2.75,1;name;name;]"
.. "field[0.5,0.5;2.75,1;name;name;%s]"
local maidroid_buf = {} -- for buffer of target maidroids.
@ -28,14 +28,15 @@ minetest.register_craftitem("maidroid_tool:nametag", {
if not obj:is_player() and luaentity then
local name = luaentity.name
if maidroid.registered_maidroids[name] and not luaentity:is_named() then
if maidroid.is_maidroid(name) then
local player_name = user:get_player_name()
local nametag = luaentity.nametag or ""
minetest.show_formspec(player_name, "maidroid_tool:nametag", formspec)
maidroid_buf[player_name] = luaentity
itemstack:take_item()
return itemstack
minetest.show_formspec(player_name, "maidroid_tool:nametag", formspec:format(nametag))
maidroid_buf[player_name] = {
object = obj,
itemstack = itemstack
}
end
end
return nil
@ -47,12 +48,21 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
return
end
local player_name = player:get_player_name()
if fields.name then
local luaentity = maidroid_buf[player:get_player_name()]
luaentity.nametag = fields.name
local luaentity = maidroid_buf[player_name].object:get_luaentity()
if luaentity then
luaentity.nametag = fields.name
luaentity.object:set_nametag_attributes{
text = fields.name,
}
luaentity.object:set_properties{
nametag = fields.name,
}
local itemstack = maidroid_buf[player_name].itemstack
itemstack:take_item()
player:set_wielded_item(itemstack)
end
end
maidroid_buf[player_name] = nil
end)

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

Binary file not shown.

Binary file not shown.

Binary file not shown.