MODULES: Face Right2, Teleport

Started by Lazarus, Wed 06/09/2006 11:48:29

Previous topic - Next topic

Lazarus

The first module is:Face Right2

FaceRight2.zip


Requirements:-  AGS 2.70 +

This idea was taken from one of the demo games, which I no longer have.
So I am unable to remember who the author was.

This module allows you to turn characters so they face a certain direction without using coordinates.

Examples:-
Code: ags

Face(cEgo, Left);
Face(cEgo, Up);
Face(cEgo, Right);
Face(cEgo, Down);

Face(cRoger, Left);
Face(cRoger, Up);
Face(cRoger, Right);
Face(cRoger, Down);


*Currently using AGS Editor 2.70 (Build 2.70.601)*

Lazarus

#1
The second module is :Fading Objects & Characters

Superseded by the FadingThings module.
*Currently using AGS Editor 2.70 (Build 2.70.601)*

Lazarus

#2
The third module is: Teleport

Teleport.zip

This zip comes with two versions
The first version uses the characters script name and object number ie.

Code: ags

TeleportCharacter(EGO,100,110);
TeleportObject(1,100,110);


The second version uses the character script o-name ie.

Code: ags

TeleportCharacter(cEgo,100,150);
TeleportObject(oWax,100,115);



Teleport Characters or Objects anywhere within same room.

Requirements:-Ã,  AGS 2.70 +

This module allows you to instantly move characters and objects around the screen as if being teleported.

The first function uses the character script '0' name, X and Y are the co-ordinates to
teleport the character too. see example below

TeleportCharacter(cJoe,100,60);
TeleportCharacter(Script name, X position, Y postion);

The second function uses the object script '0' name, X and Y are the co-ordinates to
teleport the object too. see example below

TeleportObject(oWax,100,60);
TeleportObject(Script o-name, X position, Y postion);
*Currently using AGS Editor 2.70 (Build 2.70.601)*

jasonjkay

Sounds really usefull, i'll have to add them all onto my site. Great work.
http://www.americangirlscouts.org/agsresources/ - Mods, plugins and templates.

Alynn

Oddly enough, I've been using a FaceDirection (character ch, FaceDir dir) over 2 years ago... I hadn't even thought about turning that into a module...

And now he gets the credit for something I had done over 2 years ago, and just recently changed to 2.72 code...

:P

These are useful modules, but I wonder about some of these "simple" modules (don't get me wrong, CharFonts is a simple module as well, what I mean by simple is it's a simple thing to script out without a module, but convenient that someone else has done that for you.) if these things get so big, how will anyone learn enough about the base scripting language to know how to do these easy little tricks...

Anyway sorry for the OT...

jasonjkay

#5
Some of these things might be simple to you but to us newbs they can be quite complicated, so it helps us out by making things simple. Oh and incase anybody asks I do still consider myself a newb, i've made no games or modules I just made a website for modules.
http://www.americangirlscouts.org/agsresources/ - Mods, plugins and templates.

strazer

I have to agree with Alynn to a point.
I don't see the benefit of the Teleport module in particular. What's wrong with
  cEgo.x = 100;
  cEgo.y = 150;
and
  oWax.X = 100;
  oWax.Y = 150;
?

jasonjkay

#7
Thats a good point, I didnt think of it in that way. I know practically nothing about coding as i've only played around with it so far.
http://www.americangirlscouts.org/agsresources/ - Mods, plugins and templates.

Khris

I was REALLY curious how the Face Right module would work, since it uses the built-in Character.FaceLocation command.

I found this:
Code: ags
#define Face_RightÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  player.x+10,player.y
#define Face_LeftÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, player.x-10,player.y
#define Face_UpÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, player.x,player.y-10
#define Face_DownÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, player.x,player.y+10

Easy enough, and it will turn the player allright, since player.FaceLocation(Face_Right); will become player.FaceLocation(player.x+10,player.y); at compile-time.

However, this obviously works for the player character only.

It would be way more useful to use something like this:

Code: ags
eNum Direction { eDirRight, eDirLeft, eDirUp, eDirDown };

function FaceDir(Character*c, Direction dir) {
Ã,  if (dir==eDirRight) c.FaceLocation(player.x+10,player.y);
Ã,  ...
}

FaceDir(cEgo, eDirRight);


As strazer has already pointed out, the teleport thingie is pretty much obsolete.

The Fade module sounds useful, however.

Alynn

Quote from: KhrisMUC on Thu 07/09/2006 13:45:15However, this obviously works for the player character only.

It would be way more useful to use something like this:

Code: ags
eNum Direction { eDirRight, eDirLeft, eDirUp, eDirDown };

function FaceDir(Character*c, Direction dir) {
  if (dir==eDirRight) c.FaceLocation(player.x+10,player.y);
  ...
}

FaceDir(cEgo, eDirRight);

* Alynn points to his early post about his FaceDirection (character ch, FaceDir dir);

Although since then it has been updated to 2.72 standards...

And that's basically the code right there. I created it as a shortcut, since I have a bunch of facing commands (as the characters break the 4th wall constantly, and they face the camera when doing so, and so on and so forth).

I just never bothered to release it as a module because to me, it's learning to do things like that that helps new people learn the language... Soon you will have people saying, "I used the face direction module to make my guy look around, but how do I make him look at a certain point no matter where he is?"

On the flip side, perhaps these easy modules will help some if they bother to look at the code to figure out how the author did it.

SSH

Quote from: KhrisMUC on Thu 07/09/2006 13:45:15
Code: ags
eNum Direction { eDirRight, eDirLeft, eDirUp, eDirDown };

function FaceDir(Character*c, Direction dir) {
  if (dir==eDirRight) c.FaceLocation(player.x+10,player.y);
  ...
}

FaceDir(cEgo, eDirRight);


I think you mean:

Code: ags

eNum Direction { eDirRight, eDirLeft, eDirUp, eDirDown };

function FaceDir(Character*c, Direction dir) {
  if (dir==eDirRight) c.FaceLocation(c.x+10,c.y); // c, NOT player!
  ...
}

FaceDir(cEgo, eDirRight);


But, I need to change the facing direction of the player much more often, so perhaps using both methods would be best?
12

Lazarus

I've now found the right zip as this one allows any character using the script o-name to face different directions

FaceRight2.zip

Code: ags

Face(cEgo, Left);
Face(cEgo, Up);
Face(cEgo, Right);
Face(cEgo, Down);

*Currently using AGS Editor 2.70 (Build 2.70.601)*

R4L

Quote from: Alynn on Wed 06/09/2006 13:15:06
These are useful modules, but I wonder about some of these "simple" modules (don't get me wrong, CharFonts is a simple module as well, what I mean by simple is it's a simple thing to script out without a module, but convenient that someone else has done that for you.) if these things get so big, how will anyone learn enough about the base scripting language to know how to do these easy little tricks...

So no one saw anything like this coming?

dbuske

I have to disagree. This works like any other script function.
It is just easier.
Excellent Module. And teleport too. It is coming in handy for my Dumbledore and
Grindelwald game. Lots of teleporting during magic battles.
What if your blessings come through raindrops
What if your healing comes through tears...

Matti

You do realize that this thread is five years old, do you? Also, the direction facing thing is obsolete and the teleport function is a three-liner you could easily script yourself.

Snarky

How is the direction facing obsolete, apart from that these days you'd probably write it as an extender function? AGS still doesn't have it built in.

monkey0506

Well deprecated or not, Lazarus never indicated that the issue with the coordinates of the Face function was ever actually fixed.

As a side note, I find it rather interesting that the name of the module is "FaceRight" to indicate "FaceDirection".

hedgefield

Here's the code I use to do FaceDirection stuff, written as an extender function, if anyone's interested.

Add at the top of the Globalscript.asc:

Code: ags
function FaceDirection(this Character*, String dir) {
  if (dir=="Down") this.FaceLocation(this.x, this.y+10, eBlock);
  else if (dir=="Left") this.FaceLocation(this.x-10, this.y, eBlock);
  else if (dir=="Right") this.FaceLocation(this.x+10, this.y, eBlock);
  else if (dir=="Up") this.FaceLocation(this.x, this.y-10, eBlock);
  else if (dir=="DownRight") this.FaceLocation(this.x+10, this.y+10, eBlock);
  else if (dir=="UpRight") this.FaceLocation(this.x+10, this.y-10, eBlock);
  else if (dir=="DownLeft") this.FaceLocation(this.x-10, this.y+10, eBlock);
  else if (dir=="UpLeft") this.FaceLocation(this.x-10, this.y-10, eBlock);
}


Add at the bottom of the Globalscript.ash:

Code: ags
import function FaceDirection(this Character*, String dir);


Use by calling cName.FaceDirection("DownRight"); for example.

Feel free to absorb it into a module if no recent one exists.

Khris

#18
Edit: As multiple people have pointed out, you're much better off using an enum for the direction parameter.

Dualnames

I still use a version of Lazarus code, that I've modified to my needs.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk