#Changing Extended Variants Values

94 messages · Page 1 of 1 (latest)

tough valley
#

Hi, I'm trying to change values on extended variants with MonoModInterop (like AddSeeker or BadelineChasersEverywhere) and none of the values are changing.
( I have done the prerequisits to set-up monomodinterop)
Here's code for what I'm doing currently

using ExtendedVariants.Module;

private void SetBadelineChasers() {
            string variant = ExtendedVariantsModule.Variant.BadelineChasersEverywhere.ToString(); // "BadelineChasersEverywhere"
            var badelineChasers = ExtendedVariantInterop.GetCurrentVariantValue(variant);
            Logger.Log("CelesteArchipelago", $"Toggle Badeline Chasers: {badelineChasers} ");
            ExtendedVariantInterop.TriggerVariant(variant, true, true);
            Logger.Log("CelesteArchipelago", $"Toggle Badeline Chasers: {badelineChasers} ");
        }
tranquil beacon
#

you need to get the variant value again after modifying it

tranquil beacon
#

you are only assigning badelineChasers once

#

and bool is a value type

#

which means it is passed by value

tough valley
#

oh i see

tranquil beacon
#
public static void Main()
{
  bool myValue = false;
  Console.WriteLine(myValue);  // false
  Update(myValue);
  Console.WriteLine(myValue);  // false
}

public static void Update(bool arg)
{
  arg = true;
}

even though Update modifies the argument, the change does not affect the caller because arg is a copy, not a reference

tough valley
#

yeah I got it i was just slow lol

tranquil beacon
#

-# well technically it is a reference since the boolean is boxed but you get the idea

#

regardless

tough valley
#

yeah my b, then you're saying it should be seen in game anyways right?

tranquil beacon
#

get the value of the variant after modifying it

#

i think you need to set the chaser count

tough valley
#

so just do c# badelineChasers = ExtendedVariantInterop.GetCurrentVariantValue(variant); right after. the triggervariant

tranquil beacon
#

yea

tough valley
#

and the default value for the chaser count is one? i think?

#

i'll try it anyways and see if it makes a difference otherwise its ggs

#

Unfortunately the chasers still aren't spawning

tranquil beacon
#

i'm a bit confused why you are using modinterop if you've got an assembly reference anyway

#

use the trigger manager instead

tough valley
#

and i couldn't find a way to change it through the module.instance

tough valley
tranquil beacon
#

no

#

if you've got an assembly reference you can just straight up use the trigger manager

#

but you said you don't want to keep it

tough valley
#

I just didn't want to be more prone to mod changes but ig i'd rather have it working than die inside from interop

tranquil beacon
#

keep the modinterop

tough valley
#
ModOptionsEntries.SetVariantValue(ExtendedVariantsModule.Variant.BadelineChasersEverywhere, true);

I ended coming across this function from the UI instead of using the trigger manager (cuz i didn't want to make a new instance / had a skill issue of changing it directly)

tranquil beacon
tough valley
# tranquil beacon how are you doing the modinterop

in my Module i do c# typeof(ExtendedVariantInterop).ModInterop();

and in the import class i have

using System;
using MonoMod.ModInterop;

namespace Celeste.Mod.CelesteArchipelago {
    [ModImportName("ExtendedVariantMode")]
    public static class ExtendedVariantInterop
    {
        public static Func<string, object> GetCurrentVariantValue;

        public static Action<string, int, bool> TriggerIntegerVariant;

        public static Action<string, bool, bool> TriggerBooleanVariant;

        public static Action<string, float, bool> TriggerFloatVariant;

        public static Action<string, object, bool> TriggerVariant;

        public static Action<int> SetJumpCount;

        public static Action<int> CapJumpCount;
    }
}

and the first code sent exists within a different class that just gets called at some point

tranquil beacon
#

does modinterop get called in load

tough valley
tranquil beacon
#

i would call modinterop earlier

#

also why is the code in the constructor commented out

tough valley
#

for log reasons. The name of the folder is different from the logger nameof which ends up not doing anything ( i think ), so i just commented it out for now and when i update / build a release i'll revert it (and the file name)

#

its only saved differently locally

tranquil beacon
#

just edit nameof(CelesteArchipelagoModule) to "CelesteArchipelago" and save yourself the headache

#

this edits the visibility of log messages for log IDs beginning with CelesteArchipelago

#

if the module is built in debug mode, the logger will show verbose level messages or higher (aka all)

#

if the module is built in release mode, the logger will show info level messages or higher

#

names of folders are completely unrelated to this

tough valley
#

ah fair enough, ty for clearing up the misunderstanding

tough valley
tranquil beacon
#

are you depending on ExtendedVariants in everest.yaml

tough valley
#

yes (its a dependency not optional)

tranquil beacon
#

or optionally depending on it if you plan to work without it

#

did you save the everest.yaml

tough valley
#

yeah

tranquil beacon
tough valley
#

still stays false

#

the way i'm expecting it to work is if i change the variant value to true, the badelinechaser value should also be true (and badeline chasers would also spawn ingame)

tranquil beacon
#

and you edited the code to the following

string variant = "BadelineChasersEverywhere";
var badelineChasers = ExtendedVariantInterop.GetCurrentVariantValue(variant);
Logger.Log("CelesteArchipelago", $"Toggle Badeline Chasers: {badelineChasers} ");
ExtendedVariantInterop.TriggerBoolVariant(variant, true, true);
badelineChasers = ExtendedVariantInterop.GetCurrentVariantValue(variant);
Logger.Log("CelesteArchipelago", $"Toggle Badeline Chasers: {badelineChasers} ");
#

right

tough valley
#

yes

tranquil beacon
#

have you built and restarted celeste

tough valley
#

many times yes

tranquil beacon
#

can you send me the dll

tough valley
#

(if you're planning to run it, you might have to change how it gets called, the code shown above exists in the trap manager)

tranquil beacon
#

i don't, i just want to look at it in ilspy

tough valley
#

alr

#

op smol mistake

tranquil beacon
tough valley
#

yeah... i also saw that

tranquil beacon
#

everything seems fine in theory

tough valley
#

so its possible that its just on the extended variants side?

#

unless i'm an edge case somehow

tranquil beacon
#

what is your extended variants version ig

tough valley
#

0.40.0

tranquil beacon
#

oh shit im slightly behind on my local build

tough valley
#

.39.9?

tranquil beacon
#

.39.7

#

im not planning on running it anyway

tough valley
#

it'll auto update next time play anyways aswell

tranquil beacon
#

no

#

it's a local build

#

i can't see anything wrong

tough valley
#

ah i see

tranquil beacon
#

also nvm about the suspicions about modinterop stuff not working since the get works clearly

tough valley
tough valley
tranquil beacon
#

no i thought for some reason the modinterop didn't work properly

#

but you are getting false clearly

#

you could put a breakpoint and debug things that way i guess

tough valley
#

with dnspy? cuz i don't have that functionality (in vscode) lol

tranquil beacon
#

i think there was a reason you didn't get vs but i don't remember it

tough valley
#

i just found it easier to have vs code instead of vs2022 (didn't have a specific reason to not have it), though i do have it installed just not used. do i have to run the .exe if i wanted to use breakpoints?

tranquil beacon
#

i mean breakpoints literally pause the application

#

you need a debugger for them

#

and idk how good vsc is for this stuff

#

i just use rider