Standalone [1.3] tModLoader - A Modding API

Hi guys. Annoying question.

Is there any way to call a spritebatch to draw Ui element or any hook to draw Ui element. And As I used in tConfig, there was a predraw for heart you could just return false to not draw heart. The same for mana stars. Cause I am trying to add UI elements and nothing draw at all.
Official UI support is far out, but you can look at my code: https://github.com/JavidPack/CaveStory/blob/master/Items/WeaponUtilities.cs#L58

4fYbKGT.png
 
You may have to do some research in the code to figure out a lot of the things you want. Mind control would be really hard, but you could have a globalNPC preai that checks a mind controlled variable, if it is, do special code. Maybe the easiest solution is to have all npc hover "by supernatural powers" while mindcontrolled. This way you can write one ai, and you don't need to worry about frames. Just an idea, I don't really know exactly everything you want.


Any more information? Does everyone have the same mods enabled? When does it happen, if it is with a specific item, do you have the code?


So, you want to use the NearbyEffects hook: https://github.com/bluemagic123/tMo...ual-void-nearbyeffectsint-i-int-j-bool-closer

to set a variable in ModPlayer like how Void Monolith does: https://github.com/bluemagic123/tModLoader/blob/master/ExampleMod/Tiles/VoidMonolith.cs#L38

then, check the variable in ModPlayer.PostUpdateEquips() and give the effect just like you would if it were an accessory effect.
I was running in world and it's happened...no more information.
 
How to check tiles on the screen or check tiles under player?
You can use player.position for that. The position is in the upper left corner of the player, so something like:
Code:
int y = (int)((player.position.Y / 16) + 3);
Will (probably, untested) give you the left tile right underneath the player.
 
I'm still having problems with losing my characters, today when I got on I found two of my characters (both made in 0.6) gone. Then when I went onto a third character it said that the load failed. Any help with this?

EDIT: It may have to with some of the mods built for lesser versions of tModloader. Even if I was to update them though, I'd still have my character lost.
 
Last edited:
So, you want to use the NearbyEffects hook: https://github.com/bluemagic123/tMo...ual-void-nearbyeffectsint-i-int-j-bool-closer

to set a variable in ModPlayer like how Void Monolith does: https://github.com/bluemagic123/tModLoader/blob/master/ExampleMod/Tiles/VoidMonolith.cs#L38

then, check the variable in ModPlayer.PostUpdateEquips() and give the effect just like you would if it were an accessory effect.

all this info is nice but wont help me as i dont know how to use the codes as it gives no examples on the github for any of the things just tells u what they do
 
all this info is nice but wont help me as i dont know how to use the codes as it gives no examples on the github for any of the things just tells u what they do
He explained exactly which steps are required to create something like that. Allow me to flesh it out a bit more:

First you'll want to create a class that derives from ModPlayer. In there, you want to create a boolean to check/set. Then in that same ModPlayer class you can override the PostUpdateEquips to check if the boolean is true and if it is, increase the speed of the player (also don't forget the ResetEffects function):
Code:
// Inside the ModPlayer class:
bool hasExtraSpeed;

public override void PostUpdateEquips()
{
    if(this.hasExtraSpeed) player.moveSpeed += 0.15F;
}

public override void ResetEffects()
{
    this.hasExtraSpeed = false;
}
Then you can take the VoidMonolith example and apply it to your own tile:
Code:
// Inside your ModTile class:
public override void NearbyEffects(int i, int j, bool closer)
{
    MyModPlayer modPlayer = (MyModPlayer)Main.player[Main.myPlayer].GetModPlayer(mod, "MyModPlayer");
    modPlayer.hasExtraSpeed = true;
}

That's it down to the bone (maybe even the marrow).
 
He explained exactly which steps are required to create something like that. Allow me to flesh it out a bit more:

First you'll want to create a class that derives from ModPlayer. In there, you want to create a boolean to check/set. Then in that same ModPlayer class you can override the PostUpdateEquips to check if the boolean is true and if it is, increase the speed of the player (also don't forget the ResetEffects function):
Code:
// Inside the ModPlayer class:
bool hasExtraSpeed;

public override void PostUpdateEquips()
{
    if(this.hasExtraSpeed) player.moveSpeed += 0.15F;
}

public override void ResetEffects()
{
    this.hasExtraSpeed = false;
}
Then you can take the VoidMonolith example and apply it to your own tile:
Code:
// Inside your ModTile class:
public override void NearbyEffects(int i, int j, bool closer)
{
    MyModPlayer modPlayer = (MyModPlayer)Main.player[Main.myPlayer].GetModPlayer(mod, "MyModPlayer");
    modPlayer.hasExtraSpeed = true;
}

That's it down to the bone (maybe even the marrow).

what if i say it as i need to use it

i need a block (candle) that gives a effect speed (not the same as the speed in the game) when close to it but that block (candle) decays over time (like a plant grows just other way) so all steps give the effect and last step (fully grown) gives non and when broken drops the stage its in and can only be placed (planted) on a special block (like plants on grass or pots only)
 
what if i say it as i need to use it

i need a block (candle) that gives a effect speed (not the same as the speed in the game) when close to it but that block (candle) decays over time (like a plant grows just other way) so all steps give the effect and last step (fully grown) gives non and when broken drops the stage its in and can only be placed (planted) on a special block (like plants on grass or pots only)
You'll need to look into tiles yourself then. If you look at some of the ModTiles in the Example Mod, you can modify those to suit your tastes.
Once you create your candle, you can use the random update function that is integrated into the ModTile to make it 'grow'.
 
Is there a way to make the player explode upon crafting anything (April Fools joke in my mod when it comes around)
 
Since the known issue says it's to be confirmed - I can confirm chests are behaving buggy in Multiplayer, contents suddenly disappears.
Happens with both the Tremor and Thorium mod, seperately.
 
Is there a way to prevent accessories and armor from working under certain circumstances?

For example, I want Nebula Wings to not work until Golem has been defeated. As such, you will get damage from falling, you won't be able to fly or glide, and possibly you won't be able to equip it. How do I do that?
 
Is there a way to prevent accessories and armor from working under certain circumstances?

For example, I want Nebula Wings to not work until Golem has been defeated. As such, you will get damage from falling, you won't be able to fly or glide, and possibly you won't be able to equip it. How do I do that?
You'll want to create a class that derives from GlobalItem and override the functionality of the Nebula Wings.
 
You'll want to create a class that derives from GlobalItem and override the functionality of the Nebula Wings.
But how do I add that circumstance? I'll give a harder example, because I oversimplified it. Let's say you have two dimensions, like in MC: overworld and hell. Your item must work in overworld, but it shouldn't work in another dimension. Or perhaps if you have a certain item it works, otherwise not. How do I make that? Do I just slap an if on it and its done? Because I'm afraid if I do that it'll regain functionality. I have no idea when and how often those things are checked.
 
But how do I add that circumstance? I'll give a harder example, because I oversimplified it. Let's say you have two dimensions, like in MC: overworld and hell. Your item must work in overworld, but it shouldn't work in another dimension. Or perhaps if you have a certain item it works, otherwise not. How do I make that? Do I just slap an if on it and its done? Because I'm afraid if I do that it'll regain functionality. I have no idea when and how often those things are checked.
Well, if we're talking accessories: The UpdateAccessory function on ModItems is called every tick (60 times a second), so it'd work to check in there.
It'd be a good idea to store something (like a boolean or string) when traveling to another dimension. Something like:
Code:
public string dimensionName; // Possible values: "Earth" & "Moon"
This you probably want to store on your ModPlayer. Then in your accessory you can get the ModPlayer and just check that value:
Code:
if(myModPlayerVariable.dimensionName == "Moon")
{
    // Blablablablabla
}

Would something like that work for you? ;)
 
Well, if we're talking accessories: The UpdateAccessory function on ModItems is called every tick (60 times a second), so it'd work to check in there.
It'd be a good idea to store something (like a boolean or string) when traveling to another dimension. Something like:
Code:
public string dimensionName; // Possible values: "Earth" & "Moon"
This you probably want to store on your ModPlayer. Then in your accessory you can get the ModPlayer and just check that value:
Code:
if(myModPlayerVariable.dimensionName == "Moon")
{
    // Blablablablabla
}

Would something like that work for you? ;)
I suppose that's a viable option. Thanks!
 
Back
Top Bottom