well if you're a programmer, there's absolutely nothing fancy about the code for my storage code for learned spells, as I'm not a programmer (wish I was, sighs. I'm old now, wish I would've been learning it from when I was little, as it's quite a bit late now).
Also... my code is really horrible, messy, and "long winded". For me, just getting a functioning code is a huge achievement for me, as later on, I can go back and try to make the code better (simple, short, clear, efficient; "streamlined"). So, my apologizes for my unbearably noobishly poor codings.
it basically involves making a lot of child objects within a parent object, so your inventory isn't cluttered and also so you can organize them (I don't know how to or if it could be done otherwise), with the actual placement of where the (spell objects) go.
It could have been just as easy to make the main storage object not have a parent too, but I decided to just go and put it as a child of the player object. (well, maybe there might be some coding difficulties in trying to do this, but I think it could be done)
storage object type -> immoveable (take, drop, use, give, etc = false) closed container. immoveable book-like objects within immoveable book-like objects, lol.
player object
-> storage object
->-> spell storage object
->->-> fire spells storage object
->->-> etc etc etc
->-> equipment storage object
->->-> weapons storage object
->->->-> sword storage object
->->->-> etc etc etc
->->-> armors storage object
->->->-> shield storage object
->->->-> headwear storage object
->->->-> etc etc etc
->->-> clothing storage object
->->->-> fingerwear (for ring wearing) storage object
->->->-> etc etc etc
->-> items storage object
->->-> useable items storage object
->->-> non-useable (game progression items) items storage object
->->-> battle items storage object
then it is a matter of making the code to place your stuff into the correct places.
(so far, I only got the spells done, as I'm still trying to figure out and work on with the equipment)
so here's my storage codings:
> it's done as a library file (but this can be easily changed or copy and pasted directly into your game file or a new game file too, if you don't want to use it as an added library file to your game file or new game file)
> I copy and pasted this over from one file into a new file, as I didn't have a file just for my storage coding, so if it doesn't work, let me know, as I probably am missing something that is needed that I didn't include in my pasting of it over to the new file, lol.
> this is just for the spell storage system, as I'm still working on how to do the equipment (it's messy as I'm doing more brainstorming of how I want to do it, so I haven't ~ can't ~ yet work on how to do its coding yet).
> I used Pixie's Spell Library coding structure, so this stuff is all his~hers - the credit goes to him~her, for making my spell storage of Pixie's learned spells.
<?xml version="1.0"?>
<library>
<!-- Templates -->
<!-- Spell Templates -->
<template name="Learn">learn</template>
<template name="Cast">cast</template>
<template name="Teach">teach</template>
<template name="Spell_Already_Learned">Oops, you already know this spell.</template>
<dynamictemplate name="Spell_Learned">"You've learned the " + GetDisplayAlias(object) + " spell."</dynamictemplate>
<!-- Verbs -->
<!-- Spell Verbs -->
<verb>
<property>learn</property>
<pattern>learn</pattern>
<defaultexpression>"You can't learn " + object.article +"."</defaultexpression>
</verb>
<verb>
<property>cast</property>
<pattern>cast</pattern>
<defaultexpression>"You can't cast " + object.article +"."</defaultexpression>
</verb>
<verb>
<property>teach</property>
<pattern>teach</pattern>
<defaultexpression>"You can't teach " + object.article +"."</defaultexpression>
</verb>
<!-- Objects -->
<!-- Structure Objects -->
<object name="elemental_structure">
<normal_elemental type="list">fire; water; air; earth; light; dark; holy; unholy</normal_elemental>
<nemesis_elemental type="stringdictionary">fire = water;water = fire;air = earth;earth = air;light = dark;dark = light;holy = unholy;unholy = holy</nemesis_elemental>
</object>
<!-- Storage Objects -->
<object name="storage">
<inherit name="storage_type" />
<parent type="object">player</parent>
<!-- Spell Storage Objects -->
<object name="spell_storage">
<inherit name="storage_type" />
<parent type="object">storage</parent>
<object name="fire_storage">
<inherit name="storage_type" />
<parent type="object">spell_storage</parent>
</object>
<object name="water_storage">
<inherit name="storage_type" />
<parent type="object">spell_storage</parent>
</object>
<object name="air_storage">
<inherit name="storage_type" />
<parent type="object">spell_storage</parent>
</object>
<object name="earth_storage">
<inherit name="storage_type" />
<parent type="object">spell_storage</parent>
</object>
<object name="light_storage">
<inherit name="storage_type" />
<parent type="object">spell_storage</parent>
</object>
<object name="dark_storage">
<inherit name="storage_type" />
<parent type="object">spell_storage</parent>
</object>
<object name="holy_storage">
<inherit name="storage_type" />
<parent type="object">spell_storage</parent>
</object>
<object name="unholy_storage">
<inherit name="storage_type" />
<parent type="object">spell_storage</parent>
</object>
</object>
</object>
<!-- Types (Object Types) -->
<!-- Storage Types (Object Types) -->
<type name="storage_type">
<inherit name="container_closed" />
<drop type="boolean">false</drop>
<inventoryverbs type="list">Look; Open; Close</inventoryverbs>
</type>
<!-- Spell Types (Object Types) -->
<type name="spell">
<drop type="boolean">false</drop>
<mana_points_cost type="int">0</mana_points_cost>
<inventoryverbs type="list">Learn</inventoryverbs>
<displayverbs type="list">Learn</displayverbs>
<learn type="script">
result = get_elemental (this)
switch (result) {
case ("fire") {
if (not this.parent = fire_storage) {
this.parent = fire_storage
this.inventoryverbs = split ("Cast;Teach",";")
msg (DynamicTemplate ("Spell_Learned",this))
}
else {
msg ("[Spell_Already_Learned]")
}
}
case ("water") {
if (not this.parent = water_storage) {
this.parent = water_storage
this.inventoryverbs = split ("Cast;Teach",";")
msg (DynamicTemplate ("Spell_Learned",this))
}
else {
msg ("[Spell_Already_Learned]")
}
}
case ("air") {
if (not this.parent = air_storage) {
this.parent = air_storage
this.inventoryverbs = split ("Cast;Teach",";")
msg (DynamicTemplate ("Spell_Learned",this))
}
else {
msg ("[Spell_Already_Learned]")
}
}
case ("earth") {
if (not this.parent = earth_storage) {
this.parent = earth_storage
this.inventoryverbs = split ("Cast;Teach",";")
msg (DynamicTemplate ("Spell_Learned",this))
}
else {
msg ("[Spell_Already_Learned]")
}
}
case ("light") {
if (not this.parent = light_storage) {
this.parent = light_storage
this.inventoryverbs = split ("Cast;Teach",";")
msg (DynamicTemplate ("Spell_Learned",this))
}
else {
msg ("[Spell_Already_Learned]")
}
}
case ("dark") {
if (not this.parent = dark_storage) {
this.parent = dark_storage
this.inventoryverbs = split ("Cast;Teach",";")
msg (DynamicTemplate ("Spell_Learned",this))
}
else {
msg ("[Spell_Already_Learned]")
}
}
case ("holy") {
if (not this.parent = holy_storage) {
this.parent = holy_storage
this.inventoryverbs = split ("Cast;Teach",";")
msg (DynamicTemplate ("Spell_Learned",this))
}
else {
msg ("[Spell_Already_Learned]")
}
}
case ("unholy") {
if (not this.parent = unholy_storage) {
this.parent = unholy_storage
this.inventoryverbs = split ("Cast;Teach",";")
msg (DynamicTemplate ("Spell_Learned",this))
}
else {
msg ("[Spell_Already_Learned]")
}
}
}
</learn>
</type>
<type name="fire_elemental" />
<type name="water_elemental" />
<type name="air_elemental" />
<type name="earth_elemental" />
<type name="light_elemental" />
<type name="dark_elemental" />
<type name="holy_elemental" />
<type name="unholy_elemental" />
<!-- Functions -->
<function name="get_elemental" parameters="obj" type="string">
result = null
foreach (elem, elemental_structure.normal_elemental) {
type = elem + "_elemental"
if (DoesInherit (obj,type)) {
result = elem
}
}
return (result)
</function>
</library>
--------
P.S.
really the only code you're interested in for what you want to do, would be this (unless you can't work directly the inventory pane with the codings):
for what you want to do, it'll obviously be a bit different, and either with more or less complex coding, as you got to figure out how to code with the inventory display titles (if this can be done, I think it can anyways). so, this code below isn't too useful, except as a very loose coding method, and you've got other things you got to code in beyond just "Get_Whatever", hehe.
<function name="get_elemental" parameters="obj" type="string">
result = null
foreach (elem, elemental_structure.normal_elemental) {
type = elem + "_elemental"
if (DoesInherit (obj,type)) {
result = elem
}
}
return (result)
</function>
as I think you'll have to (in my noob attempt at guessing how to code it, lol):
need a way of "checking and getting" a list of the items in your inventory, so that you can then identify the "worm" items, and then figure out how to count them, and then substitute all of the worm items for: a single worm item with it's amount of them (or if you're going to have worms with different attributes, then multiple single worm items of those different worm types, and with it doing the same of removing them and adding in the right number onto the right single worm type name).
i.e.
player.inventory:
worm_type_1 (heals 25 HP)
worm_type_1 (heals 25 HP)
worm_type_2 (heals 50 HP)
worm_type_2 (heals 50 HP)
worm_type_2 (heals 50 HP)
worm_type_3 (heals 100 HP)
worm_type_3 (heals 100 HP)
worm_type_3 (heals 100 HP)
worm_type_3 (heals 100 HP)
~TO~
player.inventory:
worm_type_1 (x2)
worm_type_2 (x3)
worm_type_3 (x4)
then you got to code in when you eat a worm, to adjust the amount shown (and if you eat the last one, it then disappears from your inventory, lol)