脚本期待{ [英] Script is expecting a {
问题描述
这里有新编码
所以我一直在为Terraria制作一个mod,问题出现在一个项目的代码上。长话短说这是错误:
c:\ Users \Hailey \Documents\My Games\Terraria \ModLoader \Mod Sources \ SaobiesMod \Items\NPCs \Items \Suspicious Chunk.cs(5,27):错误CS1514:{预计
我认为我应该是最重要的这个问题的代码是如此:
使用Terraria;
使用Terraria.ID;
使用Terraria.ModLoader;
命名空间SaobiesMod.Items;
{
public class ItemName:ModItem;
{
public override void SetDefault()
{
item.name =Suspicious Chunk;
item.width = 20;
item.height = 20;
item.maxStack = 20;
AddTooltip(一种奇怪的各种矿物质。;
item.value = 100;
item.rare = 1;
item.useAnimation = 30;
item.useTime = 30;
item.useStyle = 4;
item.consumable = true;
}
public override bool CanUseItem(Player player)
{
return!NPC.AnyNPCs(mod.NPCType(Gouzibal)); //你不能多次产生这个boss
return!Main.dayTime; //只能在晚上使用
}
公共覆盖bool UseItem(玩家玩家)
{
NPC.SpawnOnPlayer(plaer.whoAmI,mod.NPCType(Gouzibal)); // boss产生
Main.PlayerSound( 15,(int)player.position.X(int)player.position.Y,0);
返回true;
}
public override void AddRecipe()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID:MeteoriteBar,10);
recipe.AddIngredient(ItemID:Ruby,3);
recipe.AddIngredient(项目ID:ST oneBlock,250);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
我尝试过:
Iv试着按照它所说的做,放一个{那里。这只会导致无穷无尽的无效* Token here * token字符串最终以我的脚本的大部分结尾无效
这里有问题:
公共类ItemName:ModItem;不应该有分号。
AddTooltip(一种奇怪的各种矿物质。;需要一个结束括号。
返回!NPC.AnyNPCs(mod.NPCType( Gouzibal)); //你不能多次产生这个老板
返回!Main.dayTime; //只能在晚上使用不能有两个返回,第二个是无法访问的。
NPC.SpawnOnPlayer(plaer.whoAmI,mod.NPCType(Gouzibal)); // boss spawn正确的名字拼写很重要:播放器和播放器不一样。
查看编译输出:它通常给出一个行号,帮助您找到错误...
Brand new to coding here
So iv been making a mod for Terraria and the issue comes to a code for an item. Long story short this is the error:
c:\Users\Hailey\Documents\My Games\Terraria\ModLoader\Mod Sources\SaobiesMod\Items\NPCs\Items\Suspicious Chunk.cs(5,27) : error CS1514: { expected
I figured i should most the entire code with the issue so heres that:
using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace SaobiesMod.Items; { public class ItemName : ModItem; { public override void SetDefault() { item.name = "Suspicious Chunk"; item.width = 20; item.height = 20; item.maxStack = 20; AddTooltip("A weird hunk of various minerals."; item.value = 100; item.rare = 1; item.useAnimation = 30; item.useTime = 30; item.useStyle = 4; item.consumable = true; } public override bool CanUseItem(Player player) { return !NPC.AnyNPCs(mod.NPCType("Gouzibal")); //you cant spawn this boss multiple times return !Main.dayTime; //can use only at night } public override bool UseItem(Player player) { NPC.SpawnOnPlayer(plaer.whoAmI, mod.NPCType("Gouzibal")); //boss spawn Main.PlayerSound(15, (int)player.position.X (int)player.position.Y, 0); return true; } public override void AddRecipe() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID:MeteoriteBar, 10); recipe.AddIngredient(ItemID:Ruby, 3); recipe.AddIngredient(ItemID:StoneBlock, 250); recipe.SetResult(this); recipe.AddRecipe(); } } }
What I have tried:
Iv tried doing what it says, putting a { there. That just leads to an endless string of "invalid *Token here* token" which ultimately ends in a large portion of my script being "invalid" somehow
Loads of problems here:
public class ItemName : ModItem;Shouldn't have the semicolon.
AddTooltip("A weird hunk of various minerals.";Needs a closing bracket.
return !NPC.AnyNPCs(mod.NPCType("Gouzibal")); //you cant spawn this boss multiple times return !Main.dayTime; //can use only at nightCan't have two returns, the second is unreachable.
NPC.SpawnOnPlayer(plaer.whoAmI, mod.NPCType("Gouzibal")); //boss spawnthe correct spelling of names is important: "player" and "plaer" are not the same.
Look at the compilation output: it normally gives a line number which helps you find errors...
这篇关于脚本期待{的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!