So I am currently making an app. Obviously or else I wouldn’t be here. Right now I am making my game with several different classes, currently at 7. But I am running into issues where I have to call methods from other classes in order to use the variable:remove() function, but can’t because they are not module classes. I have thought about making changes to the code to change a lot of it into functions to allow me to call into other classes, but the code that I have seen doesn’t seem to work.
For instance, when I press the mute button on the main menu, I am trying to call the music object from the main.lua into another class to use the audio.stop, but whatever I try doesn’t seem to work. I’ve tried the:
local M = {}; function M.mute() audio.stop(test) end return M;
local muteButton = require("main") muteButton.mute()
The code above is typed in the main.lua, and would be called into the mainMenu.lua which loads the interface. Each iteration that I try doesn’t seem to work. Can anyone tell what I’m missing?
Also, is it wise to use a lot of classes? I know that if I had my entire main menu into one class, I wouldn’t really have this problem. But wouldn’t that increase the memory load?
Thanks for reading everyone. Any information would be helpful!