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
Script help
Rakez68 Offline
Junior Member

Posts: 11
Threads: 3
Joined: Mar 2013
Reputation: 0
#11
RE: Script help

Then you use AddUseItemCallback then.

I know. But there came this problem what I said earlier:

''I have another problem now, something I can't understand.

I pick up all four chemicals, and I try to put them into the pot (which is on the table). There does not come text ''Cannot use this item this way.'' But the SECOND time I try, there comes the text.
The item does not disappear from my inventory, and no sound effect plays.
After putting all four chemicals to the pot, nothing happens. It is supposed to play the event after all 4 chemicals have been put into the pot.''

But clearly there happens something when it doesn't give me ''Cannot use this item this way'' message when trying to put one of the chemicals into the pot. On second attempt however, it does give the message.

Never encountered something like this before.

This is the script once again:

void OnStart()
{
SetLocalVarInt("Var1", 0);
for(int i=1;i<=4;i++) AddUseItemCallback("Chemicals", "Chem"+i, "GetAcidComplete", "UsedChemsOnPot", true);
}
void UsedChemsOnPot(string &in asItem, string &in asEntity)
{

if("asParent" == "Chem1" && GetLocalVarInt("Var1") == 1)

{
AddLocalVarInt("Var1", 1);
RemoveItem("Chem1");
PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false);
}
else if("asParent" == "Chem2" && GetLocalVarInt("Var1") == 1)
{
AddLocalVarInt("Var1", 1);
RemoveItem("Chem2");
PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false);
}
else if("asParent" == "Chem3" && GetLocalVarInt("Var1") == 1)
{
AddLocalVarInt("Var1", 1);
RemoveItem("Chem3");
PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false);
}
else if("asParent" == "Chem4" && GetLocalVarInt("Var1") == 1)
{
AddLocalVarInt("Var1", 1);
RemoveItem("Chem4");
PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false);
}

if(GetLocalVarInt("Var1") == 4)
{
GiveSanityBoostSmall();
SetEntityActive("GetAcidComplete", false);
SetEntityActive("chemical_container_full_1", true);
PlayMusic("26_event_agrippa_head.ogg", false, 0.7, 0.1, 10, false);
}
}

Also:
All item names are correct.
(This post was last modified: 03-27-2013, 04:11 PM by Rakez68.)
03-27-2013, 04:09 PM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#12
RE: Script help

if("asParent" == "Chem1" && GetLocalVarInt("Var1") == 1)

asParent doesn't exist in that function, and "Var1" will not be equal to 1 after 2 of the chemicals have been added, since 1 is being added to the value each time. Also, when using the name of a variable, you need to not have it surround by the quotation marks " ", those are only used for the value of a string variable.

here...
void UsedChemsOnPot(string &in asItem, string &in asEntity)
The 2 variables you have available are the Item being used (called asItem) and the entity that you are using the item on (called asEntity)


So the 'if' statement should be
if (asItem == "Chem1")

03-27-2013, 04:11 PM
Find
Rakez68 Offline
Junior Member

Posts: 11
Threads: 3
Joined: Mar 2013
Reputation: 0
#13
RE: Script help

Sigh, I can't figure this out.
This is so complicated! Huh
I'm starting to feel embarrassed to bother you guys for so long. People must appreciate alot that you spend so much time with people that are bad at scripting like I am.

Honestly, I have no idea what you meant in your latest post. I don't understand English very well, I'm finnish.

EDIT:

HOORAY IT WORKS! Big GrinBig Grin

void OnStart()
{
SetLocalVarInt("Var1", 0);
for(int i=1;i<=4;i++) AddUseItemCallback("Chemicals", "Chem"+i, "GetAcidComplete", "UsedChemsOnPot", true);
}
void UsedChemsOnPot(string &in asItem, string &in asEntity)
{

if (asItem == "Chem1")
{
AddLocalVarInt("Var1", 1);
RemoveItem("Chem1");
PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false);
}
else if (asItem == "Chem2")
{
AddLocalVarInt("Var1", 1);
RemoveItem("Chem2");
PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false);
}
else if (asItem == "Chem3")
{
AddLocalVarInt("Var1", 1);
RemoveItem("Chem3");
PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false);
}
else if (asItem == "Chem4")
{
AddLocalVarInt("Var1", 1);
RemoveItem("Chem4");
PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false);
}

if(GetLocalVarInt("Var1") == 4)
{
GiveSanityBoostSmall();
SetEntityActive("GetAcidComplete", false);
SetEntityActive("chemical_container_full_1", true);
PlayMusic("26_event_agrippa_head.ogg", false, 0.7, 0.1, 10, false);
}
}

Thank you so much for helping me out guys! Big Grin
(This post was last modified: 03-27-2013, 05:18 PM by Rakez68.)
03-27-2013, 04:50 PM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#14
RE: Script help

No problem, I'll try to remember for next time to make it easier to understand for you - sorry about that.

But don't worry too much about how long it takes, the record for a support thread is about 8 pages, over many days I think Smile

You might find it helpful to just spend some time going over tutorials for basic programming concepts, it may help to explain some stuff and help you avoid problems in the future.

Also if you get more issues, don't forget to look at this thread, it's got some really useful info in it
http://www.frictionalgames.com/forum/thread-19868.html

03-27-2013, 05:44 PM
Find




Users browsing this thread: 1 Guest(s)