Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A question regarding a key script
k.okkim Offline
Junior Member

Posts: 3
Threads: 1
Joined: Jun 2016
Reputation: 0
#5
RE: A question regarding a key script

(06-13-2016, 12:31 PM)Romulator Wrote: Alrighty - let's go through this point by point Smile

(06-13-2016, 10:17 AM)k.okkim Wrote: So I changed the Item and Door to asItem and asDoor respecively as well as removed the extra R from AddUserItemCallBack, but I'm still getting errors. I'm also wondering what you meant by my void syntax for FUNCTION being wrong. I'm looking at the page, but I don't understand what it's explaining in the void FUNCTION() snippet.

Okay, to help out here, you might want the Engine Scripts page. It contains all the functions prebuilt into Amnesia (not including various variable declarations). If you search up AddUseItemCallback, it has a part under it in bold which explains the Callback Syntax. It looks like this:

Callback syntax: void MyFunc(string &in asItem, string &in asEntity)

Therefore, your FUNCTION's Callback syntax should match it, except that MyFunc should be named FUNCTION or whatever you've named it in your AddUseItemCallback();. Therefore, asItem is correct, but you should keep the door as asEntity.

--------------

Quote:
Spoiler below!
PHP Code: (Select All)
SetSwingDoorLocked(asEntityfalsetrue); 


What does the asEntity and the booleans mean in it? I understand that the false tag is meant to do the opposite of what the syntax is supposed to do, but why is the true which comes after it? Apologies if I'm not using the correct terminology, I'm still a complete newbie when it comes to coding.

Nope, your terminology is pretty good at the moment Smile. Go back to the Engine Scripts page above and you'll notice that when you search for SetSwingDoorLocked, it shows this code:

PHP Code: (Select All)
void SetSwingDoorLocked(stringasNamebool abLockedbool abEffects); 

It doesn't fully explain, but:

asName - The name of the door you are locking.
abLocked - The state of the door's lock. True = locked, False = unlocked.
abEffects - If the unlock door sound should play when done so.

In the tutorial page earlier, the code uses asEntity instead of the door's name. It works this way because of the AddUseItemCallback(); declaration in OnStart.

PHP Code: (Select All)
void AddUseItemCallback(stringasNamestringasItemstringasEntitystringasFunctionbool abAutoDestroy); 

Notice how we declare asEntity here? The entity we put in this string variable is the door name. Then, in the callback syntax, we pass asEntity into the code as a string variable with the name "asEntity". We can then use asEntity anyway we want to, but it will always refer to the door we use in the AddUseItemCallback.

That is to say, if we go off your example;

PHP Code: (Select All)
SetLevelDoorLocked("level_wood_1"false); 
is exactly the same as
PHP Code: (Select All)
SetLevelDoorLocked(asEntityfalse); 

-----------------

Quote:I also checked the point (3, 2) in the script, but it's completely empty. I've used Tab to organize the code, but that shouldn't even affect the code in any way. Does it mean the AddUseItemCallBack() syntax is not supposed to be in void OnStart()?

Well, when you tab, you actually create one character which appears to be a few spaces. You shouldn't have to worry too much about where in the line something errors but the line of which the error occurs. The line number, as I said before, indicates an error on or before that line, which means that the code runs fine till there.

And it does go inside OnStart(). It can go other places, but it will error if it is outside a parenthesis block in any way ( {} ).

If that part is still erroring, compare it with the AddUseItemCallback(); in the Engine Scripts page and fill in the sections with what you're missing. You shouldn't have to worry about the asName section, so just leave that as "" for now.

Any other questions, feel free to ask! Smile

You are a godsend.
06-17-2016, 09:15 AM
Find


Messages In This Thread
A question regarding a key script - by k.okkim - 06-13-2016, 08:30 AM
RE: A question regarding a key script - by k.okkim - 06-17-2016, 09:15 AM



Users browsing this thread: 1 Guest(s)