Standalone [1.3] tModLoader - A Modding API

How do you scan something's code name and copy it, also how do you change texture directory of blocks or walls ("namespace" is taken, "public override string Texture" for some reason doesn't work on blocks)
 
Last edited:
SOOOOO, I got an error while publishing Rainbow's Content Pack REUPLOADED. It is an error that states that states that my mod browser credentials are invalid. I need some help because want to publish my mod but i cant. I reinstalled tmodloader and redid RCP before this error even happened. thanks.
 
How do you scan if a player has an accessory equipted through a mod player file, or how do you scan if it is not equipted

NVM: Found alternative, using reset effects
 
Last edited:
i am just want to resend my reply so when devs check the thread they find it
hey thanks for unbanning me but i need help on an other thing does anyone knows how to force terraria to use more ram ? i mean i have 4 GB ram (3.85 free) terraria uses 1.5 and i want it to use at least 2 GB so i don't suffer lag while playing calamity mod is there a way to do it ?
 
i am just want to resend my reply so when devs check the thread they find it
hey thanks for unbanning me but i need help on an other thing does anyone knows how to force terraria to use more ram ? i mean i have 4 GB ram (3.85 free) terraria uses 1.5 and i want it to use at least 2 GB so i don't suffer lag while playing calamity mod is there a way to do it ?

I think this should help i dunno?

https://github.com/blushiemagic/tModLoader/wiki/Basic-tModLoader-Usage-FAQ#outofmemoryexception
If you do have the outofmemoryexception this could help too.
 
Alright So.. at first I originally thought this was a mod related issue but someone else in Calamity thread pointed out the WoF bug that v0.10.1.5 was supposed to fix, but it is still happening with me, I have tripled checked the version, all mods up to date, which are; Calamity, BossChecklist, Cheat Sheet, and Yet Another Boss Healthbar. Is there any known issue like this still ongoing? Im having a issue where everytime I kill the Wall of Flesh, the Crimson/Hallow only half generates... and causes a drop in framerat, even dramatically sometimes. First time It killed my framerate and only created the hallow, on other maps it was hallow, hallow, crimson, and hallow, but only did one...
 
Alright So.. at first I originally thought this was a mod related issue but someone else in Calamity thread pointed out the WoF bug that v0.10.1.5 was supposed to fix, but it is still happening with me, I have tripled checked the version, all mods up to date, which are; Calamity, BossChecklist, Cheat Sheet, and Yet Another Boss Healthbar. Is there any known issue like this still ongoing? Im having a issue where everytime I kill the Wall of Flesh, the Crimson/Hallow only half generates... and causes a drop in framerat, even dramatically sometimes. First time It killed my framerate and only created the hallow, on other maps it was hallow, hallow, crimson, and hallow, but only did one...
You are not going to like my answer, also don't change anything (accept in the answer) because of it.
I think it means your computer has a bad processor.
 
You are not going to like my answer, also don't change anything (accept in the answer) because of it.
I think it means your computer has a bad processor.

Its not that, my computer is fine and works well, but I believe that tmodloader is still just bugged insome cases, because even without calamity installed it still happens, this was not that case or has ever been a framerate issue prior to the original WoF bug release.



Edit: Wait.. I just used TEdit to open up both worlds that I test then my calamity world, it appears that, while 1 of the biomes spawn in 1 spot, the other biome spawns a lot farther away than originally..., I usually assumed they make a V from or around the spawn point but this time they are from apart from each other.
 
Last edited:
Incase no one read it or even cares.

SOOOOO, I got an error while publishing Rainbow's Content Pack REUPLOADED. It is an error that states that states that my mod browser credentials are invalid. I need some help because want to publish my mod but i cant. I reinstalled tmodloader and redid RCP before this error even happened. thanks.

Lol copy and paste.

I would input a image of the error, but idk how to take a picture on pc.
 

Attachments

  • upload_2018-10-9_16-11-27.png
    upload_2018-10-9_16-11-27.png
    571.4 KB · Views: 174
  • upload_2018-10-9_16-11-38.png
    upload_2018-10-9_16-11-38.png
    571.4 KB · Views: 160
I don´t know if this is the right place to ask but, some of my modded biomes have vanished, for example, in the place were the Abyss is suposed to be, there´s just a giant crater. I´ve reinstalled my mods, tmod, and my worlds several times, yet the craters are still there. Also, Whenever i´m creating a world that has a modded biome in it, when it gets to the part of creating the biome, Terraria crashes. Please someone help me out!
 
How do you make a projectile place a block, similar to sandgun?
You'll want to override the following ModProjectile method:
Code:
public override bool OnTileCollide(Vector2 oldVelocity)
From there you'll basically want to spawn a block at the projectile's position:
Code:
int tileX = (int)((projectile.position.X + projectile.width / 2) / 16);
int tileY = (int)((projectile.position.Y + projectile.width / 2) / 16);

if (!Main.tile[tileX, tileY].active())
    WorldGen.PlaceTile(tileX, tileY, TileID.DirtBlock, forced: true);

Again, like almost all my examples, this is an untested, rudamentary implementation. It should give you a good start though.
 
You'll want to override the following ModProjectile method:
Code:
public override bool OnTileCollide(Vector2 oldVelocity)
From there you'll basically want to spawn a block at the projectile's position:
Code:
int tileX = (int)((projectile.position.X + projectile.width / 2) / 16);
int tileY = (int)((projectile.position.Y + projectile.width / 2) / 16);

if (!Main.tile[tileX, tileY].active())
    WorldGen.PlaceTile(tileX, tileY, TileID.DirtBlock, forced: true);

Again, like almost all my examples, this is an untested, rudamentary implementation. It should give you a good start though.
Placing worked, but now I am having an issue with this part of it that I added:

else
{
Item.NewItem(tileX, tileY, 18, 18, ItemID.DirtBlock);
}
return true;
 
Placing worked, but now I am having an issue with this part of it that I added:

else
{
Item.NewItem(tileX, tileY, 18, 18, ItemID.DirtBlock);
}
return true;
Those tileX and tileY coordinates are in tile dimensions, not pixel/world dimensions. So you'll want to multiply them by 16 for item spawning.
 
Whenever ModConfig becomes a thing for tModLoader, will it work by returning the configuration value or by overwriting a variable? In other words, can multiplying a ModConfig value by 2 work something like variable = ModConfig("configValName")*2;, or will it instead have to be something like ModConfig("configValName",variable); variable*=2;? Vanilla Terraria's "Preferences" thing seems to work in the latter way, while I definitely prefer the former and see no negatives about it (while I easily see a few negatives about the latter).
 
Whenever ModConfig becomes a thing for tModLoader, will it work by returning the configuration value or by overwriting a variable? In other words, can multiplying a ModConfig value by 2 work something like variable = ModConfig("configValName")*2;, or will it instead have to be something like ModConfig("configValName",variable); variable*=2;? Vanilla Terraria's "Preferences" thing seems to work in the latter way, while I definitely prefer the former and see no negatives about it (while I easily see a few negatives about the latter).

There actually is an obvious problem to your first method. C# is a strongly typed language, and if you do something like ModConfig("configValName") * 2; there's no garuntee that ModConfig() is returning a correct type. Doing something like
Code:
float c_hp_mod = 0;  //default in case loading fails
try
{
    c_hp_mod = ModConfig("config HP modifier");
}
catch (exception e)
{
    debug_message = e.message;
    c_hp_mod = 0;
}

c_hp_mod *= 2;
would be better and allows for exception handling on incorrect typing without causing errors to the player and/or failing and crashing the game.

edit: forgot the *2 and to actually set the hp modifier incase the config wasn't loaded :sigh:
 
Those tileX and tileY coordinates are in tile dimensions, not pixel/world dimensions. So you'll want to multiply them by 16 for item spawning.
Thanks again.
(I really should not post this) I have noticed you help constantly (Three times now) and you are the only one who helps. I am offering you to join me making mods because I am that desperate for more modders.
 
Last edited:
Thanks again.
(I really should not post this) I have noticed you help constantly (Three times now) and you are the only one who helps. I am offering you to join me making mods because I am that desperate for more modders.
Sorry mate but I'll have to decline. Good luck with your mod, though :)
 
There actually is an obvious problem to your first method. C# is a strongly typed language, and if you do something like ModConfig("configValName") * 2; there's no garuntee that ModConfig() is returning a correct type. Doing something like
Code:
float c_hp_mod = 0;  //default in case loading fails
try
{
    c_hp_mod = ModConfig("config HP modifier");
}
catch (exception e)
{
    debug_message = e.message;
    c_hp_mod = 0;
}

c_hp_mod *= 2;
would be better and allows for exception handling on incorrect typing without causing errors to the player and/or failing and crashing the game.

edit: forgot the *2 and to actually set the hp modifier incase the config wasn't loaded :sigh:
Your example is unnecessarily complex.
Yes, you will be able to get any property you add to your config. (What's the point of it if you couldn't?)
ExampleMod.MyConfig.MyProperty
Example config: https://paste.mod.gg/oqujujiwiq.cs
 
Back
Top Bottom