Hey all!
I've been recently been playing around with with different dialog methods, and I have a question concerning a particular piece of code which I would like to use for efficiencies sake. Basically, each conversation stores it's options, and if any new ones need to be added the next time the conversation is opened the code should do that without losing the old ones. I've tried to do it this way:
//in room
function hBody_Talk()
{
CurrentDialog = 0;
if(player.HasInventory(iPoster)) CreateNewOption(5, 24);
if(player.HasInventory(iGun)) CreateNewOption(6, 29);
StartDialog(0);
}
and global script
function CreateNewOption(int index, int sprite){//Add a new index
if(Game.DoOnceOnly(String.Format("&d,&d,&d", CurrentDialog, index, sprite))){
//do all the adding dialog stuff
}
}
Unfortunatly, the code only executes once, despite the string value in Game.DoOnceOnly being different. Have I misunderstood the nature of that function? I searched the forums prior and I found an earlier example using this sort of logic...
Thanks!
You didn't misunderstand, you just got the formatting character wrong :)
As is the string will always be the same, literally "&d,&d,&d", ignoring the values of the integers and therefore the contents of the if statement only executes once.
String.Format("&d,&d,&d", CurrentDialog, index, sprite))
Should be
String.Format("%d,%d,%d", CurrentDialog, index, sprite))
Haha! I can't believe I did that! :D
Thankyou very much Krus, that should do it :)