Creating an item to remind player

Started by Oddysseus, Thu 21/06/2007 23:24:39

Previous topic - Next topic

Oddysseus

Is it possible to create a "To Do List" item, and update the description of that item each time the player is introduced to a new puzzle?  For instance, when an NPC asks the hero for a flower, the message "Get flower" would be added to the description.  The message would then be removed from the description once the player uses the Flower item on the NPC.

I'm working on a large, nonlinear game, and don't want the inventory box to become cluttered with "recipe" items and separate "note" items reminding the player of his objectives.  It would be nice to have a single, all-encompassing reminder where messages could be added in any order.

Khris

You can use a GUI with a ListBox, you can do this manually using arrays, you could even use a second "task inventory".

A single reminder item with a description that is constantly updated is probably the easiest way.
I'm too lazy to script example code now, though, sorry :)

ALPHATT

#2
Yeah make a list box heres an example
Code: ags

int list_v;//it doesn't matter what name you give i hope you know it[

And then add 1 to list_v when getting the info from npc so it will now be equal with 1 and then:
Code: ags

if (list_v == 1) {
      List1.AddItem("Flower");//this'll add the the item "flower" to the list
}

And when you give the flower to npc -1 from list_v so it will be equal with 0 againand then:
Code: ags

if (list_v == 0) {
      list1.RemoveItem(0);//this'll remove the "flower" item from the list
}

Well thats all and note that I named the listbox list1 you can name however you want

Hope I helped ya oh and others if I made any mistake please correct me.
Be good and i'm looking forward that game good luck!! ;D

/sig

Ashen

#3
The problem with that is, it's really only good for one item at a time - if there's more than one thing in the listbox, the top item will always be removed when you set list_v to 0 even if that's not the one you want to clear. Also, the int seems a little pointless, it looks like it'd only work if the second and third code snippets were in repeatedly_execute - and I think that would keep adding to the listbox until it overflowed and crashed (or alternatively keep deleting from the box until it crashed).

Try something like (untested):
Code: ags

function AddReminder(String text) {
  lstMemo.InsertItemAt(0,text);
}

function LoseReminder(String text) {
  int Temp;
  while (Temp < lstMemo.ItemCount) {
    if (lstMemo.Items == text) {
      lstMemo.RemoveItem(Temp);
      Temp = lstMemo.ItemCount;
    }
  Temp ++;
  }
}


(You could maybe make an array of the possible reminders, so you don't need to type the text both times - less chance of a typo messing things up.)

Then, AddReminder("Get flower"); will add that to the box, and LoseReminder("Get flower"); will search the list and delete it if needed. (Don't forget to import the functions in the header, if they're going to be used in room scripts.)

If you only want one reminder at a time (adding another replaces the existing one), you might as well use a Label instead of a ListBox. Then, check the Label text when you complete a task to see if it needs to be cleared:
Code: ags

// Use inv on character
if (player.ActiveInventory == iFlower) {
  cNpc.Say("Thank you very much!");
  player.LoseInventory(iFlower);
  if (lblMemo.Text == "Get flower") lblMemo.Text = "";
}

I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk