Difference between revisions of "Load.view"

From AGI Wiki
Jump to navigationJump to search
 
(10 intermediate revisions by one other user not shown)
Line 1: Line 1:
The load.view and load.view.v commands load a [[View Resource|view resource]] into memory. A view must be loaded before it can be assigned to any [[Object|objects]] or used in any command such as [[add.to.pic]] ('''note:''' a view does not have to be loaded before the [[show.obj]] command is used).
+
The '''load.view''' command loads a [[view]] resource onto the [[memory heap]].
  
<code>
+
== Syntax ==
load.view([[number]] viewNumber);
 
  
load.view.v([[variable]] viewNumber);
+
load.view([[number|byt]] VIEWNUM);
</code>
 
  
The view <code>viewNumber</code> is loaded into memory.
+
== Remarks ==
  
== Parameters ==
+
This command loads [[view]] '''VIEWNUM''' onto the [[memory heap]]. [[View]] resources must be loaded before being used in any other commands. If a view is not loaded before being used in commands, AGI will generate one of several [[trappable errors]]. [[View|Views]] should be unloaded using the '''[[discard.view]]''' or '''[[discard.view.v]]''' command once they are no longer needed.
  
For <code>load.view</code>:
+
AGI adds a script entry to the [[script stack]] each time a [[view]] resource is loaded.
  
* <code>viewNumber</code>: a [[number]], 0-255, specifying the view that should be loaded
+
== Possible Errors ==
  
For the indirect version, <code>load.view.v</code>:
+
If you attempt to load a [[view]] that does not exist, AGI will raise a [[runtime error]] and crash.
 
 
* <code>viewNumber</code>: a [[variable]], v0-v255, whose value specifies the view that should be loaded
 
 
 
== Possible errors ==
 
 
 
* The view must exist in the game's [[VOL File|vol files]], or the game will crash with a [[View Not Found Error|view not found error]].
 
* There must be sufficient memory to load the entire view resource into memory, or the game will crash with an [[Out of Memory Error|out of memory error]].
 
* If the view resource is already loaded, it is not loaded a second time, nor is the [[Script Buffer|script buffer]] affected. If the view is [[discard.view|discarded]] and then loaded again, it will of course be loaded a second time; however, this adds to the [[Script Buffer|script buffer]].
 
  
 
== Example ==
 
== Example ==
  
The following code loads VIEW.025 into memory using <code>load.view</code>:
+
<div class="CodeBlockHeader">Code:</div>
 
+
<syntaxhighlight lang="agi">
<code>load.view(25);</code>
+
[ typical code to assign a view to an object
 
+
[ assume there is a view with ResourceID of 'Armor'
The following code uses the [[Indirect Command|indirect command]] <code>load.view.v</code> to do the same thing:
+
#define o1 Guard;
 
+
animate.obj(Guard);       [ initialize the Guard object
<code>v195 = 25;
+
load.view(Armour);       [ load the view with the guard in armor
load.view.v(v195);</code>
+
set.view(Guard, Armour);  [ assign the view
 
+
draw(Guard);              [ and then draw the object on screen
== See also ==
+
</syntaxhighlight>
 
 
* [[discard.view]]
 
* [[set.view ]]
 
  
== Sources ==
+
== Technical Information ==
  
Some of the text in this article is taken from the [[AGI Studio]] help file.
+
{| border="1" cellpadding="2"
 +
| style="background-color: #efefef" width="200" | '''Required Interpreter Version:'''
 +
| width="175" | Available in all AGI versions.
 +
|-
 +
| style="background-color: #efefef" | '''Byte-Code Value:'''
 +
| 30 (0x1E hex)
 +
|}
  
&nbsp;
+
== See Also ==
  
[[Category:Logic Commands]]
+
[[Screen Object/View Commands]]<br />
[[Category:Object and View Commands]]
+
'''[[load.view.v]]'''<br />
 +
[[Memory Management]]<br />
 +
[[AGI Scripts]]<br />
 +
[[Category:Commands]]<br />

Latest revision as of 21:16, 10 April 2019

The load.view command loads a view resource onto the memory heap.

Syntax

load.view(byt VIEWNUM);

Remarks

This command loads view VIEWNUM onto the memory heap. View resources must be loaded before being used in any other commands. If a view is not loaded before being used in commands, AGI will generate one of several trappable errors. Views should be unloaded using the discard.view or discard.view.v command once they are no longer needed.

AGI adds a script entry to the script stack each time a view resource is loaded.

Possible Errors

If you attempt to load a view that does not exist, AGI will raise a runtime error and crash.

Example

Code:

<syntaxhighlight lang="agi"> [ typical code to assign a view to an object [ assume there is a view with ResourceID of 'Armor'

  1. define o1 Guard;

animate.obj(Guard); [ initialize the Guard object load.view(Armour); [ load the view with the guard in armor set.view(Guard, Armour); [ assign the view draw(Guard); [ and then draw the object on screen </syntaxhighlight>

Technical Information

Required Interpreter Version: Available in all AGI versions.
Byte-Code Value: 30 (0x1E hex)

See Also

Screen Object/View Commands
load.view.v
Memory Management
AGI Scripts