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
Why isn't this script working?
Shadowfied Offline
Senior Member

Posts: 261
Threads: 34
Joined: Jul 2010
Reputation: 5
#1
Why isn't this script working?

Hi.

I'm working on a custom story where In one level I have an empty bucket placed, which the player needs to pick up and go fill it using a pump.

So I put a script area around the pump, ticked the "Item Interaction" option and made this script:

(This is in the void OnStart() area)

AddUseItemCallback("", "bucket_empty_1", "AreaFillBucket", "FillBucketFunc", true);

Then outside of the onstart area:

void FillBucketFunc(string &in asItem, string &in asEntity)
{
PlaySoundAtEntity("", "04_water_puff.snt", AreaFillBucket", 0.0f, true);
RemoveItem(asItem);
GiveItemFromFile("filled_bucket", "wooden_bucket_filled.ent");
}

But when I try to enter the level the game crashes giving me an error saying:

"FATAL ERROR: Could not load script file ~~~~~~
ExecuteString(1, 1) : ERR : No matching signatures to 'OnEnter()'
ExecuteString (1, 1) : ERR : No matching signatures to 'OnLeave()'
main (21, 1) : ERR : Unexpected end of file"

Here is the entire script (it's a new level so it's tiny)

Spoiler below!

void OnStart()
{

// Debug
if(ScriptDebugOn())
{
GiveItemFromFile("lantern", "lantern.ent");
}

PlayMusic("02_amb_strange.ogg", true, 0.2f, 2, 0, true);
AddUseItemCallback("", "bucket_empty_1", "AreaFillBucket", "FillBucketFunc", true);
}

void FillBucketFunc(string &in asItem, string &in asEntity)
{
PlaySoundAtEntity("", "04_water_puff.snt", AreaFillBucket", 0.0f, true);
RemoveItem(asItem);
GiveItemFromFile("filled_bucket", "wooden_bucket_filled.ent");
}


Also if I remove the "void FillBucketFunc" part the map works..

What did I do wrong?

Thanks in advance.


Current - Castle Darkuan
Other - F*cked Map
(This post was last modified: 01-09-2012, 09:21 AM by Shadowfied.)
01-09-2012, 09:03 AM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#2
RE: Why isn't this script working?

RemoveItem(asItem); it needs quotation marks around asItem.
And you missed the other quotation mark around AreaFillBucket


Quote:void OnStart()
{

// Debug
if(ScriptDebugOn())
{
GiveItemFromFile("lantern", "lantern.ent");
}

PlayMusic("02_amb_strange.ogg", true, 0.2f, 2, 0, true);
AddUseItemCallback("", "bucket_empty_1", "AreaFillBucket", "FillBucketFunc", true);
}

void FillBucketFunc(string &in asItem, string &in asEntity)
{
PlaySoundAtEntity("", "04_water_puff.snt", "AreaFillBucket", 0.0f, true);
RemoveItem("asItem");
GiveItemFromFile("filled_bucket", "wooden_bucket_filled.ent");
}

There is the script that you should use


(This post was last modified: 01-09-2012, 09:13 AM by flamez3.)
01-09-2012, 09:12 AM
Find
Shadowfied Offline
Senior Member

Posts: 261
Threads: 34
Joined: Jul 2010
Reputation: 5
#3
RE: Why isn't this script working?

Thank you very much.

That's what happens when you start scripting 6 am.


I can get into the level now and the script works, I get the filled bucket but the empty bucket is still there..Any idea on how to fix that?

Edit: Nevermind. Removed the quotations around "asItem" and now it gets removed. So it works, thanks again.

Current - Castle Darkuan
Other - F*cked Map
(This post was last modified: 01-09-2012, 09:21 AM by Shadowfied.)
01-09-2012, 09:20 AM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#4
RE: Why isn't this script working?

(01-09-2012, 09:20 AM)Shadowfied Wrote: Removed the quotations around "asItem" and now it gets removed. So it works
Oops, wrong advice Tongue

01-09-2012, 09:24 AM
Find




Users browsing this thread: 2 Guest(s)