(10-31-2015, 12:04 AM)Abion47 Wrote: When you declare a function, it has to go where functions can be declared. This is either within a class body or on its own. It cannot be placed within another function's body.
To clarify what I mean, you can do one of two things. To declare a function as part of a class, you do this:
class cScrMap : iScrMap
{
// ... Other class code ...
void FunctionName(const tString &in asParameterOne, float afParameterTwo)
{
}
// ... Other class code ...
}
To declare a function independent of any class, you do this:
// ... Other classes or independent functions ...
void FunctionName(const tString &in asParameterOne, float afParameterTwo)
{
}
// ... Other classes or independent functions ...
Notice how in both of these cases, the function declaration is accompanied by the curly brackets, which is the function body. When declaring a function, you have to also declare a body for that function, even if that body is completely empty.
(There are exceptions to these rules, but they deal with specific concepts in programming that you shouldn't ever need to worry about when making a mod.)
Also, the code void _CathTool_OnGui(const tString &in, float) is what is called a function signature, meaning that it contains the name, parameter types, and return value of a function. By itself, it is not valid syntax for declaring a function. To do that, you have to give the parameters valid names, as well as the function body that I mentioned earlier.
To talk about the specific errors you are mentioning, they are called syntax errors, which unlike the _CathTool_OnGui errors will not let your script be compiled until they are fixed.
ERR: Expected method or property means that there is a spot in your code where the compiler is expecting something but is not getting it. This happened when you pasted void _CathTool_OnGui(const tString &in, float), but didn't declare a method body using curly brackets.
ERR: Unexpected token '}' means that the compiler found something it wasn't expecting, which in this case was a closing curly bracket. This usually is a red herring error as it can be caused by other errors that are the actual roots of the problem. Fixing the other problems will generally resolve these as well.
ERR: Expected expression value is similar to the above error in that the compiler is expecting something it isn't getting. In this case, you moved void _CathTool_OnGui(const tString &in, float) into the body of another function, which isn't something that can be processed within a function body.
At any rate, I have to apologize. I misunderstood your original post. For some reason I thought the OnGui function was your core issue, when in fact your issue was the CathTool_UseOnPanel function.
The error ERR: No smatching signatures to 'CathTool_UseOnPanel(tString, tString)' means that in your code you are trying to call a function that according to the compiler doesn't exist. In this case, I imagine that when you were copying code from the test map, you didn't copy over the code at the top of the file.
All of the CathTool helper functions exist in a script file called "helper_custom_depth.hps". In order to use them in your code, you have to add #include "helper_custom_depth.hps" to the top of your script file. If you don't, then those functions will effectively not exist, and any calls to them will result in the above error.
(Incidentally, adding that line of code will also resolve the _CathTool_OnGui minor errors as well. That's good to know, though I kick myself for not thinking of that sooner.)
Oh my gosh, I'm so happy right now. I've been struggling with this code for days, and it turns out I was just missing one line of coding. The #include helper_custom_depth.hps was what I was missing. Very informative information you included above, too. You've helped me a lot. Thank you so much!
EDIT: How do I go about closing the door behind the player once they walk through, and they have to use the omnitool again to open the door? I figured that using a trigger area would work to close the door behind them, but I'm not sure of the code. I'm not used to SOMA's code, TDD was so much easier to code, but SOMA is so much more... Complex.
A code I tried to close the door behind the player, I had just typed:
bool CloseFinalDoor(const tString in asParent, const tString in asChild, int alState)
{
void SlideDoor_SetClosed("finaldoor", bool abClosed, bool abInstant = false);
}
but I know that is wrong, and I got errors for it, too. I knew it wouldn't work, but I had just wanted to try it.
The trigger area, under the "Area" tab, under the "Collide Callbacks" tab the CC_Entities is "player" and the CC_Funcs is "CloseFinalDoor". The name of the trigger area is "CloseFinalDoor" though that probably doesn't chance anything.
=========================
I guess one of my main issues overall with coding is that I try to compare it to TDD, in which that code I understand for the most part. But something about coding SOMA, I just don't quite understand, like trigger areas for a small example: I know that there are no more "AddEntityCollideCallbacks" like Amnesia for script areas, so how do I make script areas in SOMA. It's by using the "Trigger" areas, correct? I know there is a tab where I can type under the CC_Funcs which are, I'm ASSUMING the same as "AddEntityCollideCallbacks", except coded differently - which is what I don't understand. I'm very... Confused. I have a great story in mind, one I've been working on since SOMA came out. I just don't know how to go about coding anything yet. @_@