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
How to make a hallucination event.
Dalroc Offline
Member

Posts: 57
Threads: 2
Joined: Mar 2011
Reputation: 0
#9
RE: How to make a hallucination event.

(04-09-2011, 03:16 PM)ZxBrad Wrote: I did that. but then i added a new key to my map and a unlock door script thing and im getting another crash now. Heres my script. And srry if im not getting it my signature clearly states im a noob.

// Run first time starting map
void OnStart()
{
SetMessage("Journal", "start", 8.0f);
AddUseItemCallback("", "doorkey_1", "castle_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "exitkey_1", "metal_1", "UsedKeyOnDoor", true);
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_1", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("doorkey_1");
}
{
SetSwingDoorLocked("metal_1", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("exitkey_1");
}

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_1" , true);
}
You are lacking the fundamental basic knowledge of scripting.
The braces ({ and }) notes the beginning and start of a function (or a for-loop or a if conditional), everything you want to happen within a function has to be placed between the braces.
The OnStart function is called when the map is first loaded, so if you want any other function in your script you will have to call that function within the Onstart function. Thats why you have the Callbacks, they will call the function it's told to call.
So as you probably understand the functions need names to be called, that's what the OnStart, UsedKeyOnDoor and MonsterFunc1 is.

As you can see in your code you have a function that has no name.
{
SetSwingDoorLocked("metal_1", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("exitkey_1");
}
It's probably this that is crashing your game. You have to give this function a name and the right parameters. Also in your AddUseItemCallback("", "exitkey_1", "metal_1", "UsedKeyOnDoor", true); you are calling the same function as the other ItemCallback.
This means that when you use "exitkey_1" on "metal_1" you will call the function to unlock "castle_1". So you will have to make the new ItemCallback call your nameless function, or you modify your "UsedKeyOnDoor" to a generic unlock function that work for several doors (search forums for this).

I really can't learn you too script, please read some easy guide, or just look through some other people scripts and learn from that. It's not that hard!

P.S. Also, look at my last post what I said about the key being removed automatically by the ItemCallback.. If you are going to ask for help on the forums at least make use of the help you get.
(This post was last modified: 04-09-2011, 03:41 PM by Dalroc.)
04-09-2011, 03:35 PM
Find


Messages In This Thread
How to make a hallucination event. - by ZxBrad - 04-09-2011, 01:29 PM
RE: How to make a hallucination event. - by Dalroc - 04-09-2011, 03:35 PM



Users browsing this thread: 1 Guest(s)