Code for placing items on wall

Discussion in 'Released Mods' started by CCHell, Nov 6, 2012.

  1. CCHell

    CCHell Angel Statue

    Hi there,
    I've been lurking around the forums for a while now and I have been looking at the terraria source and stuff like that. However, I want to make items that are able to be placed on the walls but I do not really know how the code works for that. Please keep in mind this is the vanilla source not tConfig.

    I have tried looking through the code for how platforms and cobwebs work but since they are not one solid object but can change depending on what's around them, it doesn't really fit my needs. An example item that would fit my need is a painting. I want to be able to place it on any open wall surface much like the wood platform but it's just one object without different frames.

    Would anyone who has experience with the vanilla source point me in the right direction as to how to add this functionality in?
  2. CCHell

    CCHell Angel Statue

    Bumping this for more views and possibly a solution...
  3. MiraiMai

    MiraiMai Hell Bat

    PlaceTile() in WorldGen.cs, you need to add your own if statements and prevent placing(return false) if there isn't a wall. At least, that's what I can see from it.
  4. Phlebas

    Phlebas Spriter

  5. MiraiMai

    MiraiMai Hell Bat

  6. CCHell

    CCHell Angel Statue

    I do know about the the PlaceTile() method but in some instances, such as the wooden platform, it never uses that method but instead uses the tilframe() method... I've been looking through that but it's tough to figure out exactly how that method works what with all the "num" variables not being helpful at all.
  7. MiraiMai

    MiraiMai Hell Bat

    TileFrame is called whenever the tile is updated, and checks if the tile is valid. I don't think it's called for placing the tile, because the tile would need to be already placed.

    Thinking about it a second time, I think it's more likely the code is in Player.cs, seeing as how that's where most "Use Item" code is.

Share This Page