Another Stinkin' Problem [SOLVED]

I know I'm posting a lot. The lastest challenge is this -- I have a search command. When searching a certain place, the player finds a widget. The widget is automatically moved to the player's inventory. I created an inventory function identical to the default inventory command, and this function runs immediately after the widget is gotten (within the same turn), in order to inform the player (via the text pane) that he now has the widget in his inventory.

The issue is this -- the widget IS displayed in the side inventory panel, but does NOT display in the text pane when the inventory function is executed (during the same turn). If the player types "inventory" for the next turn, the widget DOES display in the text pane, as expected. So there is a one turn delay in the text pane.

So I am trying to "update" the inventory immediately after the player gets the widget, so that it gets displayed properly in the same turn when the inventory function executes. I tried sending a parameter to the inventory function to "manually" update things, without success. By the way, the inventory function uses the "FormatObjectList" function (as does the default inventory command). Not the worst problem, I know, but still frustrating!


how are you trying to display the widget in the text pane? Are you just using a 'msg' Script/Function in your custom 'inventory' Function or are you using 'DisplayList (ScopeInventory(), true/false/0/1:whatever_it_is_lol)' or something else?

(aka, we need to see your relevent code - or your entire game code, if it's not to big, to be sure we have all relevent code lol, as you should know, descriptions/explanations from people in posts, aren't too helpful compared to actually seeing the code itself)


Does your game maintain a list of objects that the inventory function uses? If so, check when the widget gets put in the list. If you use a turn script to keep the list up-to-date, then that will only happen after the players turn, so the widget would only appear next turn.

Otherwise, you might need to re-order when things are done when the player picks up the widget, so the widget gets moved and/or added to the list earlier.


My game does not maintain a list of objects for my inventory function (it is generated on-the-fly). My inventory function is just copied and pasted from (and identical to) Quest's default inventory command:

list = FormatObjectList(Template("CarryingListHeader"), game.pov, Template("And"), ".")
if (list = "") {
  msg (Template("NotCarryingAnything"))
}
else {
  msg (list)
}

The widget is added to the player's inventory BEFORE the inventory function is run. When the function is run, the widget shows up right away in the side panel, but not in the text pane. You have to type "inventory" on the next turn to see it in the text pane. So there is a 1-turn delay for the text pane, but not for the side panel, which is strange. So the relevant code looks like this:

AddToInventory (game.object) // this is widget
InventoryFunction // which routes to this:

list = FormatObjectList(Template("CarryingListHeader"), game.pov, Template("And"), ".")
if (list = "") {
  msg (Template("NotCarryingAnything"))
}
else {
  msg (list) // Here is where it should display widget in the text pane.
}

The player's inventory is displayed, but there's no widget in there (but you can see it in the side panel).


My game does not maintain a list of objects for my inventory function (it is generated on-the-fly).

Good, that is definitely the best way to do it.

So then we have to look at the code that called the inventory function.

Something that might help debugging would be to print the location of the widget at various points in the code. Eg:

msg("in inv func: " + widget.parent)
list = FormatObjectList(Template("CarryingListHeader"), game.pov, Template("And"), ".")
if (list = "") {
  msg (Template("NotCarryingAnything"))
}
else {
  msg (list)
}

You can then see where the object is at that point in the code execution.


I just did as you suggested:

PrintCentered (game.object + " " + game.object.parent)
list = FormatObjectList(Template("CarryingListHeader"), game.pov, Template("And"), ".")
if (list = "") {
  msg (Template("NotCarryingAnything"))
}
else {
  msg (list)
}
PrintCentered (game.object + " " + game.object.parent)

It prints "Object: widget Object: player" at the beginning and at the end. So the widget is where it's supposed to be.


I assume game.pov is the player?

Looking in FormatObjectList, it does remove dark objects if it is dark. Could that be an issue?

Try adding this to the start of the function:

PrintCentered ("Held: " + GetDirectChildren(game.pov))

You should see omething like:

Held: List: widget


I found the problem! Widget was a scenery object, but I had a script that made it a non-scenery object AFTER my inventory function ran. So it was in the player inventory, just not shown in the text pane until next turn (strange that side inventory panel still shows scenery objects). Silly rabbit!

Thanks for all the help Pixie and HK. Sorry I wasted your time! I guess that was what today's lesson was all about -- scenery objects in the player inventory won't show up with the "inventory" command or function, but will still show up in the inventory side panel. Ho hum.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums