superhc
Spazmatism
So..that means you fixed it? o.oAll good now
So..that means you fixed it? o.oAll good now
Im making an ammo bag that will cycle through and shoot random bullets. When I craft the bag, it only randomly chooses one type of ammo and will only shoot that kind. (Example, ill craft the pouch and it gets Musket shots, it will only shoot musket shots.)
Hints anyone?
Code:private static Random rand = new Random(); public int shoot = rand.Next(15); public override void SetDefaults() { item.name = "Endless Test Pouch"; item.damage = 1; item.ranged = true; item.width = 26; item.height = 34; item.maxStack = 1; item.consumable = false; item.knockBack = 1f; item.value = 20000; item.rare = 4; item.shootSpeed = 1f; item.ammo = ProjectileID.Bullet; if (shoot == 0) { item.shoot = 14; shoot = rand.Next(15); } if (shoot == 1) { item.shoot = 36; shoot = rand.Next(15); } if (shoot == 2) { item.shoot = 89; shoot = rand.Next(15); } if (shoot == 3) { item.shoot = 104; shoot = rand.Next(15); } if (shoot == 4) { item.shoot = 207; shoot = rand.Next(15); } if (shoot == 5) { item.shoot = 242; shoot = rand.Next(15); } if (shoot == 6) { item.shoot = 279; shoot = rand.Next(15); } if (shoot == 7) { item.shoot = 207; shoot = rand.Next(15); } if (shoot == 8) { item.shoot = 283; shoot = rand.Next(15); } if (shoot == 9) { item.shoot = 284; shoot = rand.Next(15); } if (shoot == 10) { item.shoot = 285; shoot = rand.Next(15); } if (shoot == 11) { item.shoot = 286; shoot = rand.Next(15); } if (shoot == 12) { item.shoot = 242; shoot = rand.Next(15); } if (shoot == 13) { item.shoot = 287; shoot = rand.Next(15); } if (shoot == 14) { item.shoot = 638; shoot = rand.Next(15); } }
That error means that the compiler thinks it's possible for the game to get through all of the code without returning a value. Fix this by replacing the last 'else if (condition)' with 'else'. You don't really need it anyway because either it won't be reached or it will always return true.so how can i get random stuff from trees like change some of the drops to something els
it wont allow main.rand.Next(0, 10)
error CS0103: The name 'Main' does not exist in the current context
why does it say this or is there some other way to get random numbers?
int f = main.rand.Next(0, 100);
if(f >= 0 && f <= 74)
{
return mod.ItemType("ITEM NAME");
}
else if(f >= 75 && f <= 99)
{
return mod.ItemType("ITEM NAME");
}
this also gives another error to
error CS0161: MODs NAME.Tiles.trees.ITEM NAME.DropWood ()': not all code paths return a value
What is it used for?-Made Main._drawInterfaceGameTime public
Yes, pretty much.So..that means you fixed it? o.o
Which mods do you have enabled, and on which tML version are you?Hey guys, been having trouble on the browser (Pre 0.8) where my characters are being automatically deleted after about 2 hours of play. This wasn't happening for a bit, so I thought it was fixed, but my most recent character disappeared once I got to Chlorophyte. (~ 6 hours of play)
I believe the problem may be related to the .Tplr extension, but even then I have no idea how to prevent it.
I've been having this same issue.sorry but WHYYYYYYYYY ICANT NO MORE USE CHARACTER
Impossibile leggere oltre la fine del flusso.
in System.IO.BinaryReader.FillBuffer(Int32 numBytes)
in System.IO.BinaryReader.ReadUInt16()
in Terraria.ModLoader.IO.ItemIO.GetCustomData(Int32 type, BinaryReader reader, Boolean hasGlobalSaving)
in Terraria.ModLoader.Default.MysteryItem.LoadCustomData(BinaryReader reader)
in Terraria.ModLoader.IO.ItemIO.ReadCustomData(Item item, Byte[] data, Boolean hasGlobalSaving)
[doublepost=1476385004,1476384986][/doublepost]
if u can restore the data message meI've been having this same issue.
This is what the character selection menu looks like
I posted because I am unable to fix this as well, sorry.if u can restore the data message me
i knowI posted because I am unable to fix this as well, sorry.
I can't help you.
That error means that the compiler thinks it's possible for the game to get through all of the code without returning a value. Fix this by replacing the last 'else if (condition)' with 'else'. You don't really need it anyway because either it won't be reached or it will always return true.
oh sry i fixed this one right after posting it just forgot to update that but what of the first error
anyway to get random numbers in the tree file it wont allow anything with main.
main.rand.next
main.hardmode
so on
Hello bluemagic123. Thanks for the update. However, the most recent update has caused my playerLayers to be invisible. Here's one as an example.v0.8.3.5
-Updated to Terraria 1.3.3.3
-Added mod packs - ability to enable/disable groups of mods at once
-Added ability to search mod browser by author
-Added ModifyInterfaceLayers hook
-DrawLayers can now modify the DrawInfo parameter
-Added whoAmI parameter to world-drawing hooks for items
-Made Main._drawInterfaceGameTime public
-Fixed bug where custom tile kill check uses liquid placement check
-Added modpath option for dedicated server command line
-Minor fixes and improvements
Note that if you're using the PreDrawInWorld or PostDrawInWorld hook for ModItem or GlobalItem, you will have to update your mod.
Enjoy!
Edit: Also, I'm trying something new with this update. Downloads are hosted through Github instead of Mediafire. Hopefully this circumvents some problems with Mediafire some people have; also hopefully no new problems get created.
public static readonly PlayerLayer NamahFaceLayer = new PlayerLayer("TDK", "NamahFaceLayer", PlayerLayer.Head, delegate(PlayerDrawInfo drawInfo)
{
Player drawPlayer = drawInfo.drawPlayer;//shortcut to the player
if (!drawPlayer.invis) //if the player isn't invisible -- add within range
{
//calculate position to draw the sprite at
Vector2 drawPosition = new Vector2((float)((int)(drawPlayer.position.X - Main.screenPosition.X - (float)(drawPlayer.bodyFrame.Width / 2f) + (float)(drawPlayer.width / 2f))),
(float)((int)(drawPlayer.position.Y - Main.screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f + drawPlayer.gfxOffY - drawPlayer.mount.PlayerOffset)));
//draw the sprite
Main.playerDrawData.Add(new DrawData(TerrarianDreamkeepers.tNamahFace, drawPosition + drawPlayer.headPosition + drawInfo.headOrigin,
drawPlayer.bodyFrame, drawInfo.upperArmorColor, drawPlayer.headRotation, drawInfo.headOrigin, 1f, drawInfo.spriteEffects, 0));
//draw the halo also
Main.playerDrawData.Add(new DrawData(TerrarianDreamkeepers.tHalo, drawPosition + drawPlayer.headPosition + drawInfo.headOrigin - new Vector2(0, 8),
drawPlayer.bodyFrame, Color.FromNonPremultiplied(253, 203, 246, MPlayer.haloAlpha[drawPlayer.whoAmI]), drawPlayer.headRotation, drawInfo.headOrigin, 1f, drawInfo.spriteEffects, 0));
}
});
case 3: //If Namah
if (layers[i].Name == "Legs")
{
layers[i].visible = false;
layers.Insert(i + 1, NamahLegLayer);
}
if (layers[i].Name == "Body")
{
layers[i].visible = false;
layers.Insert(i + 1, NamahBodyLayer);
}
if (layers[i].Name == "Head")
{
layers[i].visible = false;
layers.Insert(i + 1, NamahFaceLayer);
}
if (layers[i].Name == "Arms")
{
layers[i].visible = false;
layers.Insert(i + 1, NamahArmLayer);
}
break;
Player layers do inherit the invisibility of their parent layer. Pretty much the entire point of parenting layers is to inherit invisibility, so you could just make your layers parent-less. I'm not sure why they were showing in earlier updates, that was probably some bug.Hello bluemagic123. Thanks for the update. However, the most recent update has caused my playerLayers to be invisible. Here's one as an example.
And here's how I've been adding them.Code:public static readonly PlayerLayer NamahFaceLayer = new PlayerLayer("TDK", "NamahFaceLayer", PlayerLayer.Head, delegate(PlayerDrawInfo drawInfo) { Player drawPlayer = drawInfo.drawPlayer;//shortcut to the player if (!drawPlayer.invis) //if the player isn't invisible -- add within range { //calculate position to draw the sprite at Vector2 drawPosition = new Vector2((float)((int)(drawPlayer.position.X - Main.screenPosition.X - (float)(drawPlayer.bodyFrame.Width / 2f) + (float)(drawPlayer.width / 2f))), (float)((int)(drawPlayer.position.Y - Main.screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f + drawPlayer.gfxOffY - drawPlayer.mount.PlayerOffset))); //draw the sprite Main.playerDrawData.Add(new DrawData(TerrarianDreamkeepers.tNamahFace, drawPosition + drawPlayer.headPosition + drawInfo.headOrigin, drawPlayer.bodyFrame, drawInfo.upperArmorColor, drawPlayer.headRotation, drawInfo.headOrigin, 1f, drawInfo.spriteEffects, 0)); //draw the halo also Main.playerDrawData.Add(new DrawData(TerrarianDreamkeepers.tHalo, drawPosition + drawPlayer.headPosition + drawInfo.headOrigin - new Vector2(0, 8), drawPlayer.bodyFrame, Color.FromNonPremultiplied(253, 203, 246, MPlayer.haloAlpha[drawPlayer.whoAmI]), drawPlayer.headRotation, drawInfo.headOrigin, 1f, drawInfo.spriteEffects, 0)); } });
Commenting out the line 'layers.visible = false;' causes my custom layer to reappear along with the vanilla layer. So do custom layers inherit the visibility of their parent layer? Is there a way to fix this? Also, I noticed that the Example Mod hasn't been updated. Is this coming soon?Code:case 3: //If Namah if (layers[i].Name == "Legs") { layers[i].visible = false; layers.Insert(i + 1, NamahLegLayer); } if (layers[i].Name == "Body") { layers[i].visible = false; layers.Insert(i + 1, NamahBodyLayer); } if (layers[i].Name == "Head") { layers[i].visible = false; layers.Insert(i + 1, NamahFaceLayer); } if (layers[i].Name == "Arms") { layers[i].visible = false; layers.Insert(i + 1, NamahArmLayer); } break;
did u not read the first post?Are you useing "main" or "Main"? As the capitalization matters. (also it should be "Next")