Friday, November 22, 2013

RAGS Tips and Tricks #1: Order of Actions

I present to you RAGS Tips and Tricks.  Here I'll post the random things I have learned when experimenting with RAGS.  Everything here will be done in RAGS version 2.4.0.0.

I make no promises that the way I do things are the best way to do them.  But I'll do my best to make it the best.  Comments appreciated.

Without further ado...

RAGS Tips and Tricks #1: Order of Actions

Download here.
One of the most important thing about your code is making sure it runs when you want it to and only when you want it to.  I attached a helping rags game that will output when actions happen.  Think of it as the debug window in a normal player form.

When you first start Order of Actions, we get to see how the game starts.
Game Setup: Game Title
Game Setup: Opening Message

Room 1: On Player Enter First Time
Object 1: On Player Enter First Time
Character 1: On Player Enter First Time
Room 1: On Player Enter
Player: On Player Enter
Object 1: On Player Enter
Character 1: On Player Enter
Room 1: Description
You can see a Object 1
Character 1 is here.

Player: On Game Start
A quick breakdown on the meaning behind the text.  The first half is generally where or what.  The second half is the section or action.  In "Game Setup: Game Title", it is the Game Setup and in the Game Title section.  For "Room 1: On Player Enter First Time", it is for Room 1 and the action is On Player Enter First Time.  Simple.

A few things stand out here, first thing that happens is the Game Title in bold and is followed by the Opening Message right away.  I'm very nit-picky and likes my text spaced apart.  Note the gap I like between paragraphs... v

^--- So if I want a space between the Game Title and the Opening Message, I need to add it in the Opening Message.

It is worth pointing out that there is a space between the Opening Message and Room 1: On Player Enter First Time.  That is from the RAGS engine and is automatic.

Second thing to notice is the Player: On Game Start action happens last!  Everything else happens before you get to the Player's On Game Start code.  This includes the Player's On Player Enter.  Some ways to work around this is to put the player in a starting room before the game actually starts.  Tales of the Drunken Cowboy by Mdqp starts off in a character creation room first before the game actually starts.

Another work around is to put all the Game Start code into the action that happens first: the starting room's On Player Enter First Time action.  This way you're guaranteed it will happen first and any narratives or text will appear before anything else could happen.  The down side is it's not very intuitive.  If you need to change something with the start of the game, it doesn't make much sense to check the code in a room.  But if you can keep that in mind, this would work fine.

Another thing to notice is all On Player Enter First Time actions occur before the regular On Player Enter actions.  And the order is Room, Player, Object, and then Characters.  There is no On Player Enter First Time.

When you move South, you'll see:
South
Room 1: On Player Leave First Time
Object 1: On Player Leave First Time
Character 1: On Player Leave First Time
Room 1: On Player Leave
Player: On Player Leave
Object 1: On Player Leave
Character 1: On Player Leave

Room 2: On Player Enter First Time
Object 2: On Player Enter First Time
Character 2: On Player Enter First Time
Room 2: On Player Enter
Player: On Player Enter
Object 2: On Player Enter
Character 2: On Player Enter
Room 2: Description
You can see a Object 2
Character 2 is here.
Like the On Player Enter, all On Player Leave First Time actions trigger before any On Player Leave action.  And the order is Room, Player, Object, and Character.

There's also a space between Character 1: On Player Leave and Room 2: On Player Enter First Time.  This is where the player actually moves to the new room.  This space is with the RAGS engine and can not be removed.  Not a problem if you like extra spacing.  If you don't, well...

But wait, there's one last thing.  Timers!  We got Rooms.  We got Objects.  We got Characters and the Player.  One last thing remains, which is Timers.

Right-click on the Player Portrait and select Timer.  I made two timers since there are two different ones we need to worry about at the moment: Run Always and Run a Specified Length.

Timer 1 is Run Always.  There is only one action available for this: On Each Turn.  Timer 2 is set to run for 3 turns and will restart automatically.

Timer 2 has 5 different actions: On Each Turn, On Turn 1, On Turn 2, On Turn 3, and On Last Turn.

Select Timer 1 (Run Always) and select On.  This just sets the Timer Active while Off sets it inactive.  This is not Execute Timer nor is it Reset Timer.  I'll get to those in a different Tips and Tricks.

You should see the results immediately:
Player - On
Timer 1: On Each Turn
 This means the timer will start the moment it's turned on.  Please keep that in mind.

Turn on Timer 2 as well: Right click Player Portrait, select Timer, select Timer 2 (3 Turn Length), and then select On.  The new text will be:
Player - On
Timer 1: On Each Turn
Timer 2 (3 turn timer): On Each Turn
Timer 2 (3 turn timer): On Turn 1
Timer 1 happens before Timer 2 due to the Execution Order of the timers.  If we switched it around, Timer 2 text would be before Timer 1.  Also, notice that for Timer 2, the On Each Turn action happens before the On Turn 1 action.  Most of the time, you won't be using both On Each Turn and On Turn X so you probably won't have much conflict here.

We need to use up some actions here for the timers so just right click on the Player Portrait and select Examine and do the same for the Room.

The new text:
Player - Examine
Player: Description
Timer 1: On Each Turn
Timer 2 (3 turn timer): On Each Turn
Timer 2 (3 turn timer): On Turn 2
Room: Room 2 - Examine
Room 2: Description
Timer 1: On Each Turn
Timer 2 (3 turn timer): On Each Turn
Timer 2 (3 turn timer): On Turn 3
Timer 2 (3 turn timer): On Last Turn
A quick point for the "Player - Examine" and "Room: Room 2 - Examine" part.  The action is actually called Examine in both cases.  "Player - " part is automatic.  Sadly, I don't know of any way to override this.  "Room: " part is also automatic.  The format appears to be "Player - <Action Name>" and "Room: <Room Name> - <Action Name>".

Anyways, back to timers.  The last three lines tells us the priority of a Set Length Timer: On Each Turn, On Turn X, and lastly, On Last Turn.

Last bit of information before I done here is to move North.
North
Room 2: On Player Leave First Time
Object 2: On Player Leave First Time
Character 2: On Player Leave First Time
Room 2: On Player Leave
Player: On Player Leave
Object 2: On Player Leave
Character 2: On Player Leave

Room 1: On Player Enter
Player: On Player Enter
Object 1: On Player Enter
Character 1: On Player Enter
Room 1: Description
You can see a Object 1
Character 1 is here.

Timer 1: On Each Turn
Everything sound be familiar by now.  The On Player Leave First Time section followed by the regular On Player Leave.  A space for when the player actually moves.  The On Player Enter First Time already happened at the start of the game so that's not there, but the stand On Player Enter is.  And finally the Timers.  Looks like the Timers are last.  This puts the final order as Room, Player, Objects, Characters, and Timers.

However, you'll notice that there's only Timer 1.  There's no Timer 2.  The Timer is set to Restart Automatically so it is running.  That's the last thing I want to point out.  Restarting the timer takes a turn.  Right click on the Player Portrait and select Examine.
Player - Examine
Player: Description
Timer 1: On Each Turn
Timer 2 (3 turn timer): On Each Turn
Timer 2 (3 turn timer): On Turn 1
So that makes it 4 turns to loop for a 3 turn length timer!

Of course, there are ways to fix this.  One easy way is to reset the timer in the On Last Turn action.  But the problem is usually the knowledge of why and not how to fix.  If a repeating timer is mistimed, this is probably why.

Anyways, that is it.  Thanks for reading; hope this was helpful.  Please leave comments or questions.  If you want me to talk about something specific, let me know.

TL;DR section

RAGS Tips and Tricks 1: Order of Actions download
Player: On Game Start happens last.
All On Player Enter/Leave First Time happens first before any of the regulard On Player Enter/Leave.
It's Room, Player, Objects, Characters, and then Timers.

Tuesday, November 12, 2013

New Project Appears!

I have some projects floating around in my head.  If things go well, you should see something interesting (read: not an actual game) within 2 weeks.

At the same time, I'm hoping to lay down some ground work for Seraphim's Javelin.  This is part of the code rewrite to hopefully make everything neater.  With any luck, this will result in fewer bugs and more effective code.  But this will depend on the amount of free time I'll have.

Friday, November 1, 2013

Not going to make it

Ugh... I code so slowly...  At my current rate, I'll be done by Christmas.

Sigh.  Another failed attempt at a game.  I'm shelving this for later.

Maybe next time I'll give myself more than one day.