Standalone [1.3] tModLoader - A Modding API

ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient("Wood", 10);
recipe.AddTile("Workbench");
recipe.SetResult(this);
recipe.AddRecipe();


error CS1503: Argument 1: cannot convert from 'string' to 'int'
error CS1502: The best overloaded method match for 'Terraria.ModLoader.ModRecipe.AddTile(int)' has some invalid arguments
i know i'm probably just stupid to you guys but please bear with me,what do i have to change to the above code to get rid of these errors?
 
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient("Wood", 10);
recipe.AddTile("Workbench");
recipe.SetResult(this);
recipe.AddRecipe();


error CS1503: Argument 1: cannot convert from 'string' to 'int'
error CS1502: The best overloaded method match for 'Terraria.ModLoader.ModRecipe.AddTile(int)' has some invalid arguments
i know i'm probably just stupid to you guys but please bear with me,what do i have to change to the above code to get rid of these errors?

You're trying to add "Wood" and "Workbench" to the recipe and those are strings. The method uses integers: try ItemID.Wood and TileID.WorkBenches instead.
If you do this it should fix the second error too.
 
When I set up a server using "Create and play", it sticks up in "Found Server".
It also happens when I use the dedicated server. (With no mods active too)

Any solutions?
Thanks
 
You're trying to add "Wood" and "Workbench" to the recipe and those are strings. The method uses integers: try ItemID.Wood and TileID.WorkBenches instead.
If you do this it should fix the second error too.

Argument 1: cannot convert from 'string' to 'int'
The best overloaded method match for 'Terraria.ModLoader.ModRecipe.AddTile(int)' has some invalid arguments
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient("ItemID.Wood", 30);
recipe.AddTile("TileID.WorkBenches");
recipe.SetResult(this);
recipe.AddRecipe();
like this?but that doesn't work still...
 
Argument 1: cannot convert from 'string' to 'int'
The best overloaded method match for 'Terraria.ModLoader.ModRecipe.AddTile(int)' has some invalid arguments
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient("ItemID.Wood", 30);
recipe.AddTile("TileID.WorkBenches");
recipe.SetResult(this);
recipe.AddRecipe();
like this?but that doesn't work still...
Don't put ItemID.Wood and TileID.WorkBenches in quotes, that makes it a string. If you take it out of the quotes, it looks into the ItemID class and pulls out the integer for wood. Same for the workbench with TileID.
 
When I set up a server using "Create and play", it sticks up in "Found Server".
It also happens when I use the dedicated server. (With no mods active too)

Any solutions?
Thanks
I have removed TModLoader and the server starts properly.
(Just adding it because I think it could be helpful)
 
Ah that makes a bit more sense. So Global Tile functions are called for every tile. I thought when you made a Global Tile you associated it to a specific tile. Well this might not be what I want then. I don't suppose I could also modify that tombstone projectile?

This might not be what I want to use then, I'm trying to take the player's inventory list and store it in the tombstone that gets generated, so that when that player right clicks it, it instantly reapplies that player's inventory to them (instead of you know, scattering it across the ground randomely).

I've figured out how to parse through the players inventory on death and read what's in it, but now I'm just trying to figure out how to modify the tombstone that gets created to store this info. Is there a better way to go about doing this?
Hmm, this might be a bit challenging. You'll need to figure out a way to keep track of the tombstone projectile, remember the death text (projectile.miscText), and look at the code for how the "Sign" is created and stored, then figure out which inventory to restore based on the tile coordinates of the tombstone. Not impossible, but you'll need to have the decompiled source available to yourself to see how to do it. Also, having the tmodloader source might be even better, since you can see when the hooks happen.
 
Don't put ItemID.Wood and TileID.WorkBenches in quotes, that makes it a string. If you take it out of the quotes, it looks into the ItemID class and pulls out the integer for wood. Same for the workbench with TileID.
Thanks you for being patient with me,i appreciate the help.I just spend 3 days making a :red:ing wooden sword stat change...
 
Thanks you for being patient with me,i appreciate the help.I just spend 3 days making a :red:ing wooden sword stat change...
Haha no problem. I actually just started myself, but I'm a CS major so it's not hard for me to pick up and explain to others. I just use the example mod and search whatever I can't figure out.
 
Hmm, this might be a bit challenging. You'll need to figure out a way to keep track of the tombstone projectile, remember the death text (projectile.miscText), and look at the code for how the "Sign" is created and stored, then figure out which inventory to restore based on the tile coordinates of the tombstone. Not impossible, but you'll need to have the decompiled source available to yourself to see how to do it. Also, having the tmodloader source might be even better, since you can see when the hooks happen.

Hmm ok I think I'm seeing how this might work. Projectiles have an owner, which seems to be an ID? Could I use this ID to retrieve the player maybe? I'm still trying to figure out if that's what it is exactly. I could then use the player id along with the coordinates of the last collision to put into a map (Or list, I'm not super familiar with c# yet) where the key is the combination of these things, and the value would be the inventory list.

*Figured out the coordinates thing. Now I somehow need to figure out how to tell which player the projectile belongs to, and the right click function on tiles doesn't seem to have any info on who clicked on it either. Ugh.
 
Last edited:
I'm trying to create some new versions of the Chain Knife that you can make out of each material, but I can't figure out how to get it to use the proper AI style AND throw the right projectile. In the projectile, I set projectile.aiStyle to 13 (harpoon AI, same as default chain knife uses) and it just throws like a harpoon using the new projectile I created. However, when I override the AI method and set the type to 273 (the chain knife projectile), it throws like the default Chain Knife but also throws the default projectile.
 
tmodloader is telling me i have to run the game from my steam client... its a gog version...
[doublepost=1463728178,1463728060][/doublepost]
System.DllNotFoundException: Unable to load DLL 'CSteamworks': 지정된 모듈을 찾을 수 없습니다. (Exception from HRESULT: 0x8007007E)
at Steamworks.NativeMethods.SteamAPI_RestartAppIfNecessary(AppId_t unOwnAppID)
at Terraria.Social.Steam.CoreSocialModule.Initialize()
at Terraria.Social.SocialAPI.Initialize(Nullable`1 mode)
at Terraria.Program.LaunchGame(String[] args)
my crash
what happened?
[doublepost=1463664415,1463664096][/doublepost]2016-05-19 오후 10:14:47
System.DllNotFoundException: Unable to load DLL 'CSteamworks': 지정된 모듈을 찾을 수 없습니다. (Exception from HRESULT: 0x8007007E)
at Steamworks.NativeMethods.SteamAPI_RestartAppIfNecessary(AppId_t unOwnAppID)
at Terraria.Social.Steam.CoreSocialModule.Initialize()
at Terraria.Social.SocialAPI.Initialize(Nullable`1 mode)
at Terraria.Program.LaunchGame(String[] args)
its a gog version
 
Hmm ok I think I'm seeing how this might work. Projectiles have an owner, which seems to be an ID? Could I use this ID to retrieve the player maybe? I'm still trying to figure out if that's what it is exactly. I could then use the player id along with the coordinates of the last collision to put into a map (Or list, I'm not super familiar with c# yet) where the key is the combination of these things, and the value would be the inventory list.

*Figured out the coordinates thing. Now I somehow need to figure out how to tell which player the projectile belongs to, and the right click function on tiles doesn't seem to have any info on who clicked on it either. Ugh.
Hm, I don't know if I'm the best person to help, but I'd try storing the location of the last death and the lost items in an item array inside your ModPlayer class. That way, the lost items will belong to the correct player.

And projectile.owner is identical to the player.whoAmI who created the projectile. You can use Main.player[projectile.owner] to find the player from within the projectile, and
Code:
MPlayer myModPlayer = Main.player[projectile.owner].GetModPlayer</*namespace goes here*/>(mod);

myModPlayer.blahblah...
to get to the modPlayer for that player.

However, you'd want to check that the .owner of a tombstone is actually your player, and not just 255 or something like that.
 
Hm, I don't know if I'm the best person to help, but I'd try storing the location of the last death and the lost items in an item array inside your ModPlayer class. That way, the lost items will belong to the correct player.

And projectile.owner is identical to the player.whoAmI who created the projectile. You can use Main.player[projectile.owner] to find the player from within the projectile, and
Code:
MPlayer myModPlayer = Main.player[projectile.owner].GetModPlayer</*namespace goes here*/>(mod);

myModPlayer.blahblah...
to get to the modPlayer for that player.

However, you'd want to check that the .owner of a tombstone is actually your player, and not just 255 or something like that.

Ah ok, that's a good suggestion. I did try checking the owner of a tombstone, when my character died the owner of the projectile was id 0, which I assumed is me, the player. But when I had a friend join quickly to try it out, his owner id was 255 which kind of raised some flags. I'm guessing id 255 is nobody? Is there any reason a tombstone would be id 255 for a network player, and 0 for me?

If I can figure this out the only other thing I need to figure out is how to get the player id when that player right clicks on the tombstone. The right click global function doesn't look like it takes that in as an argument though :/
 
tmodloader is telling me i have to run the game from my steam client... its a gog version...
[doublepost=1463728178,1463728060][/doublepost]
its a gog version
tModLoader doesn't support the GOG version, and I don't think it will at any point due to some legal reasons or something I read somewhere.
 
Can someone tell me if making different damage types is possible? And making the numbers indicating the damage dealt have different colors?

Like if I wanted every fire based weapon deal fire based damage instead of the On Fire! debuff and make the damage numbers red, would it be possible?
 
Back
Top Bottom