A puzzle about carrying too much

My player character really loves books. At one point, he'll be in a bookshop picking up books he'll need to research a task. I'd like to have him pick up, let's say five books and then print a message like, "That's all the books you can carry, and you don't want to put any back." But the character loves books, right? So he might try to pick up another book despite carrying too many. Then he'd drop the books he's carrying and find that the last book he was trying to pick up was actually the book he needed all along.

So this is something I've been noodling over for a little while. I'm not actually going to implement any inventory limits (weight, volume, etc.) in the game since this is the only place inventory limits come up. My biggest issue is that if there are six books that can be picked up, and they can be picked up in any order, how do I make the last one the right book?

I was thinking I could create a list or an array that adds an item every time the player picks up an item with"book*in the object name. I'd have something that checks how many items are in the list/array/whichever. Once it hits five, the game prints the message about this being all the books you can carry. If it hits six, a script runs that drops the other books, changes the last book's alias to the title the character was looking for and then prints the descriptive text for the incident.

Does that sound like a real thing that could happen? If it is, I'm not totally clear on how to implement it. I would love to hear what you think and see your takes on how to execute the puzzle.

Thanks!


Hmm... as i see this, all you need to do is to save the first book which is picked up, and after that the number of books. That way, you can refer to the bottom most book explicitly, probably even use unique flavour text on each one.

And you can check the items in the inventory for this, of course, but my (allegedly dumb) way to do it would be having a counter/function run every time a book is picked up. So other stuff in the pockets aren't counted and so on.

I'm not as fit when it comes to posting code as other's here, but i hope you get what i mean.


(filler for getting my edited post, updated/posted)


you basically got the idea correct already...

use a String List Attribute or an Object List Attribute (in quest, Lists, are basically the same as Arrays)

IMPORTANT: there's a difference between a 'STRING' Data Type (using a String List Attribute) and an 'OBJECT REFERENCE/POINTER (ADDRESS)' Data Type (using an Object List Attribute)

push/enque/add functionality: check if at item quantity limit via 'if (ListCount(NAME_OF_OBJECT.NAME_OF_LIST_ATTRIBUTE)) = MAX_QUANTITY' Function, for adding new item to list or not ('msg' that the list is full and/or ask-to-or-do-so 'clear/empty' the entire List and/or to remove a single item, either from the front, the back, or anywhere, coding required varies, along if desired sorting, such coding may be required, and/or check if the correct/required/needed item is in the list or not, if not, than can remove an item from list or clear/empty the entire list, lots of ways to do your code designing/methods)

pop/deque/remove functionality:

clear/empty/remove-all functionality:

view/peek/ functionality:

search/find/get functionality:

sort functionality:

copy functionality:

display list functionality: quest has built-in function to do this: DisplayList (NAME_OF_BJECT.NAME_OF_LIST_ATTRIBUTE, 0_or_1 or false_or_true), (1/true: numbered or 0/false: not numbered), or you can create your own function


if you want more reading/info on this type of stuff (Abstract Data Structures and their Management/Handling):

https://en.wikipedia.org/wiki/List_of_data_structures

https://en.wikipedia.org/wiki/Linked_list
https://en.wikipedia.org/wiki/Doubly_linked_list

https://en.wikipedia.org/wiki/Stack_(abstract_data_type)

https://en.wikipedia.org/wiki/Queue_(abstract_data_type)
https://en.wikipedia.org/wiki/Double-ended_queue

https://en.wikipedia.org/wiki/Tree_(data_structure)


quest documentation:

https://docs.textadventures.co.uk/quest/

https://docs.textadventures.co.uk/quest/tutorial/

https://docs.textadventures.co.uk/quest/elements/ (the "physical things" of quest: the OBJECTS/Elements of quest's engine/internal coding, which includes the 'Object' Element/OBJECT)

https://docs.textadventures.co.uk/quest/elements/object.html (the built-in Attributes of the 'Object' Element/OBJECT)

https://docs.textadventures.co.uk/quest/types/ (Data/Attribute/Value Types)

https://docs.textadventures.co.uk/quest/null.html (more details about the 'null' Data/Attribute/Value/Object Type)

https://docs.textadventures.co.uk/quest/scripts/

https://docs.textadventures.co.uk/quest/functions/ (categorical order)
https://docs.textadventures.co.uk/quest/functions/index_allfunctions.html (alphabetical order)

https://docs.textadventures.co.uk/quest/using_lists.html

https://docs.textadventures.co.uk/quest/using_dictionaries.html

some more useful Functions (see the 'functions: categorical/alphabetical' links above):

  1. the 'HasXXX' Functions
  2. the 'GetXXX' Functions
  3. the 'IsXXX' Functions
  4. the 'ToXXX' Functions
  5. the 'AllXXX' Functions
  6. the list functions: https://docs.textadventures.co.uk/quest/functions/#list
  7. the dictionary functions: https://docs.textadventures.co.uk/quest/functions/#dictionary
  8. the 'ScopeXXX' Functions
  9. the 'string manipulation/formatting' functions: https://docs.textadventures.co.uk/quest/functions/#string

That's really helpful! Thanks!


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

Support

Forums