Skip to content

Is this the problem with my game or with my BNM syntax? Array of objects #166

@doviettung96

Description

@doviettung96

Hi guys,
I'm trying to use BNM to run my game functions

		// Token: 0x06000260 RID: 608 RVA: 0x000021D2 File Offset: 0x000003D2
		[Token(Token = "0x6000260")]
		[Address(RVA = "0x145A4C0", Offset = "0x14594C0", VA = "0x145A4C0")]
		public Table[] FindScripts(string uiName)
		{
			return null;
		}

and Table is

namespace MoonSharp.Interpreter
{
	// Token: 0x020000B3 RID: 179
	[Token(Token = "0x20000B3")]
	public class Table : RefIdObject, IScriptPrivateResource
	{
		// Token: 0x0600068E RID: 1678 RVA: 0x00002053 File Offset: 0x00000253
		[Token(Token = "0x600068E")]
		[Address(RVA = "0x13BFCFC", Offset = "0x13BECFC", VA = "0x13BFCFC")]
		public Table(Script owner)
		{
		}

I try to make this call

    BNM_LOG_INFO("Creating mono string");
    Mono::String *monoName = CreateMonoString(scriptName);
    if (!monoName) {
        BNM_LOG_INFO("CreateMonoString failed for %s", scriptName.c_str());
        return nullptr;
    }

    BNM_LOG_INFO("Resolving FindScripts method");
    Method<Mono::Array<void *> *> findScripts{};
    findScripts = executorClass.GetMethod(BNM_OBFUSCATE("FindScripts"), 1);
    BNM_LOG_INFO("FindScripts method resolved: %s", findScripts.str().c_str());

    BNM_LOG_INFO("Invoking FindScripts");
    Mono::Array<void *> *scriptsArray{};
    const auto findScriptsException = TryInvoke([&]() {
        scriptsArray = findScripts[executor](monoName);
    });
    if (findScriptsException.IsValid()) {
        auto message = findScriptsException.Message();
        BNM_LOG_INFO("FindScripts threw an exception: %s", message.c_str());
        return nullptr;
    }

    if (!scriptsArray) {
        BNM_LOG_INFO("FindScripts returned null");
        return nullptr;
    }

however, the log just stop at

12-08 12:31:39.567  4465  4615 I ByNameModding: Creating mono string
12-08 12:31:39.567  4465  4615 I ByNameModding: Resolving FindScripts method
12-08 12:31:39.567  4465  4615 I ByNameModding: FindScripts method resolved: [Assembly-CSharp-firstpass.dll]::[MoonSharp.Interpreter]::[Table[]] [Assembly-CSharp.dll]::[FGStudio.LuaSystem.Logic]::[MonoBehaviourExecutor].(FindScripts){arguments count: 1} 
12-08 12:31:39.567  4465  4615 I ByNameModding: Invoking FindScripts

Did I do anything wrong?
My game just crash at that. No log for the exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions