CAOS-Programmierung: Befehlsgruppen: Resources

Resources

NET: MAKE (integer) which_journal_spot (integer) journal_name (string) user (string) report_destination (variable)

Like PRAY MAKE, only sends the made pray file to the specified user. This will arrive in their inbox, where it can be read with normal PRAY commands 
and deleted with PRAY KILL.

PRAY AGTI (integer) resource_name (string) integer_tag (string) default_value (integer)

This returns the value of the integer tag associated with the named resource. If the resource does not contain such a tag, then the default value 
specified is returned. This call pairs with PRAY AGTS.

PRAY AGTS (string) resource_name (string) string_tag (string) default_value (string)

This returns the value of the string tag associated with the named resource. If the resource does not contain such a tag, then the default value  
specified is returned. This call pairs with PRAY AGTI.

PRAY BACK (string) resource_type (string) last_known (string)

Like PRAY PREV, only doesn't loop at the end. If you go beyond the first entry then it returns an empty string.

PRAY COUN (integer) resource_type (string)

This returns the number of resource chunks which are tagged with the resource type passed in. Resource types are four characters only. Anything over 
that length will be silently truncated.

PRAY DEPS (integer) resource_name (string) do_install (integer)

This performs a scan of the specified resource, and checks out the dependency data. The primary use for this would be in the preparation for 
injection  of agents. If you pass zero in the do_install parameter, then the dependencies are only checked. If do_install is non-zero, then they are 
installed also. The return values are as follows:
0 = Success
-1 = Agent Type not found
-2 = Dependency Count not found
-3 to -(2 + count) is the dependency string missing
-(3+count) to -(2+2*count) is the dependency type missing
2*count to 3*count is the category ID for that dependency being invalid
1 to count is the dependency failing

PRAY EXPO (integer) chunk_type (string)

This function exports the target creature. If the creature is exported successfully then it has been removed from the world. Returns value is one of  
the following:
0 for success
1 if the creature, or if pregnant any of its offspring, are already on disk in some form.
The chunk type should be used to find the creature again to import it. In Creatures 3, most exported creatures have a chunk type EXPC, and the 
starter  family uses SFAM.
For new games, you should not use SFAM, as its data would get confused with that of an EXPC with the same moniker. This is for backwards compatibility 
with Creatures 3's use of SFAM, which works because the CAOS code guarantees different monikers.
For other chunk names, creatures exported with a different type are kept entirely separately, and will not get confused with each other. The chunk 
type is added to the end of the moniker to form the chunk name.
The exported creature has some fields associated with it, that can be read by PRAY AGTI or PRAY AGTS before importing:
"Exported At World Time" integer
"Creature Age In Ticks" integer
"Exported At Real Time" integer
"Creature Life Stage" integer
"Exported From World Name" string
"Exported From World UID" string
"Native Network User" string
"Last Network User" (could be faked, NET: FROM is safer) string
"Creature Name" string
"Gender" integer
"Genus" integer
"Variant" integer
"Head Gallery" string (this is calculated on the sending computer, so the file may be missing on the receiving one - try LIMB instead)
"Pregnancy Status" integer
In addition you can add custom fields by setting NAME variables on the Creature before export. Any strings or integers whose name begin "Pray Extra "  
are added as entries to the export file.

PRAY FILE (integer) resource_name (string) resource_type (integer) do_install (integer)

This performs the "installation" of one file from the resource files. The resource_type is defined in the agent resource guide. If do_install is zero, 
the command simply checks if the file install should succeed. Return value is 0 for success, 1 for error.

PRAY FORE (string) resource_type (string) last_known (string)

Like PRAY NEXT, only doesn't loop at the end. If you go beyond the last entry then it returns an empty string.

PRAY GARB (command) force (integer)

This command clears the manager's cached resource data. Execute this after a lot of resource accesses (E.g. installing an agent) to clean up the 
memory used during the process. If you don't do this, excess memory can be held for a while, If the parameter is zero (the most usual) then the  
manager will only forget resources which are not in use at the moment. If force is non-zero, then the manager will forget all the previously loaded 
resources. As the resources currently in use go out of scope, they are automatically garbage collected.

PRAY IMPO (integer) moniker_chunk (string) actually_do_it (integer) keep_file (integer)

This function imports the creature with the requested moniker and chunk type. Returns one of the following codes:
0 - success
1 - couldn't reconcile histories so creature was cloned
2 - moniker not found in PRAY system
3 - unused error code
4 - internal / file format error
Set actually_do_it to 1 to try and perform the import, or 0 to perform a query giving just the return value. You can use the query to test if the 
creature is available, and if the creature would have to be cloned upon importing, and warn the user. The new creature is TARGetted after import. If 
you set keep file to 1, then the exported file won't be deleted (moved to the porch). The creature will appear in the same place that it was exported, 
but as with NEW: CREA, it will be in limbo, and won't function until moved to a valid place.

PRAY INJT (integer) resource_name (string) do_install (integer) report_var (variable)

This command injects an agent. The agent must be in the chunk named. If do_install is zero, the command simply checks for the presence of the required 
scripts and dependencies. If non-zero, it attempts to inject the agent. The report var is a string variable, and is set to the name of the offending 
script if the injection/check fails.
Return is 0 for success, -1 for "Script not found" and if injecting, -2 for "Injection failed".
Return value -3 indicates that a dependency evaluation failed, and in this case, the report var is the return code from PRAY DEPS

PRAY KILL (integer) resource_name (string)

Deletes the resource file which contains the specified chunk. This is permanent and irreversible. Returns 1 if there was such a chunk and file, or 0 
if there wasn't.

PRAY MAKE (integer) which_journal_spot (integer) journal_name (string) which_pray_spot (integer) pray_name (string) report_destination (variable)

Please see the documentation accompanying the praybuilder on CDN
Suffice it to say: return value is zero for success, otherwise non-zero, and report is set to the praybuilder output for you
Also, the which_journal_spot is zero for world journal, 1 for global journal. Also the which_pray_spot is zero for "My Agents" and 1 for "My Creatures"

PRAY NEXT (string) resource_type (string) last_known (string)

This returns the name of the resource chunk directly after the named one, given that they are of the same type. It loops when it reaches the end. If 
the named resource cannot be found in the list of resources of the type specified, then the last resource of that type is returned. This call pairs 
with PRAY PREV. Compare PRAY FORE.

PRAY PREV (string) resource_type (string) last_known (string)

This returns the name of the resource chunk directly before the named one, given that they are of the same type. It loops when it reaches the end. If 
the named resource cannot be found in the list of resources of the type specified, then the first resource of that type is returned. This call pairs 
with PRAY NEXT. Compare PRAY BACK.

PRAY REFR (command)

This command refreshes the engine's view of the Resource directory. Execute this if you have reason to believe that the files in the directory may 
have changed. It only detects changes if there is a new file or a deleted file - if a file has only changed it won't notice. This is awkward during 
development, you can use PRAY KILL to kill the old file before copying the new one over. PRAY REFR forces a PRAY GARB to happen automatically.

PRAY TEST (integer) resource_name (string)

This checks for the existence of a chunk, returning zero if it is not found, and a value from 1-3 indicating the cost to load if it is.
Return values are currently defined as:
0 - Chunk not available at this time
1 - Chunk Available, Cached and ready for use
2 - Chunk available, on disk uncompressed and fine for loading
3 - Chunk available, on disk compressed and ready for loading.

Thus the return value could be thought of as the cost of loading, where 1 is no cost, and 3 is high cost.