Tips, tricks and info

Find detailed help from the AAO community, or write your own tutorials.

Moderator: EN - Forum Moderators

User avatar
Wolf Speaker
Posts: 2398
Joined: Sat Jan 28, 2012 9:32 pm
Gender: Female
Spoken languages: English, French, Chinese
Location: Canada

Re: Tips, tricks and info

Post by Wolf Speaker »

Thanks. c:

--------

Legit double post? Not sure if this goes here, but how do I get the links used for custom sprites and backgrounds from the editor? I mean, if you have access to another member's trial and you need one of the sprites they use, how do you get it?
Image
Shuìlián - Lv.9
Adaptability

- Helping Hand
- Growl
- Tackle
- Tail Whip
- Sand-Attack
- Baby-Doll Eyes

Image
Mr. Darcy - Lv.8
Pick Up

- Odor Sleuth
- Tackle
- Growl
- Defense Curl
- Flail

Allistair - Lv.9
- Tackle
- Dragon Rage
- Focus Energy
- Bite
User avatar
DWaM
Posts: 1763
Joined: Fri Jun 01, 2012 9:23 am
Gender: Male
Spoken languages: English
Location: The Kingdom of Ellipses

Re: Tips, tricks and info

Post by DWaM »

Pretty sure you can just Right Click -> View Picture on the preview (The window on the left side). :P
User avatar
Wolf Speaker
Posts: 2398
Joined: Sat Jan 28, 2012 9:32 pm
Gender: Female
Spoken languages: English, French, Chinese
Location: Canada

Re: Tips, tricks and info

Post by Wolf Speaker »

Oh, thanks!
Image
Shuìlián - Lv.9
Adaptability

- Helping Hand
- Growl
- Tackle
- Tail Whip
- Sand-Attack
- Baby-Doll Eyes

Image
Mr. Darcy - Lv.8
Pick Up

- Odor Sleuth
- Tackle
- Growl
- Defense Curl
- Flail

Allistair - Lv.9
- Tackle
- Dragon Rage
- Focus Energy
- Bite
Broocevelt
Moderator
Posts: 7319
Joined: Fri Sep 11, 2009 6:06 pm
Gender: Female
Spoken languages: ES/FR/EN/DE
Location: Spain
Contact:

Re: Tips, tricks and info

Post by Broocevelt »

Tip: Centering text in AAO

There is no proper way to 'center' text in the editor. However you can manually center it.
First, write your text line by line (using the Enter button if there is more than one line).
Then, with your cursor at the beginning of each line, press Alt+255 (Hold the left Alt key, then press in order 2 5 5 on your numpad.) Yes, that is an empty character, but it has another ASCII slot assigned, so it won't be recognized as a regular space, and therefore won't be deleted when the editor detects a group of 1+ spaces together.

Now, use the character at the beginning of each line as much times as necessary to make the text look centered. When you finish writing your frame, the spaces should remain there, and your text should be centered.
EDIT: Apparently the AAO forums DO change these characters. THANK YOU D:< I will try to find a way to put it here.

EDIT2: Edited with the proper keyboard combination!
User avatar
E.D.Revolution
Posts: 5743
Joined: Mon Jul 26, 2010 9:00 pm
Gender: Male
Spoken languages: English and decent Spanish
Location: Across dimensions, transcending universes

Re: Tips, tricks and info

Post by E.D.Revolution »

Alt 255 won't work if the user doesn't have a number keypad. Do you have an alternate?
Image
Broocevelt
Moderator
Posts: 7319
Joined: Fri Sep 11, 2009 6:06 pm
Gender: Female
Spoken languages: ES/FR/EN/DE
Location: Spain
Contact:

Re: Tips, tricks and info

Post by Broocevelt »

I'm afraid I haven't :? . Pressing Alt+255 several times works, pressing it once and copying doesn't, so the copy function overrides the nature of the character, and I don't know of any other way to input said character.
User avatar
Unas
Admin / Site programmer
Posts: 8850
Joined: Tue Jul 10, 2007 4:43 pm
Gender: Male
Spoken languages: Français, English, Español
Contact:

Re: Tips, tricks and info

Post by Unas »

I wouldn't recommend using too many special characters on V5. It's supposed to work, but is quite a big mess in the V5 format, and might get troublesome at some point. (most notably, it'll make the conversion from V5 to V6 a little risky)

V6 should handle this kind of characters cleanly without any problem, but it's not normal for them to be needed, it's a bit of a hack and completely non-intuitive behaviour...
I think I'll just make it so that regular spaces aren't collapsed when displaying text in V6. It's not much work, just a small line of CSS :-P
ImageImageImage
If knowledge can create problems, it is not through ignorance that we can solve them.
Si le savoir peut créer des problèmes, ce n'est pas l'ignorance qui les résoudra. ( Isaac Asimov )
Broocevelt
Moderator
Posts: 7319
Joined: Fri Sep 11, 2009 6:06 pm
Gender: Female
Spoken languages: ES/FR/EN/DE
Location: Spain
Contact:

Re: Tips, tricks and info

Post by Broocevelt »

That would actually be great :D
User avatar
percey
Posts: 653
Joined: Tue May 08, 2012 9:34 pm
Gender: Male
Spoken languages: English
Location: Some kind of portal. Guess which one.

Re: Tips, tricks and info

Post by percey »

A lot of people don't seem to know about this feature, so I'm putting it here:

Previewing startup animations
If you selected a pose with a startup animation in the Trial Editor, you can hover your mouse over the picture displayed above the selected pose's number to make it show the startup animation instead.
There wasn't a signature fad/meme/whatever here, what are you talking about?
Mimi
Posts: 10382
Joined: Wed Jan 27, 2010 6:35 am
Gender: Female
Spoken languages: English: the only language I can brag about

Re: Tips, tricks and info

Post by Mimi »

Danielinhoni wrote:Tip: Centering text in AAO

There is no proper way to 'center' text in the editor. However you can manually center it.
First, write your text line by line (using the Enter button if there is more than one line).
Then, with your cursor at the beginning of each line, press Alt+255 (Hold the left Alt key, then press in order 2 5 5 on your numpad.) Yes, that is an empty character, but it has another ASCII slot assigned, so it won't be recognized as a regular space, and therefore won't be deleted when the editor detects a group of 1+ spaces together.

Now, use the character at the beginning of each line as much times as necessary to make the text look centered. When you finish writing your frame, the spaces should remain there, and your text should be centered.
EDIT: Apparently the AAO forums DO change these characters. THANK YOU D:< I will try to find a way to put it here.

EDIT2: Edited with the proper keyboard combination!
Are you sure it works...? I did that and I got 7...
Broocevelt
Moderator
Posts: 7319
Joined: Fri Sep 11, 2009 6:06 pm
Gender: Female
Spoken languages: ES/FR/EN/DE
Location: Spain
Contact:

Re: Tips, tricks and info

Post by Broocevelt »

Hey everyone, I'd like to know how to use str_distance to compare two variables that are a string of characters, since this is documented nowhere :) Basically I want to evaluate the condition that two variables (let's say var1 and Var2) are equal. How would I write that?

f:str_distance('Var1','Var2')=0 ?
User avatar
Kroki
Admin
Posts: 7475
Joined: Fri Nov 23, 2007 10:05 pm
Spoken languages: Français, English, Español, 日本語
Contact:

Re: Tips, tricks and info

Post by Kroki »

Can't you just evaluate
Var1 = Var2
? x)
ImageImage Image Image Image
Broocevelt
Moderator
Posts: 7319
Joined: Fri Sep 11, 2009 6:06 pm
Gender: Female
Spoken languages: ES/FR/EN/DE
Location: Spain
Contact:

Re: Tips, tricks and info

Post by Broocevelt »

No, that only works for variables that are a number, otherwise the player will returne a "malformed expression" message :P Although I'm going to try the format I used before, it may work.

EDIT: It doesn't work :? It doesn't return a "malformed expression" message so I assume this is the way it's supposed to be presented but it doesn't do anything. I'm going to do a few more tests... Anyone knows how to do this?

EDIT2: Huh the function doesn't interpret 'Var1' as the variable 1 but as the TEXT Var1. I'm going to try without the 's.

EDIT3: NOW it works. You don't have to put the 's. The correct expression is:
f:str_distance(Var1,Var2)
User avatar
Unas
Admin / Site programmer
Posts: 8850
Joined: Tue Jul 10, 2007 4:43 pm
Gender: Male
Spoken languages: Français, English, Español
Contact:

Re: Tips, tricks and info

Post by Unas »

Well, yes, the simple quotes delimit a string literal.
Variable names are written straight into the expression, without any delimiter.


(there is a special case, that is here for historical reason but shouldn't be used : if your variable's name contains spaces or special characters, you need delimiters around it : variable name delimiters are double quotes. But again, you shouldn't have to use it, variable names shouldn't contain spaces in the first place)



Also, yes,
f:str_distance(a,b)=0
is the same as
a=b
ImageImageImage
If knowledge can create problems, it is not through ignorance that we can solve them.
Si le savoir peut créer des problèmes, ce n'est pas l'ignorance qui les résoudra. ( Isaac Asimov )
User avatar
Ferdielance
Posts: 778
Joined: Sun Mar 09, 2008 12:46 am
Gender: Male
Spoken languages: English

Re: Tips, tricks and info

Post by Ferdielance »

Trick 1:
Using & and | to set variable values
Suppose you want to do the following:

* If some condition is true, set variable Y to the value 'Well done!'
* But if that condition is false, set variable Y to 'Oops.'

Normally, you might evaluate a condition, then jump to a frame that sets variable Y's value depending on the result, then proceed from the next frame out. But there's a faster way!

1. Define Y as the expression:

Code: Select all

((condition) & 'Well done!') | 'Oops.'
See, X & Y follows this rule:

If X is false, give false; If X is true, give Y.

...and X | Y follows this rule:

If X is false, give Y; If X is true, give true.

To see why this is REALLY useful, consider the following case:

1. Define victoryMessage as:

Code: Select all

((score < 2) & 'That was... not good.') | ((score < 4) & 'Not bad.') | ((score = 4) & 'Well done!') | 'Perfect score!'
Consider how many frames that would have taken by any other means! Uses of this include, but are not limited to:

* Making more efficient examine-based engines.

* Giving the player a different message depending on how many penalties they've received (requires you to increment a penalty counter.)

* Making type-and-response engines that DON'T take up an insane number of frames.

Warnings:

* I don't know how much longer Unas will support this. It works in the v5 and v6 player, but the source of the v6 player says that Unas will probably rewrite the expression engine soon...

I don't think it's a security issue, seeing as the expression engine sanitizes everything quite carefully, but it's conceivable that Unas might decide that this behavior of the Javascript & and | is potentially risky in some way and switch to truly Boolean operators. :(

* Don't assume that evaluation always occurs in the obvious order. If, for example, you do:

Code: Select all

(!(couldBeUndefined) & 'Variable is undefined!') | (f:str_first_word(couldBeUndefined))
...on the theory that this will prevent str_first_word from ever being fed a variable that might not be defined, you're in for a surprise!

This:

Code: Select all

(!(couldBeUndefined) & 'Variable is undefined!')
returns 'Variable is undefined!' if the variable truly is undefined. However, the longer expression just doesn't return anything. This is probably because the engine processes the entire expression and evaluates functions even if they're on the wrong side of an OR. But I'm not really a programmer, so take my explanations with a grain of salt.

* Make sure you can read your code. Use parentheses and spacing consistently, and consider downloading Notepad++ or another text editor that automatically tells you whether your parentheses match. Don't make something that it will be a nightmare to follow later...

Whew!

----
Trick 2
Using expressions in examine frame images
In the v5 editor, the image you use in 'Examine an area of an image' can be an expression. This is fantastically useful for those who want to make touchscreen engines. This works in the v5 and v6 players, for now. However, I don't see the capability anywhere in the v6 editor, presumably because Unas is reworking the expression engine.

To do this, use concatenation. Set the image to:

'http://www.yourimagehost.com/' . examineImage . '.png' (or whatever your image extension is)

This means you can create multiple examine screens (with the same button layout) using only one frame. This is good for two reasons. First, it can reduce the degree to which you need to insert 1-ms calculation frames between your examine screens. If your engine depends on jumping between lots of examine screens, this could make it less flickery. Second, it makes your code more readable and saves time, since you don't need to code 20 near-identical examine frames if one of your engine screens happens to just have a changing image.

This method cannot be used for backgrounds or characters, as far as I know, since those don't take expressions.

Warnings:

* You may be tempted to vary your button layout by using expressions in either the redirect frames for success and failure, or in the frames that define examinable areas. I DO NOT RECOMMEND THIS! As Bad Player discovered in a recent challenge thread, this can lead to unstable behavior, and expressions in redirects are an excellent way to make your trial an absolute mess when you start changing the frame order.

* The anticipated support for this feature in future versions of AAO is... oh, god, I don't even want to ASK Unas, because I'm going to be sad.

---
Trick 3:
Super-smooth fades in v5 and v6 using .svg images
(Works only with Firefox, but doesn't fail too jarringly in Chrome.)

Here's a demo trial.

These fades are not .apngs; they're much smaller files, and truly fade continuously. In addition, they do not loop, so you can set the frame timer a little long without worrying that they'll flash awkwardly. Even though they don't loop, however, you can still use them repeatedly in the same case.

Feel free to use them! They're such tiny files (under 1 kb each) that it won't be a drain on my bandwidth if you do. To use them, link the fade sprite you want as a special sprite (Use External Image), and set the frame timer to that sprite's speed plus a safety margin of 5 cs or so. On the subsequent frame, use the hide character option to remove the fade sprite from the screen.

For fade-ins, put the background you want to fade in on the same frame as the fade sprite. For fade-outs, put a black background in the next frame (where you hide the fader sprite). This should create smooth fades.

Links:

Code: Select all

Slow fade in: http://ferdielance.net16.net/fadein1500.png
Slow fade out: http://ferdielance.net16.net/fadeout1500.png

Medium fade in: http://ferdielance.net16.net/fadein1000.png
Medium fade out: http://ferdielance.net16.net/fadeout1000.png

Fast fade in: http://ferdielance.net16.net/fadein500.png
Fast fade out: http://ferdielance.net16.net/fadeout500.png
The way this works is as follows:

* AAO doesn't like it if you use any image that's not a .png, .jpg, or .gif. These images (in spite of their file extension) are all scalable vector graphics (.svg) files. To get the editor to accept that, I host them as .svg on one free web server, then have a second free web server do a redirect. When you ask for a .png, it bounces you to the .svg on the other server. Fun!

Once again, I'm not a programmer, so if this opens the door to some horrific exploit, please do tell me.

Warnings:

* I'm using two free web hosts to do this. If either goes down, they'll stop working. And there's a good chance that v6 will make all of these obsolete.

* This technically depends on a behavior that Unas might not like! Of all three tricks, this is the least likely to remain stable in future versions, even though it does work in v6 player right now.

* No, you can't use embedded JavaScript in your .svg inside the trial player. The player safely ensconces everything in <img> tags, which don't allow that in any sane browser. You could ask your players to right-click, view image, but that's awfully clumsy (except on April Fool's Day, when a surprise video is always fun.)

(Plus, if we abuse this toy, Unas will probably take it away...)

* Does not work in Chrome, which just doesn't play well with partial transparency.
Last edited by Ferdielance on Sat Apr 06, 2013 11:29 pm, edited 1 time in total.
"A slow sort of country!" said the Queen. "Now, here, you see, it takes all the running you can do, to keep in the same place. If you want to get somewhere else, you must run at least twice as fast as that!"
Post Reply