AGS tidbits & snippets: Difference between revisions

m
Removed <pre> tags
(Removed version history (now on AGS about page))
m (Removed <pre> tags)
Line 32: Line 32:
You can create this association manually if you like, just set up .AGSGame files so that their association is:
You can create this association manually if you like, just set up .AGSGame files so that their association is:


<pre>c:\path\to\ags\agsedit.exe -shelllaunch "%1"</pre>
c:\path\to\ags\agsedit.exe -shelllaunch "%1"


([http://www.bigbluecup.com/yabb/index.php?topic=12051.msg166879#msg166879 Thread])
([http://www.bigbluecup.com/yabb/index.php?topic=12051.msg166879#msg166879 Thread])
Line 116: Line 116:
----
----
'''CJ''': "The workaround for '''displaying player-entered strings''', in case anyone wants to know, is simply to do this:
'''CJ''': "The workaround for '''displaying player-entered strings''', in case anyone wants to know, is simply to do this:
<pre>Display("%s", playerString);</pre>
Display("%s", playerString);
since that way, the player string will not be parsed for special tokens."
since that way, the player string will not be parsed for special tokens."
([http://www.bigbluecup.com/yabb/index.php?topic=12051.msg157449#msg157449 Thread])
([http://www.bigbluecup.com/yabb/index.php?topic=12051.msg157449#msg157449 Thread])
Line 129: Line 129:
----
----
'''CJ''': "It's
'''CJ''': "It's
<pre>protected import static function get_slots();</pre>
protected import static function get_slots();
Basically, to be consistent with Java/C#, '''the protection level always goes first'''."
Basically, to be consistent with Java/C#, '''the protection level always goes first'''."
([http://www.bigbluecup.com/yabb/index.php?topic=19369.msg226163#msg226163 Thread])
([http://www.bigbluecup.com/yabb/index.php?topic=19369.msg226163#msg226163 Thread])
Line 150: Line 150:
----
----
'''CJ''': "The '''number of game loops [speech text] stays for''' is:
'''CJ''': "The '''number of game loops [speech text] stays for''' is:
<pre>int gameloops = ((StrLen(text) / game.text_speed) + 1) * GetGameSpeed();</pre>
int gameloops = ((StrLen(text) / game.text_speed) + 1) * GetGameSpeed();
([http://www.bigbluecup.com/yabb/index.php?topic=14364.msg174988#msg174988 Thread])
([http://www.bigbluecup.com/yabb/index.php?topic=14364.msg174988#msg174988 Thread])
----
----
Line 159: Line 159:
([http://www.bigbluecup.com/yabb/index.php?topic=13300.msg160466#msg160466 Thread])
([http://www.bigbluecup.com/yabb/index.php?topic=13300.msg160466#msg160466 Thread])
:''Meaning, unlike strings, you can do''
:''Meaning, unlike strings, you can do''
<pre>
char tmpchar = 'A';
char tmpchar = 'A';
tmpchar += 2; // will make tmpchar into 'C'
tmpchar += 2; // will make tmpchar into 'C'
</pre>
----
----
'''RickJ''': "A '''variable declaration in the header''' will cause a :''seperate'' [static] variable (...) for each room."
'''RickJ''': "A '''variable declaration in the header''' will cause a :''seperate'' [static] variable (...) for each room."
Line 170: Line 168:
([http://www.bigbluecup.com/yabb/index.php?topic=12418.msg147974#msg147974 Thread])
([http://www.bigbluecup.com/yabb/index.php?topic=12418.msg147974#msg147974 Thread])
:''I think it's 200, the AGS maximum string length:''
:''I think it's 200, the AGS maximum string length:''
<pre>
struct myStruct {
struct myStruct {
  char mystring [200];
  char mystring [200];
};
};
</pre>
:''Since you can't make arrays from string variables, you can make it from such a struct instead.''
:''Since you can't make arrays from string variables, you can make it from such a struct instead.''
----
----
'''Scorpiorus''':
'''Scorpiorus''':
<pre>cJack.Say("The new code is %04d", GetGlobalInt(99));</pre>
cJack.Say("The new code is %04d", GetGlobalInt(99));
(...) will '''add leading zeros''' (up to 4) if necessary."
(...) will '''add leading zeros''' (up to 4) if necessary."
:''Here are more format flags:''
:''Here are more format flags:''
<pre>
// (number) = Create a field (number) characters wide:
Display("Here comes %4d a test", 22); //=&gt; Here comes &nbsp;&nbsp;22 a test


// - = Left justify:
// (number) = Create a field (number) characters wide:
Display("Here comes %-4d a test", 22); //=&gt; Here comes 22&nbsp;&nbsp; a test
Display("Here comes %4d a test", 22); //=&gt; Here comes &nbsp;&nbsp;22 a test


// 0 = Field is padded with 0's instead of blanks:
// - = Left justify:
Display("Here comes %04d a test", 22); //=&gt; Here comes 0022 a test
Display("Here comes %-4d a test", 22); //=&gt; Here comes 22&nbsp;&nbsp; a test


// + = Sign of number always shown:
// 0 = Field is padded with 0's instead of blanks:
Display("Here comes %+d a test", 22); //=&gt; Here comes +22 a test
Display("Here comes %04d a test", 22); //=&gt; Here comes 0022 a test


// (blank) = Positive values begin with a blank:
// + = Sign of number always shown:
Display("Here comes % d a test", 22); //=&gt; Here comes &nbsp;22 a test
Display("Here comes %+d a test", 22); //=&gt; Here comes +22 a test
</pre>
 
// (blank) = Positive values begin with a blank:
Display("Here comes % d a test", 22); //=&gt; Here comes &nbsp;22 a test
----
----
'''RickJ''': "The character's '''global inventory variables are integers''' and can be used to keep track of how many items the character has."
'''RickJ''': "The character's '''global inventory variables are integers''' and can be used to keep track of how many items the character has."
Line 218: Line 213:
:'' Similarly, Character.AddInventory increases the quantity by one each time it's used.
:'' Similarly, Character.AddInventory increases the quantity by one each time it's used.
So better use''
So better use''
<pre>if (player.InventoryQuantity[iCoin.ID]) { // if player has one OR MORE of inv item iCoin</pre>
if (player.InventoryQuantity[iCoin.ID]) { // if player has one OR MORE of inv item iCoin
:''instead of''
:''instead of''
<pre>if (player.InventoryQuantity[iCoin.ID] == 1) { // if player has EXACTLY one inv item iCoin</pre>
if (player.InventoryQuantity[iCoin.ID] == 1) { // if player has EXACTLY one inv item iCoin
----
----
'''CJ''': "There is an undocumented Character.on variable, which is normally 1, but you can set it to 0 to '''make the character invisible'''."
'''CJ''': "There is an undocumented Character.on variable, which is normally 1, but you can set it to 0 to '''make the character invisible'''."
Line 266: Line 261:
----
----
Character to '''mask % symbol in strings''': %
Character to '''mask % symbol in strings''': %
<pre>Display("The %% is the percent symbol.");</pre>
Display("The %% is the percent symbol.");


Character to '''mask quotemarks in strings''': \
Character to '''mask quotemarks in strings''': \
<pre>Display("The \" is a quotemark.");</pre>
Display("The \" is a quotemark.");


Character for '''line breaks in strings''': [
Character for '''line breaks in strings''': [
<pre>Display("The [ is a line break.");</pre>
Display("The [ is a line break.");


Character to '''mask [ in strings''': \
Character to '''mask [ in strings''': \
<pre>Display("The \[ is a left brace.");</pre>
Display("The \[ is a left brace.");
----
----


0

edits