return command?
Moderator: Event DM
return command?
I can't figure out how to use this one. I learned the toolset by experimenting with it, but I can't find a way to get this to work. All I know is that int StartingConditional() is needed at the top, and the return is used to return a value. It's very important for conversations which is why I need it. I assumed that it would return a variable and depending on that variable a conversation line may or may not be said- will not be said if 0 and will be said if 1. Or the return TRUE and return FALSE thing. Can anyone clarify the use of this statement for me? It is pretty much essential for my quests, and I don't like the plot wizard.
- Jordicus
- Team Member; Retired with Honors
- Posts: 8042
- Joined: Tue Jan 21, 2003 3:46 pm
- Location: Whitehall, PA (GMT -4)
- Contact:
sample code from a previous script example:
Code: Select all
int HasItem(object oPlayer, string sItemTag)
{
int bReturnValue = FALSE;
object oItem = GetItemPossessedBy(oPlayer, sItemTag);
if (GetIsObjectValid(oItem)==TRUE){
bReturnValue = TRUE;
}
return bReturnValue;
}
void main()
{
object oPC = GetEnteringObject();
string sItem1 = "XYZ1"; // tag of first key
if (HasItem(oPC, sItem1))
{
SendMessageToPC(oPC, "You may pass");
}else
{
SendMessageToPC(oPC, "This area is restricted");
}
}
- maxinion
- Team Member; Retired with Honors
- Posts: 2778
- Joined: Mon Mar 17, 2003 7:44 pm
- DM Avatar: Andrinor
- Location: Bay Area, CA
- Contact:
Here you go.
1- presence of something. 0- absense. Its so, so its nothing. Therefore, 1=true, 0=false. In the int StartingConditional, you're creating a funcion that returns an int. The conversation editor checks this script- if it returns a 1, and therefore true, that leg is displayed, or whatnot. Otherwise, it isn't. return is used in all other methods that aren't voids- voids need 'void'-nothing- to return, to be complete, while other functions, like int, string, etc., need a data-type of their own to be returned to compile succesfully.
Does that make sense?
1- presence of something. 0- absense. Its so, so its nothing. Therefore, 1=true, 0=false. In the int StartingConditional, you're creating a funcion that returns an int. The conversation editor checks this script- if it returns a 1, and therefore true, that leg is displayed, or whatnot. Otherwise, it isn't. return is used in all other methods that aren't voids- voids need 'void'-nothing- to return, to be complete, while other functions, like int, string, etc., need a data-type of their own to be returned to compile succesfully.
Does that make sense?
I found my old computer class notes from when we did C. Amazing how much you forget once the class is over and the exam is written.
Those helped a lot too, but it still doesnt show the line of conversation even though the Text Appears When is set to the script and all that. BTW, does it have to be StartingConditional, or can it be any int function? Thanks 

