tModLoader Rail Bound - Disables movement unless in a minecart

hamstar

Terrarian
Rail Bound
v1.0.2​


See title. Here you can see it being used for a "chariot" mode (be sure to start from the beginning, though):


Here's the source code, in full:
Code:
using Terraria;
using Terraria.GameInput;
using Terraria.ID;
using Terraria.ModLoader;


namespace RailBound {
    class RailBoundMod : Mod {
        public RailBoundMod() {
        }
    }




    class RailBoundPlayer : ModPlayer {
        public override void ProcessTriggers( TriggersSet triggersSet ) {
            if( !this.player.mount.Active || !this.player.mount.Cart ) {
                if( triggersSet.Grapple ) {
                    triggersSet.Grapple = false;
                    this.player.controlHook = false;
                }
                if( triggersSet.Up ) {
                    triggersSet.Up = false;
                    this.player.controlUp = false;
                }
                if( triggersSet.Down ) {
                    triggersSet.Down = false;
                    this.player.controlDown = false;
                }
                if( triggersSet.Left ) {
                    triggersSet.Left = false;
                    this.player.controlLeft = false;
                }
                if( triggersSet.Right ) {
                    triggersSet.Right = false;
                    this.player.controlRight = false;
                }
                if( triggersSet.Jump ) {
                    triggersSet.Jump = false;
                    this.player.controlJump = false;
                }
            }
        }


        public override void SetupStartInventory( IList<Item> items, bool mediumcoreDeath ) {
            if( mediumcoreDeath ) {
                return;
            }

            var rails = new Item();
            rails.SetDefaults( ItemID.MinecartTrack );
            rails.stack = 999;

            items.Add( rails );
        }
    }
}
 
Last edited:
v1.0.2
  • Added starter rails for fresh players.
  • Improved mod description.
v1.0.1
  • First release.
 

Attachments

  • RailBound v1.0.1.zip
    4 KB · Views: 195
  • RailBound v1.0.2.zip
    4.1 KB · Views: 351
Last edited:
The code simply does this: if player presses movement button, the input is not redirected to the game. 999 rails are added to starting inventory.
 
Back
Top Bottom