Author Topic: Placing your inventory descriptions in a text resource.  (Read 6802 times)

0 Members and 1 Guest are viewing this topic.

Offline Cloudee1

Placing your inventory descriptions in a text resource.
« on: January 30, 2007, 12:32:54 AM »
As your inventory item count grows, the list of instances at the bottom of the main script grows. every addition you make to the main script takes away from every other rooms memory allotment since it itself is used in every room. One way to minimize your impact on the main script and thereby your game overall, is to use text resources to hold all of your inventory items descriptions (and all other text strings but that's personal choice).

In order to do so, you must edit the main script. Remember whenever you edit the main script, you must compile all scripts, both editors have a button just for this. In the main script a hair passed halfway you will find the class Iitem of InvI. the showself method is basicly just creating the print tag
Code: [Select]
  (method (showSelf)
    Print( description
             #title objectName
             #icon view loop cel // you did make this bug update right
In order to change the description from the string we are setting it in each item's instance, we want to display the text resource instead so for that we need two numbers. As you may know when printing from a text resource like say number 54 line 23 you would use Print(54 23). So for us to do the same here, we need to pick a text resource to use which all inventory item descriptions will be placed in and I don't see any reasons not to use 0. So we just change the first line of the print statement to read
Code: [Select]
Print(0 description
Now that that is done, we need to address the description found in each inventory items instance. By default we used "long text strings" but now that the first thing in the print statement is a number, the second thing better be too or something is going to break. The best part is that now the description in each instance simply needs to equal the line it is found on in text resource 0. So they should all look something like this.
Code: [Select]
(instance {Test Object} of Iitem
said 'object'
description 10
owner 0
view 800
loop 0
cel 0
script 0
Besides making editing them easier since you won't have to recompile all the scripts just for adding a comma, your heap space will last out that much longer for not having preloaded all that miscellaneous junk in there in every room to begin with.
« Last Edit: January 30, 2007, 12:35:12 AM by Cloudee1 »

Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline NilG

Re: Placing your inventory descriptions in a text resource.
« Reply #1 on: March 29, 2019, 08:00:11 PM »
I hope zombie threads are okay here; if not, let me know, I won't do it again.  I just wanted to say this is great.  I had a room down to 312 Bytes free, and had heap crashes when I initialized a small window showing the inside of a box.  Managed to bump it to 1040 by changing some things I'd set as Props to Views and what code condensing I could, then tried this.  This alone (on 30 inv items) sent me up to 4598 free, which should be more than enough now, so it really saved the day.  Just wanted to say thanks.

SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.037 seconds with 22 queries.