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
Noob in trouble!
Macetrow Offline
Junior Member

Posts: 38
Threads: 3
Joined: Apr 2012
Reputation: 1
#1
Noob in trouble!

Hi, i created a thread the other day with a problem that my monster did not spawn from a key being picked up. Good news thou i fixed that so the monster spawns, but my key doesn't work for any door. I've gone through the tutorial on the wiki and several videos, but nothing seems to work. I didn't want to bother any of the more experienced developers on the forums with this, but it seems i've run out of options.

TL;DR: What did i do wrong with my script so my door doesn't work?

////////////////////////
//Run when starting map
void OnStart()
{
AddUseItemCallback("", "key_1", "mansion_3", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("key_1", "OnPickup");
}
void UsedKeyOnDoor(string &in item, string &in entity)
{
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_3", 0, false);
RemoveItem("key_1");
}
void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("monster", true);
ShowEnemyPlayerPosition("monster");
}
void DoorLockedPlayer(string &in entity)
{
if(GetSwingDoorLocked("mansion_3") == true)
{

SetMessage("Messages", "msgname1", 0);

}
}
////////////////////////
//Run when entering map
void OnEnter()
{

}
////////////////////////
//Run when leaving map
void OnLeave()
{

}
(This post was last modified: 04-13-2012, 07:07 PM by Macetrow.)
04-13-2012, 07:06 PM
Find
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#2
RE: Noob in trouble!

Do you have a map_cache? If so, delete it.

Is the key called "key_1" in the editor?

Is the door called called "mansion_3" in the editor?

Try replacing the "UsedKeyOnDoor" arguments to "(string &in asItem, string &in asEntity)"

04-13-2012, 07:35 PM
Find
Macetrow Offline
Junior Member

Posts: 38
Threads: 3
Joined: Apr 2012
Reputation: 1
#3
RE: Noob in trouble!

Alright, i'll take a look.
Nope, the names are correct, i deleted the cache and fixed the argument, but still doesn't work.
(This post was last modified: 04-13-2012, 07:47 PM by Macetrow.)
04-13-2012, 07:43 PM
Find
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#4
RE: Noob in trouble!

I triple-checked your code, and I just cross-checked this with my own code, and I don't see any errors. Here, I'll post what I have:

void OnStart()
{

    //Callbacks
    AddEntityCollideCallback("Player", "Area_Wind", "HallwayWindEvent", true, 1);
    AddEntityCollideCallback("Player", "Area_FallTree", "FallTreeEvent", true, 1);
    
    AddUseItemCallback("keyondoor", "key_study_1", "level_wood_3", "UnlockLevelDoor", true);
    
    SetEntityPlayerInteractCallback("Area_InteractBed", "BedEvent", true);
    
    //Enemy pathnodes, this guy is harmless though
    AddEnemyPatrolNode("enemy_suitor_1", "PathNodeArea_4", 0, "");

}

void InteractLevelDoor(string &in asEntity)
{

    AddLocalVarInt("DoorTouched", 1);

    if(HasItem("key_study_1") == true)
    {
        SetMessage("Interact", "Ch01_01_KeyOnDoor", 0);
    }

    if(GetLocalVarInt("DoorTouched") == 1)
    {
        AddQuest("01UnlockEntranceHall", "01UnlockEntranceHall");
    }

}

void UnlockLevelDoor(string &in asItem, string &in asEntity)
{

    PlaySoundAtEntity("unlock", "unlock_door.snt", "level_wood_3", 0.4f, false);
    SetLevelDoorLocked("level_wood_3", false);
    
    RemoveItem("key_study_1");
    CompleteQuest("01UnlockEntranceHall", "01UnlockEntranceHall");

}

I guess you can use that as a reference since that works??? The only problem I can see is that your names or your cache would be wrong/still there. You're getting a "Cannot use item this way!" message?

04-13-2012, 10:59 PM
Find
Macetrow Offline
Junior Member

Posts: 38
Threads: 3
Joined: Apr 2012
Reputation: 1
#5
RE: Noob in trouble!

Yes, that's the message i'm getting. I've checked a ton of times and started over multiple times, but i still get the same message.
04-13-2012, 11:01 PM
Find
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#6
RE: Noob in trouble!

Try commenting out "SetEntityCallbackFunc("key_1", "OnPickup");" and try again, as I said, the rest of your code is fine.

04-13-2012, 11:03 PM
Find
Macetrow Offline
Junior Member

Posts: 38
Threads: 3
Joined: Apr 2012
Reputation: 1
#7
RE: Noob in trouble!

I removed that, and the monster keeps spawning anyways (i deleted the cache) and the key stil doesn't work
04-13-2012, 11:09 PM
Find
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#8
RE: Noob in trouble!

I don't think your map is picking up changes to your script, because removing that callback func should have disabled the monster (which is what I was aiming to do for test purposes). But then again, as I've said, that only happens if the CACHE is gone, but you said you deleted it, which is making me scratch my head.

Sometimes what I'll do is open up the script and accidentally save it to a different location, and edit it from there, which is what may be happening. Otherwise, since I can't see your screen, it's impossible for me to tell what's the problem since I can't see what's actually happening.

Try making a syntax error to crash the script/game. If that doesn't work, you're not changing your script in any way.

Just a quick checklist:

- deleted cache
- proper arguments
- names are the same
- script changes when you change something in it
- saving to the correct location, script name is identical to map name with extension .hps

04-13-2012, 11:14 PM
Find
Macetrow Offline
Junior Member

Posts: 38
Threads: 3
Joined: Apr 2012
Reputation: 1
#9
RE: Noob in trouble!

I did make some changes so it sort of looked like yours and i accidently made a syntax error so it's not being saved to a different location. My cache has been deleted everytime i changed something, my arguments should be correct, the names on the door and key are correct, and it's saved where i want it to be saved.
04-13-2012, 11:20 PM
Find
zombiehacker595 Offline
Member

Posts: 141
Threads: 51
Joined: Mar 2012
Reputation: 3
#10
RE: Noob in trouble!

try changing

void UsedKeyOnDoor(string &in item, string &in entity)
{
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_3", 0, false);
RemoveItem("key_1");
}


to

void UsedKeyOnDoor(string &in item, string &in door)
{
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_3", 0, false);
RemoveItem("key_1");
}

thats how i always put it and it works

04-14-2012, 01:37 AM
Find




Users browsing this thread: 1 Guest(s)