• For issues you find with the Switch and Console releases, please follow this link and give as much detail as possible. This is the speediest way to get info to Pipeworks and get a hotfix in the works.
  • 1.4 will bring many changes to the PC version. We strongly advise making plans to back up your worlds and players prior to updating your game. More details here.
  • Begin your search for Journey's End information here and here. Please report bugs and issues for Journey's End here.
  • For issues you find with the Mobile 1.3 update, please follow this link and give as much detail as possible. This is the speediest way to get info to DR Studios to look at your issue. Also, some troubleshooting hints here.

tModLoader Official tModLoader Help Thread

fr0g

Skeletron
This might seem silly, but i'm having serious trouble trying to organize my curly brackets. Like I'm using Visual Studio Code and it normally shows the colors for the text, but it won't and when i build + reload my mod, it says error: cs1519: invalid token '{' in class, struct, or interface member declaration
 

NumericPrime

Terrarian
This might seem silly, but i'm having serious trouble trying to organize my curly brackets. Like I'm using Visual Studio Code and it normally shows the colors for the text, but it won't and when i build + reload my mod, it says error: cs1519: invalid token '{' in class, struct, or interface member declaration
I usually count the curley braces you add one for a { and subtract one for }.
If your value is 2 you can wirte a methode or a variable that is for the whole class.
With a value of 3 you are inside a void.
With 1 you can write a class.
If you want to write a class you have to get the value to 1.
If you want to make a methode you need to get it to 2. etc.
 
Last edited:

unstew

Terrarian
Hello everyone! I have a question about partially drawing a UIImage.

The image itself is a circle that represents how much of a certain resource (let's say "soul") the player has, and it "fills up" from bottom to top when player gets more of that resource, like water in an aquarium.
So if the player has zero of that resource, the image isn't drawn at all;
If the player has reached 50% capacity, the bottom half of the image is drawn (from half its height down to the bottom);
And if player has reached maximum of what they can hold, the image is drawn as normal.

Is there a way to achieve this effect?

I'm including code of my attempt to implement a similar sort of thing (did this just to experiment; hoping this would add some context?)
I tried dynamically setting the image's Height value, which would do the opposite of what I want (im assuming that it would draw from top to bottom instead of bottom to top since Y increases from top to bottom), but that would still be something... that didn't work at all and doing it this way currently draws the whole sprite.
C#:
internal class UISoulOrb : UIState
    private UIImage soulOrbFillerImage;

    public override void OnInitialize()
    {
        area = new UIElement(); //base UIElement for this whole thing
        area.Left.Set(-area.Width.Pixels - 600, 1f);
        area.Top.Set(30, 0f);
        area.Width.Set(190, 0f);
        area.Height.Set(140, 0f);
        ...
        soulOrbFillerImage = new UIImage(GetTexture("TestMod/UI/SoulOrbFiller"));
        soulOrbFillerImage.Left.Set(10f, 0f);
        soulOrbFillerImage.Top.Set(26f, 0f);
        soulOrbFillerImage.Width.Set(100, 0f);
        //height is (supposed to be) set dynamically later
        soulOrbFillerImage.Height.Set(0f, 0f);
        ...
        area.Append(soulOrbFillerImage);
        Append(area);
    }
    public override void Update(GameTime gameTime)
    {
        var modPlayer = Main.LocalPlayer.GetModPlayer<SoulPlayer>();
        //this is supposed to dynamically change height parameter in-game:
        var soulPercentage = modPlayer.soulCurrent / modPlayer.soulMax2;
        soulOrbFillerImage.Height.Set((float)soulPercentage, 0f);
        base.Update(gameTime);
    }
Thanks in advance!
 

unstew

Terrarian
Hi i'm new here , came to ask : How can i detect that a player is wearing a certain armour piece ?
Try "UpdateEquip(Player player)". Found it in the ModItem class reference, scroll down until you see it.

Trying to make this code work , but it says that i'm missing a } at 13,46. Even if i put it there or in another place it still says i need more
You probably need more! It's likely that the code editor program you're using highlights these brackets in pairs, so you can see which brackets have a pair and which ones do not.
Send your code here if you can't figure it out.
 

unstew

Terrarian
Thanks for the help , i'll send you the code . Terraria paste - Pastebin.com
I'm pretty sure you can't override from inside other overriden methods: public override void Kill code must be on the same level as public override void ProcessTriggers code.
There's also a stray "/" at line 28 after the calculation :)
It seems you've began writing ProcessTriggers, then the Hotkey check, and then didn't finish it and went straight to Kill(). The "{" after (TutorialMod.ExplodeHotKey.JustPressed) is the bracket that needs a pair. After that, you can begin writing your Kill() code.
here's how I'd do it
 

betterlugi

Terrarian
I'm pretty sure you can't override from inside other overriden methods: public override void Kill code must be on the same level as public override void ProcessTriggers code.
There's also a stray "/" at line 28 after the calculation :)
It seems you've began writing ProcessTriggers, then the Hotkey check, and then didn't finish it and went straight to Kill(). The "{" after (TutorialMod.ExplodeHotKey.JustPressed) is the bracket that needs a pair. After that, you can begin writing your Kill() code.
here's how I'd do it
it says that : CS0115 Tutorialplayer(int) no suitable methode to override
 

unstew

Terrarian
it says that : CS0115 Tutorialplayer(int) no suitable methode to override
Where does it say that exactly? Is it in regards to the Kill() method? I've checked just now and the Kill() method does not take in a single int parameter like it does in your code (the timeleft one), instead it takes up several and none of them are ints i believe.
Where did you get this method from? It's possible it's supposed to run elsewhere. If you're sure that this is the place, check the PlayerHooks reference page and search for the kill method, and simply copy the parameters from there.
 

betterlugi

Terrarian
Where does it say that exactly? Is it in regards to the Kill() method? I've checked just now and the Kill() method does not take in a single int parameter like it does in your code (the timeleft one), instead it takes up several and none of them are ints i believe.
Where did you get this method from? It's possible it's supposed to run elsewhere. If you're sure that this is the place, check the PlayerHooks reference page and search for the kill method, and simply copy the parameters from there.
the error is at : 18,29. I'm tryna make a bind that explodes you (a killbind so to speak) , since i don't know exaclty what i'm doing i checked the example mod for instructions for binds and it was in the modplayer. And this methode was taken from a custom explosive , i hoped that if i just took the kill code it'll work
 

unstew

Terrarian
the error is at : 18,29. I'm tryna make a bind that explodes you (a killbind so to speak) , since i don't know exaclty what i'm doing i checked the example mod for instructions for binds and it was in the modplayer. And this methode was taken from a custom explosive , i hoped that if i just took the kill code it'll work
The bind does go into the modplayer class, but you'll have to do some extra work with the explosive code, just copying it won't work since the explosive and modplayer classes work very differently.
I'm not sure if Kill is the method you'd want to copy, since it's a hook, which means that instead of killing anything, it's a method that runs when something gets killed. So for modplayer, the kill method will activate when the player dies, and all code that is in the kill method will run when that happens. Same with Hurt(), PreHurt() and PostHurt(), these activate when player takes damage.
You'd probably want to spawn an explosive at the player's position when the player presses the hotkey, but I can't help you with that exactly, sorry :p try spawning a projectile with NewProjectile() from the Projectile Class Documentation's "Methods" paragraph
 

tylera220

Terrarian
The problem most likely has to do with tmodloader's version, terraria 1.4 requires tmodloader 0.11.7+ version. I've had the exact same problem until I've installed the latest tmodloader version via Steam.
Okay! Is that the x64 bit version or the x32 bit version. The reason for the question is that I would be able to run more mods without worrying about it crashing on the x64 bit version than the x32 bit version.
 
Top Bottom