Stackable Library

Sora574
Have you ever wanted to help keep a player's inventory clean?
Have you ever gotten tired of seeing many objects with the same name, that do the exact same thing?
I bet this looks familiar, huh?
Inventory
Potion
Potion
Potion
Coin
Potion
Coin


Well now, this annoyance can be a thing of the past!
Using state-of-the-art doohickeys, gizmos, gadgets, and coding,* I bring to you...
The Stackable Library

With this library, if you have objects with the same alias, you can combine them all into one manageable place in the player's inventory. For example:
Potion: 4
Coin: 2


And the best part is... It does all this and more automatically! The only thing you need to do is change some settings in the new 'Stackable' tab inside the editor of any object.

I've included a demo, along with the library (you need both to play the demo), so try it out!
Have a question? Ask.
Tell me what you think!

*Minus the doohickeys, gizmos, and gadgets

UPDATE 1.2:
[list][*]Fixed all bugs[/*:m]
[*]Added inventory verb support for the stack[/*:m]
[*]Added a default 'look at' script that shows everything inside the stack in one line[/*:m]
[*]100% bug free guaranteed (unless you find a bug)[/*:m]
[*]NEW FUNCTION TO ENABLE STACKING. CHECK BELOW[/*:m][/list:u]

**Currently, to enable stacking, you must add the 'Enable stacking' function, which is under the 'Scripts' section in the GUI (or enable_function by script), to your game's start script. Sorry for the inconvenience.**

levicki
Will check it out soon.

HegemonKhan
the only problem, is that even with the stackable feature, you can still have too many items cluttering up the inventory ;)

potion1 (5)
potion2 (5)
potion3 (5)
potion4 (5)
potion5 (5)
potion6 (5)
potion7 (5)
potion8 (5)
potion9 (5)
coin1 (5)
coin2 (5)
coin3 (5)
coin4 (5)
coin5 (5)
etc

if this is the case for you, then you'll need to store them elsewhere, anyways. I've got a storage system for those who need one, though it's quite easy to make on your own too, nothing too fancy with coding. Though, it's only a simple blue print, I've not made an all encompassing storage system nor a library file nor demo file of it.

I'm just pointing this out for anyone who is interested, but your stackable feature is still extremely useful regardless !!! :D

Sora574
HegemonKhan wrote:the only problem, is that even with the stackable feature, you can still have too many items cluttering up the inventory ;)


I'm not sure what you mean... Are you talking about different objects that are non-related being put into one storage object? If so, that's not what this is trying to accomplish.

What this library does is if you have one object with the name 'potion', and another object with the alias 'potion', instead of showing

potion
potion

it shows

potion: 2

in the inventory... Without a limit. So, why would it say 'potion1 (5)' or 'potion2 (5)'?
I don't quite understand what you're saying.

sonic102
What about disambiguation problems? Is that tested?

@HK: Sora wants this to stack things that have the same alias. To merge potion1 and potion2 into one stack would be difficult.
Also, how do I limit a stack? I only want to allow 10 potions, for example, and no more.

Sora574
sonic102 wrote:What about disambiguation problems? Is that tested?


I don't know what that means, sorry. Explain?

sonic102 wrote:Also, how do I limit a stack? I only want to allow 10 potions, for example, and no more.


Hmm... I'll get to work on putting that into the library.
For now, you could just add a turn script that does something like this:
object = [Name of the object you want to limit]
container = GetObject(object.alias + "_container")
if (container.stacked_count > 10) {
unstack (container)
msg ("You can only carry 10 of that.")
}


EDIT: Fixed code.
SECOND EDIT: Fixed code... again.

sonic102
For example, I have a green potion with the alias potion and a regular potion with the alias potion, which stacks into one. If I say 'drink potion', which potion will it drink?

Sora574
sonic102 wrote:For example, I have a green potion with the alias potion and a regular potion with the alias potion, which stacks into one. If I say 'drink potion', which potion will it drink?


Oh. This depends on a few things...
[list=1][*]If the potions have the same use, run the same script for both potions[/*:m]
[*]If the potions have different uses, the script of the one you picked up last will be used (this is a flaw that I'm working on)[/*:m]
[*]Lastly, if the green potion is a 'stack child' of the potion, or the other way around, it will run the 'stack parent' script.[/*:m][/list:o]

Does that make sense?

sonic102
Ah. I thought it would ask a question, "Which potion did you mean, the green potion or the regular potion?". But that would be hard to code.

Sora574
sonic102 wrote:Ah. I thought it would ask a question, "Which potion did you mean, the green potion or the regular potion?". But that would be hard to code.


I know not the meaning of the word 'hard'.

But yes, it is pretty hard. I'm working on a way to do it, though, so it's only a matter of time.

HegemonKhan
I simply meant that you can still have a bunch of different type of objects, thus the stacking won't help, as your inventory will still be cluttered, a storage will be needed if you got too many different types of items. The stacking is awesome, but I don't think there's any other way to deal with lots of different types of objects, other than with using some storage system for it.

potions (99)
keys (50)
arrows (70)
food (40)
silver_coins (30)
gold_coins (60)
herbs (20)
remedies (10)
rope (5)
seeds (80)
magic_walnuts (63)
cup_of_wishes (88)
candies (77)
chocolates (66)
statues (55)
ore (44)
lumber (33)
vespian_gas (22)
oil (11)
marble (82)
bombs (35)
magic_powder (69)
tinctures (42)
elixirs (71)
rocks (52)
etc

can you recognize what games any of (some) of these things are from? lol :D

------------------

"Ah. I thought it would ask a question, "Which potion did you mean, the green potion or the regular potion?". But that would be hard to code (Sonic)"

this wouldn't be that hard to code, really.

you just need some "If" checks, and then have it run the correct yes~no question based on those yes~no checks, and~or you can just have your objects with some attribute, which can be checked for.

like I had done with my storage system code between potions and elixirs though this was for proper storage object placement, a similar example though:

object name: elixir
attribute: string "elixir" or boolean "elixir = true" or integer "1" (1 = elixir)

object name: green_elixir
attribute: string "green" or boolean "green = true" or integer "2" (2 = green elixir)

sonic102
HegemonKhan wrote:I simply meant that you can still have a bunch of different type of objects, thus the stacking won't help, as your inventory will still be cluttered, a storage will be needed if you got too many different types of items. The stacking is awesome, but I don't think there's any other way to deal with lots of different types of objects, other than with using some storage system for it.

potions (99)
keys (50)
arrows (70)
food (40)
silver_coins (30)
gold_coins (60)
herbs (20)
remedies (10)
rope (5)
seeds (80)
magic_walnuts (63)
cup_of_wishes (88)
candies (77)
chocolates (66)
statues (55)
ore (44)
lumber (33)
vespian_gas (22)
oil (11)
marble (82)
bombs (35)
magic_powder (69)
tinctures (42)
elixirs (71)
rocks (52)
etc

can you recognize what games any of (some) of these things are from? lol


But that would be much better than:

potion
potion
potion
potion
potion
etc.

HegemonKhan
yep, I said the stackable library~coding is awesome, though I think most games would have lots of different types of items, which the stackable coding can't do anything about, as I don't think there's really any other way (no coding or even method) to deal with having too much stuff, other than storage, lol.

the only way it could be shortened is to put it horizontally, but still this may not be enough:

potions (99), keys (99), etc etc etc

or

potions, keys, etc (99/99/etc)

but a problem with this, is would you be able to see it and~or click on it, does the pane move the text to the next line, or is it off the pane and thus inexcessable and~or unviewable.

-------------

the stackable library~coding + a storage system is the best ;)

within the storage (objects), you've got the stackable library~coding for it, instead of using it for the inventory due to too much cluttering due to the sheer amount of different type of objects, that surely most games would be employing, hehe ;)

Sora574
HegemonKhan wrote:the stackable library~coding + a storage system is the best


The library already uses a storage system, of sorts.
It creates an empty object named
this.alias + "_container"
<!--In other words, potion_container"-->

Then, it moves everything into that.
However, making objects such as "green potion" and "red potion" all stackable into one simple "potion" container is possible...

I'm just having trouble doing it.

EDIT: I think I might just re-code the entire library altogether...

levicki
Sora574 wrote:

"sonic102"

Ah. I thought it would ask a question, "Which potion did you mean, the green potion or the regular potion?". But that would be hard to code.



I know not the meaning of the word 'hard'.

But yes, it is pretty hard. I'm working on a way to do it, though, so it's only a matter of time.



It would not be that hard, here is one way how it could be done (untested, off the top of my head):

value = what player typed after the verb (i.e. if they typed "drink potion" value will be "potion")
scope = ScopeInventory()
foreach (obj, scope) {
name = LCase(GetDisplayAlias(obj))
CompareNames (name, value, obj, fullmatches, partialmatches)
if (obj.alt <> null) {
foreach (altname, obj.alt) {
CompareNames (LCase(altname), value, obj, fullmatches, partialmatches)
}
}
}
if (ListCount(fullmatches) = 1) {
JustDrinkIt(ObjectListItem(fullmatches, 0))
}
else if (ListCount(fullmatches) = 0 and ListCount(partialmatches) > 0) {
menu = NewStringDictionary()
GenerateMenuChoices(menu, partialmatches)
ShowMenu ("Which potion do you want to drink?", menu) {
if (result = null) {
// handle menu cancel
}
else {
JustDrinkIt(GetObject(result))
}
}
}
else {
// todo: fail miserably
}


For more ideas look at ResolveNameInternal() function in CoreParser.aslx.

Sora574
@levicki: Thanks for the suggestion, but it seems like it's time for...

UPDATE 1.1 (BETA):
[list][*]Added support for different object aliases into one list...[/*:m]
[*]Which lead to this: Stackable objects are now either 'main' stackable objects or 'child' stackable objects... This is for many reasons. REMEMBER: The 'main' stackers are essentially the object that its 'child' objects revolve around (e.g. you need 1 and ONLY one 'main' stacker, and you can have as many 'children' as you want -- just change the settings)
**This does not mean that you have to be HOLDING the 'main' stacker. It can be anywhere as long as it's not deleted**[/*:m]
[*]You can name the stack (For example, if you have many different potion types, you could use 'potions' as the name)[/*:m]
[*]Each individual object in the stack can be used with separate scripts in the stack (you can also use another script for when you're not holding the object)[/*:m]
[*]You can now drop each individual object by using 'drop (stack name)', which will bring up a menu[/*:m]
[*]Functions are now available to use in scripts under the 'Objects' section (WARNING: Use container function is still under development -- it might not be useful most of the time)[/*:m]
[*]You can now limit stacks (only a certain number of objects in it)[/*:m][/list:u]

There's a few other things, but I'll let you figure them out yourself. If you need me to explain something else, just ask.

File is in the original post as 'StackLibraryBeta.aslx'.

--NEEDS SOME TESTING. I'M ACCEPTING SUGGESTIONS, AND ANY FEEDBACK YOU HAVE. PLEASE REPORT ANY PROBLEMS--

Sora574
UPDATE 1.11 (BETA):

[list][*]Fixed some minor issues[/*:m][/list:u]

File is in the main post.

HegemonKhan
excellent sora!, thanks for this library, another thing for me to study (and use too of course), to learn coding better, hehe :D

Sora574
HegemonKhan wrote:excellent sora!, thanks for this library, another thing for me to study (and use too of course), to learn coding better, hehe :D

No problem, just don't hurt yourself figuring it out lol

HegemonKhan
I figured out Pertex' Combat Library and made my own rough combat system based upon it, so I can probably understand yours eventually too, hehe.

I haven't worked yet with displaying of strings in the panes, as I've decided to move onto working with lists and dictionaries first, to understand how to use them more fully. I've been lazy though, and haven't been practicing~trying~testing doing code for awhile, as I'm also trying to slowly put together a massive rpg game or rather a "kit" (libraries and etc) for it, lol. As once I get all of that done, then it'll be easy (easier) to make games, once you have the base (or is it known as "source" ?) code for all of the elements, game design, and~or game mechanics in a game (like magic system, level up system, equipment system, storage system, dialogue~talk system, stealing~sneaking system, combat system, event system, npc~character system, and etc etc etc.

Sora574
Sounds interesting. I'm pretty much trying to create everything that my first game will include BEFORE I start it. Right now, I need an idea for something nobody has created that I can put into it... But I'm stuck.

HegemonKhan
Game Design and Game Mechanics, is just as bad as coding is for me, lol. I'm still learning coding, and on top of it, I got to try to brainstorm up what kind of game I want and the things in it (which of course means more coding), and then also trying to figure out the right Game Mechanics too, I think I spent like a few hours trying to get my combat equations to something I can at least use, lol. Figuring out the right Game Mechanic equations takes almost as much time as it does for me to code, sighs.

I'm working on a massive file for everything, and trying to organize it as best as I can (as I hate having multiple files, I get so confused, and it's a pain opening up files all the time, works better for me, if I can have all my stuff in a single file) ...

using notepad++, I'm already at:

Length: 41,488
Lines: 1,236

it took so long just to think up, "thought testing", and to create these (argh!):

(here's just a tiny part of my massive file)

<library>
<!-- My Own Notes -->

// final_melee_damage = sum_of_all_elemental_damage_types + final_physical_damage
// final_physical_damage = critical_hit * actual_physical_damage + actual_physical_damage * physical_damage_multiplier
// physical_damage_multiplier = (strength - endurance) / 100
// accuracy = dexterity - speed
// evasion = agility - speed
// piercing = attack_rating - armor_class
// parrying = dexterity - agility
// blocking = agility - dexterity
// actual_physical_damage = physical_damage - physical_resistance
// actual_fire_damage = fire_damage - fire_resistance
// actual_water_damage = water_damage - water_resistance
// actual_air_damage = air_damage - air_resistance
// actual_earth_damage = earth_damage - earth_resistance
// actual_light_damage = light_damage - light_resistance
// actual_dark_damage = dark_damage - dark_resistance
// actual_holy_damage = holy_damage - holy_resistance
// actual_unholy_damage = unholy_damage - unholy_resistance
// sum_of_all_elemental_damage_types = actual_fire_damage + actual_water_damage + actual_air_damage + actual_earth_damage + actual_light_damage + actual_dark_damage + actual_holy_damage + actual_unholy_damage
// battle_turn_initiative = speed vs speed
</library>


to organize, this is how I do it:

(excluded are all the various sub categories, like the types of functions, objects, and etc, to further organize things for me)

<library>
<!-- Game Libraries -->
<!-- Templates -->
<!-- Dynamic Templates -->
<!-- Verbs -->
<!-- Commands -->
<!-- Functions -->
<!-- Turnscripts -->
<!-- Types (Object Types) -->
<!-- Objects -->
<!-- Game Object -->
<!-- Player (POV) Objects -->
<!-- Room Objects -->
<!-- Item (Object) Objects -->
<!-- "Object Structures" or "Data Storage" (Objects) -->
<!-- Boolean Object Structures -->
<!-- Integer Object Structures -->
<!-- String Object Structures -->
<!-- Script Object Structures -->
<!-- Lists -->
<!-- String Lists -->
<!-- Object Lists -->
<!-- Dictionaries -->
<!-- String Dictionaries -->
<!-- Object Dictionaries -->
<!-- Script Dictionaries -->
<!-- Attributes -->
<!-- Boolean Attributes -->
<!-- Integer Attributes -->
<!-- String Attributes -->
<!-- Script Attributes -->
<!-- My Own Notes -->
</library>

Sora574
@HK sounds pretty cool.When you figure everything out, I can't wait to see your first game.

@Everyone:

UPDATE 1.1 IS NOW STABLE (ISH). CHECK THE ORIGINAL POST

HegemonKhan
My first game is along ways away, you'll be waiting quite a long while, lol.

I think I'm getting most of the coding understood, enough of it to code whatever I'll need, but the still huge massive problem is to code specifically for game creation, the "kit" (libraries and etc code) is still in it's uber early stages, I haven't done much of the bulk of the coding at all yet, as most of it first requires me to figure out all of my game mechanics, game design, and etc game stuff, and second of all, while I think I know enough coding to do whatever I want, it's still not easy nor quick for me to "adapt" it for what I want in my games, as part of my library. For example, even though there are a lot of libraries, I still have to craft my own libraries, tailored for what I want in my game. I think I have the ability and enough knowledge of coding to do all of this, but I'm still a noob and I code slowly, as it takes me awhile to figure out how to code something and then to trouble shoot all the mistakes I got in it as well, lol. For example, it'll just take me awhile to merge the equipment system with (preferably of somewhat my own, as I don't like to use other people's work as much as I can do so) a storage system and~or with your stackable(+storage) system, if I may do so ~ use your library (I'll likely use much of it's structure, but I'll try to write what of it as I can on my own. Similar to Pertex' Combat library, I used his structure, but I tried to create otherwise as much of my own combat system as I could do so, only looking or using parts of it, when I needed to, as I couldn't figure out how to do those parts on my own and~or couldn't create a different and better way, haha ~ that'll be the day I ain't a noob!, of coding it, lol). And that's just one aspect, there's still a magic system and all of the spells and etc of how I want to implement it into my game, a diplomacy (talking and hostility) system, stealth (thievery~stealing, sneaking, combat bonus, etc), a level up system (perks, abilities, spells maybe, stat points for increases to stats, and etc), all the races, classes, and their abilities, and "Flying", "Swimming", "Running", Fatigue, Encumbrance, and etc.

basically, I want to make games like the elder scroll games, as I think quest has that coding capability ~ quest's coding power, at a lesser scope obviously, as it's a text adventure game, and not a full blown game, like the elder scroll games, lol. So, if you played the elder scroll games, all of the game elements~systems that it has, is what I want eventually to have in~for my game making kit ~ library(ies), hehe.

Sora574
Well, remember HK, I can guarantee that for something like that, using someone else's libraries for everything might not work correctly (or, the way you want them to). This is probably obvious, but just throwing it out there.

ALSO:
New stackable library should be out tomorrow. Want a sneak peek?

Sora574
Little late here, sorry... But guess what?

UPDATE 1.2 TIEMZ

Check the main post for the update notes and to download the file.

Sorry about the whole 'enable stacking' thing... It just makes things run a lot smoother.

jnde011
Id be awsome if the ''If player is carrying object'' could have different amounts, also the if doesn't count the stack as the requested item

lightwriter
Does this still work? Someone recently refered this to me but I'm having trouble with custom verbs for the stackables... like I have a potions as a the main stack and have Drink as a verb and defined under Potions (I tried both but still get this error) and it says I can't drink them.
Where am I supposed to define the verb for the stackable if the one in the verbs tab isn't working..
Edit: I got it to somewhat work but when I use a potion it doesn't get moved like I coded it to. In other words if I try to move the object using this or removeobject function then it's still in my inventory

Tibe19k
Hello,

I just found this software a few days ago so I am still rather new to this. I have started to flesh out a game and I have created several houses and a street and I have stocked these items with shelves and so forth.

Now I want to stock the shelves with items. I must not be understanding the first post here because I do not have a "Stack" tab and when I go to turn on the script I don't have a "enable stackable" script.

I have read this forum page a few times and just get confused as to why it doesn't seem I can do what it on this page in the Quest program.

Any way somebody could give a step by step lay out of what to click and do to enable this stackable script or how do I get this Stack tab for a person who is not so great at understanding?

Thanks.

HegemonKhan
This is a library file (think of it as like a 'mod'~'xpac'~'add-on'~'patch' that simply adds more~extra~additional code into~for your game, in fact the entire quest engine is just a bunch of libraries, so it's very powerful~customizable for those who can program~code very well.

So, the GUI~Editor Tabs (Controls) that Sora's Library creates won't be seen in your GUI~Editor, until you add this library to it, your game file (in~as code), and your quest.exe's folder.

you got to have this file in the same folder as your quest.exe file, and then within your game code, you got to add the library code line:

'<include ref="~Sora's_Stackable_File's_name_whatever_it_is_or_whatever_you_rename_it_to" />'

unfortunately, Sora (and many others, sighs) have been MIA for a long time, so this library file of his~her hasn't been converted~upated to the new version's of quest and their new code formats~syntaxes, so this library file isn't useable unless you or someone converts~updates the code lines within it that need to be changed.

------

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

http://docs.textadventures.co.uk/quest/ ... aries.html
http://docs.textadventures.co.uk/quest/ ... aries.html

-----

Sora's Stackable Library is still a bit too advanced for me... I could try to see if I can update~convert it, but I fear I'd might mess it up too badly, so maybe we can get someone better at coding, who can fix up Sora's Stackable Library so it'll work again.

lightwriter
I'm working on a version of this for the latest version of Quest! :)
I'm, actually, making progress as well!

HegemonKhan
Awesome, thanks for trying to work on updating this library or making one of your own! This is a very useful subject for a lot of people (multiple item storage/handling). I think I speak for everyone, in saying thanks for working on this subject content.

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

Support

Forums