dcl-npc-toolkit 1.1.3 → 1.1.4-20230619185824.commit-afe7da0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +72 -18
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -69,12 +69,55 @@ The dialog messages can also require that the player chooses options, and any ac
69
69
 
70
70
 
71
71
 
72
- To use NPCs in your scene:
72
+ ## Install the library
73
73
 
74
-
74
+ ## Via the Decentraland Editor
75
75
 
76
-
76
+ Follow the steps in [Manage Dependencies](https://docs.decentraland.org/creator/development-guide/sdk7/libraries/manage-dependencies/#via-the-editor) with Visual Studio Code open on your project folder.
77
+
78
+ 1. Open the Decentraland Editor tab. Note that the bottom section lists all of your project’s currently installed dependencies.
79
+
80
+ 2. Click the + icon on the header of the Dependencies view.
81
+
82
+ 3. Visual Studio opens an input box at the top of the screen. Write ´dcl-npc-toolkit´ and press Enter.
83
+
84
+ 4. Import the library into the scene's script. Add this line at the start of your `index.ts` file, or any other TypeScript files that require it:
85
+
86
+ ```ts
87
+ import * as npc from 'dcl-npc-toolkit'
88
+ ```
89
+ 5. In your TypeScript file, call the `create` function passing it a `TransformType` and a `NPCData` object. The `NPCData` object requires a minimum of a `NPCType` and a function to trigger when the NPC is activated:
90
+
91
+
92
+ ```ts
93
+ export function main(){
94
+ export let myNPC = npc.create(
95
+ {position: Vector3.create(8,0,8),rotation:Quaternion.Zero(), scale: Vector3.create(1,1,1)},
96
+ //NPC Data Object
97
+ {
98
+ type: npc.NPCType.CUSTOM,
99
+ model: 'models/npc.glb',
100
+ onActivate:()=>{console.log('npc activated');}
101
+ }
102
+ )
103
+ }
104
+ ```
105
+
106
+ 6. Write a dialog script for your character, preferably on a separate file, making it of type `Dialog[]`.
107
+
108
+
109
+ ```ts
110
+ import { Dialog } from 'dcl-npc-toolkit'
77
111
 
112
+ export let ILoveCats: Dialog[] = [
113
+ {
114
+ text: `I really lo-ove cats`,
115
+ isEndOfDialog: true
116
+ }
117
+ ]
118
+ ```
119
+
120
+ ## Via the CLI
78
121
 
79
122
 
80
123
  1. Install the library as an npm bundle. Run this command in your scene's project folder:
@@ -86,7 +129,7 @@ To use NPCs in your scene:
86
129
 
87
130
 
88
131
  ```ts
89
- npm i dcl-npc-toolkit -B
132
+ npm i dcl-npc-toolkit
90
133
  ```
91
134
 
92
135
 
@@ -117,7 +160,7 @@ npm i @dcl-sdk/utils -B
117
160
 
118
161
 
119
162
 
120
- 4. Import the library into the scene's script. Add this line at the start of your `game.ts` file, or any other TypeScript files that require it:
163
+ 4. Import the library into the scene's script. Add this line at the start of your `index.ts` file, or any other TypeScript files that require it:
121
164
 
122
165
 
123
166
 
@@ -144,14 +187,14 @@ import * as npc from 'dcl-npc-toolkit'
144
187
 
145
188
 
146
189
  ```ts
147
- export let myNPC = npc.create({position: Vector3.create(8,0,8),rotation:Quaternion.Zero(), scale: Vector3.create(1,1,1)},
148
-
149
- //NPC Data Object
150
- {
151
- type: npc.NPCType.CUSTOM,
152
- model: 'models/npc.glb',
153
- onActivate:()=>{console.log('npc activated');}
154
- }
190
+ export let myNPC = npc.create(
191
+ {position: Vector3.create(8,0,8),rotation:Quaternion.Zero(), scale: Vector3.create(1,1,1)},
192
+ //NPC Data Object
193
+ {
194
+ type: npc.NPCType.CUSTOM,
195
+ model: 'models/npc.glb',
196
+ onActivate:()=>{console.log('npc activated');}
197
+ }
155
198
  )
156
199
  ```
157
200
 
@@ -161,7 +204,7 @@ onActivate:()=>{console.log('npc activated');}
161
204
 
162
205
 
163
206
 
164
- 5. Write a dialog script for your character, preferably on a separate file, making it of type `Dialog[]`.
207
+ 6. Write a dialog script for your character, preferably on a separate file, making it of type `Dialog[]`.
165
208
 
166
209
 
167
210
 
@@ -171,10 +214,11 @@ onActivate:()=>{console.log('npc activated');}
171
214
 
172
215
  ```ts
173
216
  import { Dialog } from 'dcl-npc-toolkit'
217
+
174
218
  export let ILoveCats: Dialog[] = [
175
219
  {
176
- text: `I really lo-ove cats`,
177
- isEndOfDialog: true
220
+ text: `I really lo-ove cats`,
221
+ isEndOfDialog: true
178
222
  }
179
223
  ]
180
224
  ```
@@ -347,7 +391,17 @@ export function setupUi() {
347
391
 
348
392
  ```
349
393
 
350
-
394
+
395
+ Note: The UI drawn by this library library requires fetching images from an external URL. For the scene to allow you to do this, you must include the `ALLOW_MEDIA_HOSTNAMES` scene permission and add `decentraland.org` to the list of allowed domains in your `scene.json` file. Learn more about [image permissions](https://docs.decentraland.org/creator/development-guide/sdk7/materials/#textures-from-an-external-url).
396
+
397
+ ```json
398
+ "requiredPermissions": [
399
+ "ALLOW_MEDIA_HOSTNAMES"
400
+ ],
401
+ "allowedMediaHostnames": [
402
+ "decentraland.org"
403
+ ],
404
+ ```
351
405
 
352
406
 
353
407
 
@@ -1902,4 +1956,4 @@ If you break the API of the library, you need to do a major release, and that's
1902
1956
 
1903
1957
  ```
1904
1958
  commit -m "feat: changed the signature of a method" -m "BREAKING CHANGE: this commit breaks the API, changing foo(arg1) to foo(arg1, arg2)"
1905
- ```
1959
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dcl-npc-toolkit",
3
- "version": "1.1.3",
3
+ "version": "1.1.4-20230619185824.commit-afe7da0",
4
4
  "description": "A collection of tools for creating Non-Player-Characters (NPCs). These are capable of having conversations with the player, and play different animations.",
5
5
  "main": "./dist/index.js",
6
6
  "typings": "./dist/index.d.ts",
@@ -33,5 +33,5 @@
33
33
  "files": [
34
34
  "dist"
35
35
  ],
36
- "commit": "7dc61dbb66055f3a5d3bc15e0dc7755370ddf1c9"
36
+ "commit": "afe7da07703b17934a97e4754867c1fb961ff12c"
37
37
  }