第21行: |
第21行: |
| public Object(int parentSheetIndex, int initialStack, bool isRecipe = false, int price = -1, int quality = 0); | | public Object(int parentSheetIndex, int initialStack, bool isRecipe = false, int price = -1, int quality = 0); |
| public Object(Vector2 tileLocation, int parentSheetIndex, string Givenname, bool canBeSetDown, bool canBeGrabbed, bool isHoedirt, bool isSpawnedObject); | | public Object(Vector2 tileLocation, int parentSheetIndex, string Givenname, bool canBeSetDown, bool canBeGrabbed, bool isHoedirt, bool isSpawnedObject); |
− | </syntaxhightlight> | + | </syntaxhighlight> |
| | | |
| '''parentSheetIndex'''为该物品的ID(储存在 ObjectInformation.xnb 文件中)。 | | '''parentSheetIndex'''为该物品的ID(储存在 ObjectInformation.xnb 文件中)。 |
第31行: |
第31行: |
| // 调用: | | // 调用: |
| Game1.getLocationFromName("Farm").dropObject(new StardewValley.Object(itemId, 1, false, -1, 0), new Vector2(x, y) * 64f, Game1.viewport, true, (Farmer)null); | | Game1.getLocationFromName("Farm").dropObject(new StardewValley.Object(itemId, 1, false, -1, 0), new Vector2(x, y) * 64f, Game1.viewport, true, (Farmer)null); |
− | </syntaxhightlight> | + | </syntaxhighlight> |
| | | |
| ===添加物品到背包=== | | ===添加物品到背包=== |
第37行: |
第37行: |
| // You can add items found in ObjectInformation using: | | // You can add items found in ObjectInformation using: |
| Game1.player.addItemByMenuIfNecessary((Item)new StardewValley.Object(int parentSheetIndex, int initialStack, [bool isRecipe = false], [int price = -1], [int quality = 0])); | | Game1.player.addItemByMenuIfNecessary((Item)new StardewValley.Object(int parentSheetIndex, int initialStack, [bool isRecipe = false], [int price = -1], [int quality = 0])); |
− | </syntaxhightlight> | + | </syntaxhighlight> |
| 例2: | | 例2: |
| <syntaxhighlight lang="c#"> | | <syntaxhighlight lang="c#"> |
第46行: |
第46行: |
| | | |
| // Note: This code WORKS. | | // Note: This code WORKS. |
− | </syntaxhightlight> | + | </syntaxhighlight> |
| | | |
| ===从背包移除物品=== | | ===从背包移除物品=== |
第70行: |
第70行: |
| ); | | ); |
| } | | } |
− | </syntaxhightlight> | + | </syntaxhighlight> |
| | | |
| 遍历: | | 遍历: |
第78行: |
第78行: |
| // ... | | // ... |
| } | | } |
− | </syntaxhightlight> | + | </syntaxhighlight> |
| | | |
| 注意:联机中客机是拿不到所有地点的。见[[模组:制作指南/APIs/Multiplayer#Get active locations|获取有效的地点]]。 | | 注意:联机中客机是拿不到所有地点的。见[[模组:制作指南/APIs/Multiplayer#Get active locations|获取有效的地点]]。 |