• Register
Forum Thread
  Posts  
Baldi's Basics C# edits not compiling??? (Forums : Coding & Scripting : Baldi's Basics C# edits not compiling???) Locked
Thread Options
May 29 2018 Anchor

It's my first time being on here but I don't even know where this goes anyways.

I'm trying to make all questions in Baldi's Basics correct regardless if it's actually correct. I'm confused on how to mod this game with ILSpy. All errors are attached to this image.

All errors. I am confused what profiles I should choose, and they all give me the same error!


Here's the source code. (ignore the hashtag links)


#region " Imports "
using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
#endregion 

#region " Referenced assemblies "
// - UnityEngine.UI v1.0.0.0
// - UnityEngine.CoreModule v0.0.0.0
// - UnityEngine.AIModule v0.0.0.0
// - UnityEngine.AudioModule v0.0.0.0
// - UnityEngine.AnimationModule v0.0.0.0
// - UnityEngine.PhysicsModule v0.0.0.0
// - mscorlib v2.0.0.0
// - Assembly-CSharp v0.0.0.0
#endregion 

namespace Script {
class MathGameScript
{

	// Limited support!
	// You can only reference methods or fields defined in the class (not in ancestors classes)
	// Fields and methods stubs are needed for compilation purposes only.
	// Reflexil will automaticaly map current type, fields or methods to original references.
	MathGameScript()
	{
	using UnityEngine;
using UnityEngine.UI;
}

public RawImage[] results = new RawImage[3];
public AudioClip[] bal_numbers = new AudioClip[10];
public AudioClip[] bal_praises = new AudioClip[5];
public AudioClip[] bal_problems = new AudioClip[3];
private string[] hintText = new string[2]
{
	"I DON'T CARE",
	"LOL"
};
private AudioClip[] audioQueue = new AudioClip[20];

// MathGameScript;

	}
	
	#region " Methods stubs "
	// Do not add or update any method. If compilation fails because of a method declaration, comment it
	static void CheckAnswer()
{
	if (this.playerAnswer.text == this.solution.ToString() & !this.impossibleMode)
	{
		this.results[this.problem - 1].texture = this.correct;
		this.baldiAudio.Stop();
		this.ClearAudioQueue();
		int num = Mathf.RoundToInt(Random.Range(0f, 4f));
		this.QueueAudio(this.bal_praises[num]);
		this.NewProblem();
	}
	else
	{
		this.results[this.problem - 1].texture = this.correct;
		this.baldiAudio.Stop();
		this.ClearAudioQueue();
		int num = Mathf.RoundToInt(Random.Range(0f, 4f));
		this.QueueAudio(this.bal_praises[num]);
		this.NewProblem();
	}
}

// MathGameScript

private void NewProblem()
{
	this.playerAnswer.text = string.Empty;
	this.problem++;
	if (this.problem <= 3)
	{
		this.QueueAudio(this.bal_problems[this.problem - 1]);
		if (this.problem <= 2 || this.gc.notebooks <= 1)
		{
			this.num1 = (float)Mathf.RoundToInt(Random.Range(0f, 9f));
			this.num2 = (float)Mathf.RoundToInt(Random.Range(0f, 9f));
			this.sign = Mathf.RoundToInt(Random.Range(0f, 1f));
			this.QueueAudio(this.bal_numbers[Mathf.RoundToInt(this.num1)]);
			if (this.sign == 0)
			{
				this.solution = this.num1 + this.num2;
				this.questionText.text = "SOLVE MATH Q" + this.problem + ": \n \n" + this.num1 + "+" + this.num2 + "=";
				this.QueueAudio(this.bal_plus);
			}
			else if (this.sign == 1)
			{
				this.solution = this.num1 - this.num2;
				this.questionText.text = "SOLVE MATH Q" + this.problem + ": \n \n" + this.num1 + "-" + this.num2 + "=";
				this.QueueAudio(this.bal_minus);
			}
			this.QueueAudio(this.bal_numbers[Mathf.RoundToInt(this.num2)]);
			this.QueueAudio(this.bal_equals);
		}
		else
		{
			this.impossibleMode = true;
			this.num1 = Random.Range(1f, 9999f);
			this.num2 = Random.Range(1f, 9999f);
			this.num3 = Random.Range(1f, 9999f);
			this.sign = Mathf.RoundToInt((float)Random.Range(0, 1));
			this.QueueAudio(this.bal_screech);
			if (this.sign == 0)
			{
				this.questionText.text = "SOLVE MATH Q" + this.problem + ": \n" + this.num1 + "+(" + this.num2 + "X" + this.num3 + "=";
				this.QueueAudio(this.bal_plus);
				this.QueueAudio(this.bal_screech);
				this.QueueAudio(this.bal_times);
				this.QueueAudio(this.bal_screech);
			}
			else if (this.sign == 1)
			{
				this.questionText.text = "SOLVE MATH Q" + this.problem + ": \n (" + this.num1 + "/" + this.num2 + ")+" + this.num3 + "=";
				this.QueueAudio(this.bal_divided);
				this.QueueAudio(this.bal_screech);
				this.QueueAudio(this.bal_plus);
				this.QueueAudio(this.bal_screech);
			}
			this.num1 = Random.Range(1f, 9999f);
			this.num2 = Random.Range(1f, 9999f);
			this.num3 = Random.Range(1f, 9999f);
			this.sign = Mathf.RoundToInt((float)Random.Range(0, 1));
			if (this.sign == 0)
			{
				this.questionText2.text = "SOLVE MATH Q" + this.problem + ": \n" + this.num1 + "+(" + this.num2 + "X" + this.num3 + "=";
			}
			else if (this.sign == 1)
			{
				this.questionText2.text = "SOLVE MATH Q" + this.problem + ": \n (" + this.num1 + "/" + this.num2 + ")+" + this.num3 + "=";
			}
			this.num1 = Random.Range(1f, 9999f);
			this.num2 = Random.Range(1f, 9999f);
			this.num3 = Random.Range(1f, 9999f);
			this.sign = Mathf.RoundToInt((float)Random.Range(0, 1));
			if (this.sign == 0)
			{
				this.questionText3.text = "SOLVE MATH Q" + this.problem + ": \n" + this.num1 + "+(" + this.num2 + "X" + this.num3 + "=";
			}
			else if (this.sign == 1)
			{
				this.questionText3.text = "SOLVE MATH Q" + this.problem + ": \n (" + this.num1 + "/" + this.num2 + ")+" + this.num3 + "=";
			}
			this.QueueAudio(this.bal_equals);
		}
		this.playerAnswer.ActivateInputField();
		this.questionInProgress = true;
	}
	else
	{
		this.endDelay = 5f;
		if (!this.gc.spoopMode)
		{
			this.questionText.text = "WOW! YOU EXIST!";
		}
		else
		{
			int num = Mathf.RoundToInt(Random.Range(0f, 1f));
			this.questionText.text = this.hintText[num];
			this.questionText2.text = string.Empty;
			this.questionText3.text = string.Empty;
		}
	}
}

// MathGameScript
private void PlayQueue()
{
	this.baldiAudio.PlayOneShot(this.audioQueue[0]);
	this.UnqueueAudio();
}

// MathGameScript
using UnityEngine;

private void QueueAudio(AudioClip sound)
{
	this.audioQueue[this.audioInQueue] = sound;
	this.audioInQueue++;
}

// MathGameScript
using UnityEngine;

private void Start()
{
	this.baldiAudio = base.GetComponent<AudioSource>();
	this.gc.ActivateLearningGame();
	this.QueueAudio(this.bal_intro);
	this.QueueAudio(this.bal_howto);
	this.NewProblem();
	if (this.gc.spoopMode)
	{
		this.baldiFeedTransform.position = new Vector3(-1000f, -1000f, 0f);
	}
}

// MathGameScript
private void UnqueueAudio()
{
	for (int i = 1; i < this.audioInQueue; i++)
	{
		this.audioQueue[i - 1] = this.audioQueue[i];
	}
	this.audioInQueue--;
}

// MathGameScript
using UnityEngine;

private void Update()
{
	if (!this.baldiAudio.isPlaying)
	{
		if (this.audioInQueue > 0 & !this.gc.spoopMode)
		{
			this.PlayQueue();
		}
		this.baldiFeed.SetBool("talking", false);
	}
	else
	{
		this.baldiFeed.SetBool("talking", true);
	}
	if ((Input.GetKeyDown("return") || Input.GetKeyDown("enter")) & this.questionInProgress)
	{
		this.questionInProgress = false;
		this.CheckAnswer();
	}
	if (this.problem > 3)
	{
		this.endDelay -= 1f * Time.unscaledDeltaTime;
		if (this.endDelay <= 0f)
		{
			this.ExitGame();
		}
	}
}

	
	#endregion 
	
	#region " Fields stubs "
	// Do not add or update any field. If compilation fails because of a field declaration, comment it
	GameControllerScript gc;
	BaldiScript baldiScript;
	UnityEngine.GameObject mathGame;
	UnityEngine.UI.RawImage[] results;
	UnityEngine.Texture correct;
	UnityEngine.Texture incorrect;
	UnityEngine.UI.InputField playerAnswer;
	UnityEngine.UI.Text questionText;
	UnityEngine.UI.Text questionText2;
	UnityEngine.UI.Text questionText3;
	UnityEngine.Animator baldiFeed;
	UnityEngine.Transform baldiFeedTransform;
	UnityEngine.AudioClip bal_plus;
	UnityEngine.AudioClip bal_minus;
	UnityEngine.AudioClip bal_times;
	UnityEngine.AudioClip bal_divided;
	UnityEngine.AudioClip bal_equals;
	UnityEngine.AudioClip bal_howto;
	UnityEngine.AudioClip bal_intro;
	UnityEngine.AudioClip bal_screech;
	UnityEngine.AudioClip[] bal_numbers;
	UnityEngine.AudioClip[] bal_praises;
	UnityEngine.AudioClip[] bal_problems;
	float endDelay;
	int problem;
	int audioInQueue;
	float num1;
	float num2;
	float num3;
	int sign;
	float solution;
	string[] hintText;
	bool questionInProgress;
	bool impossibleMode;
	UnityEngine.AudioClip[] audioQueue;
	UnityEngine.AudioSource baldiAudio;
	#endregion 

}
}

May 30 2018 Anchor

That function (CheckAnswer) needs to be within a class/struct, it cannot exist like that.

--

Meadow of Dreams

Nightshade
Nightshade Unemployed 3D artist
Jun 17 2018 Anchor

It looks like you just ripped CheckAnswer() from some other piece of code because it's a class method (function) residing in the main scope instead of within the scope of a class. You can tell by the this -keyword (this is a reference to the object that was initialized from the class).

Also, next time post the source code with line numbers: it's frustrating to count rows manually.

--

   - My portfolio
“There he goes. One of God's own prototypes. Some kind of high powered mutant never even considered for mass production. Too weird to live, and too rare to die.” Hunter S. Thompson

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.