Standalone [1.3] tModLoader - A Modding API

If at all possible, how would I write a mod in F#? I have everything down, and it all seems to be written correctly, but tModLoader says "make sure there is exactly one class that extends Mod." but the class exists. Any help would be appreciated. Here's my mod code:

namespace FSTestMod
open Terraria.ModLoader
type public FSTestMod() =
inherit Mod()

let mutable properties = new ModProperties()

do
properties.Autoload <- true
properties.AutoloadBackgrounds <- true
properties.AutoloadGores <- true
properties.AutoloadSounds <- true

member __.Properties = properties
you are on your own there.
 
Can you add a feature that makes a graph of downloads every month you get on your mod, it will help tell if you are rising or falling in popularity.
 
Code:
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using TerrariaPlus.Items;
using Terraria.ModLoader.IO;
using Terraria.GameInput;

namespace TerrariaPlus
{   
    public class GlobalPlayer : ModPlayer
    {
        public bool reviveAngel = false;
        public bool reviveDebuff = false;
        public override void ResetEffects()
        {
            public bool reviveAngel = false;
            public bool reviveDebuff = false;
        }
        public override void OnHitByNPC(NPC npc, int damage, bool crit)
        {
            for (int index1 = 3; index1 < 8 + player.extraAccessorySlots; ++index1)
            {
                if (player.armor[index1].type == mod.ItemType("GlassShield"))
                {
                    if(Main.rand.Next(6)==0)
                    {
                        player.statLife += (damage);
                        Main.NewText(player.name + " blocked " +  damage + damage", 0, 155, 55);
                    }
                }
                if (player.armor[index1].type == mod.ItemType("FireShield"))
                {
                        npc.AddBuff(BuffID.OnFire, 300);
                }
                if(player.setBonus == ("Chance to dodge attacks by hiding in shadows"))
                {
                    if(Main.rand.Next(15)==0)
                    {
                        player.AddBuff(BuffID.Invisibility, 30);
                        player.statLife += (damage);
                        Main.NewText(player.name + " hid from " +  damage + " damage", 0, 155, 55);
                    }
                }
            }
        }
        public override void Hurt (bool pvp, bool quiet, double damage, int hitDirection, bool crit)
        {
            for (int index1 = 3; index1 < 8 + player.extraAccessorySlots; ++index1)
            {
                if (player.reviveAngel = true)
                {
                    if(player.reviveDebuff = false)
                    {
                        return false;
                        player.statLife += (player.statLifeMax * 0.3);
                        Main.NewText(player.name + " lives!", 0, 155, 55);
                        player.AddBuff(mod.BuffType("ReviveDebuff"), 18000);
                    }
                }
            }
        }
    }
}

says } expected when I try to compile. Any help?
 
Code:
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using TerrariaPlus.Items;
using Terraria.ModLoader.IO;
using Terraria.GameInput;

namespace TerrariaPlus
{  
    public class GlobalPlayer : ModPlayer
    {
        public bool reviveAngel = false;
        public bool reviveDebuff = false;
        public override void ResetEffects()
        {
            public bool reviveAngel = false;
            public bool reviveDebuff = false;
        }
        public override void OnHitByNPC(NPC npc, int damage, bool crit)
        {
            for (int index1 = 3; index1 < 8 + player.extraAccessorySlots; ++index1)
            {
                if (player.armor[index1].type == mod.ItemType("GlassShield"))
                {
                    if(Main.rand.Next(6)==0)
                    {
                        player.statLife += (damage);
                        Main.NewText(player.name + " blocked " +  damage + damage", 0, 155, 55);
                    }
                }
                if (player.armor[index1].type == mod.ItemType("FireShield"))
                {
                        npc.AddBuff(BuffID.OnFire, 300);
                }
                if(player.setBonus == ("Chance to dodge attacks by hiding in shadows"))
                {
                    if(Main.rand.Next(15)==0)
                    {
                        player.AddBuff(BuffID.Invisibility, 30);
                        player.statLife += (damage);
                        Main.NewText(player.name + " hid from " +  damage + " damage", 0, 155, 55);
                    }
                }
            }
        }
        public override void Hurt (bool pvp, bool quiet, double damage, int hitDirection, bool crit)
        {
            for (int index1 = 3; index1 < 8 + player.extraAccessorySlots; ++index1)
            {
                if (player.reviveAngel = true)
                {
                    if(player.reviveDebuff = false)
                    {
                        return false;
                        player.statLife += (player.statLifeMax * 0.3);
                        Main.NewText(player.name + " lives!", 0, 155, 55);
                        player.AddBuff(mod.BuffType("ReviveDebuff"), 18000);
                    }
                }
            }
        }
    }
}

says } expected when I try to compile. Any help?

if(player.reviveDebuff = false)
{
return false;
player.statLife += (player.statLifeMax * 0.3);
Main.NewText(player.name + " lives!", 0, 155, 55);
player.AddBuff(mod.BuffType("ReviveDebuff"), 18000);
}
likely because you mis-placed a return value, but that return value is still a problem.
return values go on the end:

if(player.reviveDebuff = false)
{
player.statLife += (player.statLifeMax * 0.3);
Main.NewText(player.name + " lives!", 0, 155, 55);
player.AddBuff(mod.BuffType("ReviveDebuff"), 18000);
return false;
}
 
if(player.reviveDebuff = false)
{
return false;
player.statLife += (player.statLifeMax * 0.3);
Main.NewText(player.name + " lives!", 0, 155, 55);
player.AddBuff(mod.BuffType("ReviveDebuff"), 18000);
}
likely because you mis-placed a return value, but that return value is still a problem.
return values go on the end:

if(player.reviveDebuff = false)
{
player.statLife += (player.statLifeMax * 0.3);
Main.NewText(player.name + " lives!", 0, 155, 55);
player.AddBuff(mod.BuffType("ReviveDebuff"), 18000);
return false;
}
same error still occuring
 
in the tmodloader it says error GlobalPlayer(21,4) : CS1513 if that helps
It does help:

public override void ResetEffects()
{
public bool reviveAngel = false;
public bool reviveDebuff = false;
}
it is stopping at "public" in "public bool reviveAngel = false;",
bool reviveAngel = false; would allow it to continue, but it would stop at "duplicate variable". try:
public override void ResetEffects()
{
reviveAngel = false;
reviveDebuff = false;
}

note: (only say "bool" first time)
 
It does help:

public override void ResetEffects()
{
public bool reviveAngel = false;
public bool reviveDebuff = false;
}
it is stopping at "public" in "public bool reviveAngel = false;",
bool reviveAngel = false; would allow it to continue, but it would stop at "duplicate variable". try:
public override void ResetEffects()
{
reviveAngel = false;
reviveDebuff = false;
}

note: (only say "bool" first time)
now I get error CS1061 stating that Terraria does not have a definition for reviveAngel
 
I meant like this:
public bool reviveAngel = false;
public bool reviveDebuff = false;
public override void ResetEffects()
{
reviveAngel = false;
reviveDebuff = false;
}

first time adds the definition, second calls it.
 
I meant like this:
public bool reviveAngel = false;
public bool reviveDebuff = false;
public override void ResetEffects()
{
reviveAngel = false;
reviveDebuff = false;
}

first time adds the definition, second calls it.
yeah wait that's how I had it though. It was already like that
 
yeah wait that's how I had it though. It was already like that
This is how you had it:
public bool reviveAngel = false;
public bool reviveDebuff = false;
public override void ResetEffects()
{
public bool reviveAngel = false;
public bool reviveDebuff = false;
}
 
This is how you had it:
public bool reviveAngel = false;
public bool reviveDebuff = false;
public override void ResetEffects()
{
public bool reviveAngel = false;
public bool reviveDebuff = false;
}
I put it like this
Code:
        public bool reviveAngel = false;
        public bool reviveDebuff = false;
        public override void ResetEffects()
        {
            reviveAngel = false;
            reviveDebuff = false;
        }

and it just gives me CS1061 error now.
 
player. refers to the "player" file in terraria. since GlobalPlayer is not player it is refered to as "GlobalPlayer.".
however, you don't need to(you still can) say file name inside itself:
public override void Hurt (bool pvp, bool quiet, double damage, int hitDirection, bool crit)
{
for (int index1 = 3; index1 < 8 + player.extraAccessorySlots; ++index1)
{
if (player.reviveAngel = true)
{
if(player.reviveDebuff = false)
{
return false;
player.statLife += (player.statLifeMax * 0.3);
Main.NewText(player.name + " lives!", 0, 155, 55);
player.AddBuff(mod.BuffType("ReviveDebuff"), 18000);
}
}
}
}

to:

public override void Hurt (bool pvp, bool quiet, double damage, int hitDirection, bool crit)
{
for (int index1 = 3; index1 < 8 + player.extraAccessorySlots; ++index1)
{
if (reviveAngel = true)
{
if(reviveDebuff = false)
{
return false;
player.statLife += (player.statLifeMax * 0.3);
Main.NewText(player.name + " lives!", 0, 155, 55);
player.AddBuff(mod.BuffType("ReviveDebuff"), 18000);
}
}
}
}

also I asked for the line number because sometimes there are multiple errors, when one is fixed another may show up, that seemed likely here.
 
player. refers to the "player" file in terraria. since GlobalPlayer is not player it is refered to as "GlobalPlayer.".
however, you don't need to(you still can) say file name inside itself:
public override void Hurt (bool pvp, bool quiet, double damage, int hitDirection, bool crit)
{
for (int index1 = 3; index1 < 8 + player.extraAccessorySlots; ++index1)
{
if (player.reviveAngel = true)
{
if(player.reviveDebuff = false)
{
return false;
player.statLife += (player.statLifeMax * 0.3);
Main.NewText(player.name + " lives!", 0, 155, 55);
player.AddBuff(mod.BuffType("ReviveDebuff"), 18000);
}
}
}
}

to:

public override void Hurt (bool pvp, bool quiet, double damage, int hitDirection, bool crit)
{
for (int index1 = 3; index1 < 8 + player.extraAccessorySlots; ++index1)
{
if (reviveAngel = true)
{
if(reviveDebuff = false)
{
return false;
player.statLife += (player.statLifeMax * 0.3);
Main.NewText(player.name + " lives!", 0, 155, 55);
player.AddBuff(mod.BuffType("ReviveDebuff"), 18000);
}
}
}
}

also I asked for the line number because sometimes there are multiple errors, when one is fixed another may show up, that seemed likely here.
:( now a NEW error shows up. CS0266 line (60,27).
 
Back
Top Bottom