Hello, I'm new to Terraria modding, but I know C# and programming well. I use Visual Studio 2019.
I would like to
mod Signs in order to create editable and writable books (or scrolls -- not to be confused with spells). How can I best do that using TModLoader?
Here is what I have found so far:
1.
Terraria.exe: decompiling Terraria.exe showed me that Sign is a different class. I mean it's not an Item per se. It seems to be under Terraria.Sign and not under Terraria.Item or Terraria.Tile.
2.
TModLoader: It seems that there is no mod class something like ModSign. No, there is no such class. Contrary to the existing classes like ModItem and ModTile. Pity. Is this something that the team might possibly consider adding to TModLoader in the future?
3.
ExampleMod: browsing the ExampleMod was helpful, but I didn't find anything even remotely similar to Signs.
3.
Make is custom: So the solution seems to be that I create a ModItem, let's call it 'TestScroll' and I create a corresponding ModTile, let's say 'TestScrollTile'. Then within my ModItem class, in SetDefaults() method, I will add a line: item.createTile = mod.TileType("MyScrollTile"); -> in order to be able to spawn the tile in the game.
4.
add Sign's functionality: Then I could add methods to my ModTile class, something like RightClick(int i, int j) method. Browsing ExampleBed provides a sample RightClick method. However this part seems to be the most difficult. Is there a way to copy the code from original Terraria? First step, I could simply provide the same functionality as the signs edit and read. In Terraria.exe under Terraria.Sign there seem to be 2 methods: ReadSign() and TextSign(), as well as fields: text, which is string type and x and y, which are int type.
4.
Checking in game: Signs have the following functionality in game:
- Mouse Over the Tile: Speech bubble appears over the Sign. Sign's text (if edited previously) appears under the Sign. The text has transparent background.
- Right Click the Tile: A blue box appears over the Sign. It seems that it is displayed at a fixed position on the screen (jumping doesn't adjust the position of the box). The box gets larger at the bottom if there is more text -> upto the maximum allowed, so the box's bottom is just over the Sign Tile. Maximum number of letters is 500: 50 letters per row, 10 rows max. Interesting thing is that you can type in more letters, they will be stored, but they will not be displayed (perhaps a small bug/oversight in the game?). There are 2 buttons: Edit and Close. If you click Edit you have 2 buttons: Save and Close.
5.
Develop further: then and only then I could program and expand the functionality. This would be the time to shine. But I need to crack the fundamentals first.
I would highly appreciate any help, comments or tips the community could provide.
FYI here is the idea which intrigued me:
Writing Sets, Empty Books, and Written Books