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
HasItem scripting help
MsHannerBananer Offline
Member

Posts: 218
Threads: 34
Joined: Sep 2013
Reputation: 10
#1
HasItem scripting help

Looking over the HasItem script.

Objective is to prevent the player from leaving unless they have a key.

I'm kinda dumb at scripting complicated stuff, and the script for this kind of event isn't working for me.


Code is in the following spoilers.

Spoiler below!

script INSIDE void OnStart:

AddEntityCollideCallback("Player", "voiceCheck_Area", "notyet", true, 1);


Spoiler below!

script OUTSIDE void OnStart

void notyet(string &in asParent, string &in asChild, int alState)
{

if (HasItem("SecretKey") == false)
{
SetMessage("Dialogue", "KateThought_VoiceCheck", 5);
}

if (HasItem("SecretKey") == true)
{
SetEntityActive("block", false);
}

}


The door they leave out of once they've completed the map is blocked by a block box called "block". Once they have the key, the block box is supposed to be set inactive, as shown in the script.

I tried to do this right, and even looked up how other users did it in their custom stories, however I can't seem to get it right. Woe is me, haha.

"SecretlKey" is named as such in the Name field and the CustomSubItemTypeName.

01-29-2014, 09:56 AM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#2
RE: HasItem scripting help

Can you show us the whole script and please re-check the names. See if they don't match. If they don't, match them and check again.

EDIT:
In order to have the script to check the name of the item, it needs to be specified so in the .lang file IIRC.

"Veni, vidi, vici."
"I came, I saw, I conquered."
(This post was last modified: 01-29-2014, 10:00 AM by PutraenusAlivius.)
01-29-2014, 10:00 AM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#3
RE: HasItem scripting help

PHP Code: (Select All)
AddEntityCollideCallback("Player""voiceCheck_Area""notyet"true1); 

I think you're just missing the zero instead of 1.

01-29-2014, 05:03 PM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#4
RE: HasItem scripting help

What is is that isn't working? Is the dialogue not working or is there a problem with the block_box?

"What you think is irrelevant" - A character of our time

A Christmas Hunt
01-29-2014, 06:24 PM
Find
MsHannerBananer Offline
Member

Posts: 218
Threads: 34
Joined: Sep 2013
Reputation: 10
#5
RE: HasItem scripting help

(01-29-2014, 05:03 PM)Amn Wrote:
PHP Code: (Select All)
AddEntityCollideCallback("Player""voiceCheck_Area""notyet"true1); 

I think you're just missing the zero instead of 1.

Didn't work. >.<

(01-29-2014, 06:24 PM)i3670 Wrote: What is is that isn't working? Is the dialogue not working or is there a problem with the block_box?

The dialogue works fine, luckily. However once I have the key in my inventory, the check script box doesn't check for it and remove the block box.

01-29-2014, 10:01 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#6
RE: HasItem scripting help

AddEntityCollideCallback("Player", "voiceCheck_Area", "notyet", true, 1);

You put the callback true. This means that it only calls once. Then it's deleted. That's why it's not working more than once.

Trying is the first step to success.
01-29-2014, 10:06 PM
Find
MsHannerBananer Offline
Member

Posts: 218
Threads: 34
Joined: Sep 2013
Reputation: 10
#7
RE: HasItem scripting help

I've changed the script and removed the block box, and just make it so the door unlocks once the check box detects if the player has the key and just unlocks the door if they do, however remains locked if they don't.

The script is now this in the .hps (AddEntityCollide etc didn't change.

Spoiler below!

void notyet(string &in asParent, string &in asChild, int alState)
{

if(HasItem("SpecialKey") == false)
{
SetMessage("Dialogue", "KateThought_VoiceCheck", 5);
}

if(HasItem("SpecialKey") == true)
{
SetLevelDoorLocked("hospitalHome", false);
}




I checked, double checked, and triple checked the names between the .lang file and the .hps file. Everything matches up on my end.

(01-29-2014, 10:06 PM)FlawlessHair Wrote: AddEntityCollideCallback("Player", "voiceCheck_Area", "notyet", true, 1);

You put the callback true. This means that it only calls once. Then it's deleted. That's why it's not working more than once.

I figured that out last night. Big Grin Changed it. Still doesn't work. xD

(This post was last modified: 01-29-2014, 10:13 PM by MsHannerBananer.)
01-29-2014, 10:12 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#8
RE: HasItem scripting help

Things to check off now:

- Is the name "SpecialKey" correctly spelled everywhere? Both with capitalizing and grammar? ALSO in the editor!
- Did you remember the last } in the "notyet" function?
- Instead of unlocking the door, just try playing a sound, to see if anything is actually calling, or even better, call an AddDebugMessage("Message", false);

Trying is the first step to success.
01-29-2014, 10:18 PM
Find
MsHannerBananer Offline
Member

Posts: 218
Threads: 34
Joined: Sep 2013
Reputation: 10
#9
RE: HasItem scripting help

(01-29-2014, 10:18 PM)FlawlessHair Wrote: Things to check off now:

- Is the name "SpecialKey" correctly spelled everywhere? Both with capitalizing and grammar? ALSO in the editor!
- Did you remember the last } in the "notyet" function?
- Instead of unlocking the door, just try playing a sound, to see if anything is actually calling, or even better, call an AddDebugMessage("Message", false);

Spelled correctly everywhere via copy and paste.

The last } is present.

I tried changing it to a sound, didn't work, then used the AddDebugMessage("Message", false); . Neither of them worked. I don't think the function is actually calling. Which now begs the question... now what? LOL

01-29-2014, 10:42 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#10
RE: HasItem scripting help

Ok. So this is how it works right now.

You pass the script box without any key.
- The dialogue appears.
You pass the script box with a key
- Does the dialogue still appear?

If it does then something is wrong with your key, because it's not getting that you have "SpecialKey".

Trying is the first step to success.
01-30-2014, 07:14 AM
Find




Users browsing this thread: 1 Guest(s)