Linking GUI's to GUI's and character selecting, and anything else

Started by , Fri 30/01/2009 01:37:51

Previous topic - Next topic

Khris

It doesn't work that way, you'll have to use the OR operator "||".

Code: ags
function cChar1_Look()
{
  if (player.NormalView == 1 || player.NormalView == 2 || player.NormalView == 3)
    Display("Damn, I'm a good looking Guy!");
  else
    Display("Damn, I'm a good looking Girl");
}


A few pointers: ( and ) are used for function parameters, { and } are used to group together several commands (after if, else if, else or those of a function).
You're calling a single (Display) line here, so you don't need the curly brackets, see my code above.

Also, since the view can't have a value other than 1-6, you can do:
Code: ags
function cChar1_Look()
{
  if (player.NormalView < 4) Display("Damn, I'm a good looking Guy!");
  else Display("Damn, I'm a good looking Girl");
}

You can also use the gender variable.

Also note that Display will show a text box. If you want the player character to say the sentence, use player.Say("Damn, ...");

ShadowRifter666

Right, that build correctly, select gender and class just fine now,
that code will definately help with bits and pieces to come.

just now need to get text to be appear
changed the display to player.say but for some reason be it Display or Player.Say the text doesn't appear onscreen, i think I maybe missing the code to recognise the character as something that can be interacted with, none of the other default functions from cEgo work, even though the code has been replaced correctly from cEgo to cChar1

Khris

If you open cChar1 and go to the events pane, what does it say e.g. next to "Look at character"?
Also check if the character's Clickable property is set to true.
And in the global script's on_mouse_click, in the eMouseLeft block, does it say "ProcessClick(...)"?

It all that is fine, make sure that the character you're clicking on is actually the player character.

ShadowRifter666

thanks, i just needed to input the functions into the "Look at character" section, forgot it wasn't applied with other characters apart from cEgo

ShadowRifter666

Just experimenting with the
Code: ags

if (player.NormalView < 4) player.Say()


and i am trying to add in a few variables to the speech
basically, tryingto have speech from 2 different characters played then a third dialog only if the character is a set view
in this case I need an "else if" function or something

Code: ags

if (player.NormalView < 4) player.Say("123");
else
  {player.Say("456")};
ELSE (player.NormalView == 21 || player.NormalView == 57) player.Say("789");


maybe a function that works like also would, so that it goes, player if player is view < 4 then player.say ("123");
it misses out the first "else" for other views, then uses an type of also function (ELSE) if the character is one of the correct views to say ("789"), if the view isn't right then the dialog ends after first if or else

for example there are 1,2,3,4,5,6 views so

Code: ags

if (player.NormalView < 4) player.Say("123");

else (player.Say("456"));

ALSO if (player.NormalView == 2 || player.NormalView == 5) player.Say ("789");


may of over explained that, hope it makes sense

monkey0506

Code: ags
if (player.NormalView < 4) player.Say("123");
else if (player.NormalView == 2 || player.NormalView == 5) player.Say ("789");
else player.Say("456");

ShadowRifter666

that doesn't quite work, i need to be able to say 123 + 789 or 456 +789 if the views are correct, or just 123/456 if the views are wrong. at the moment it just shows 123 +456 but not 789

monkey0506

Code: ags
if (player.NormalView == 2 || player.NormalView == 5) {
  if (player.NormalView < 4) player.Say("123");
  else player.Say("456");
  player.Say("789");
}
else {
  player.Say("123");
  player.Say("456");
}


Like that?

ShadowRifter666

I can see what it is supposed to do but it doesn't work
I changed the code a little to try and make more sense of it and it seemed to be more suitable

Code: ags

if (player.NormalView == 2 || player.NormalView == 5) {
  if (player.NormalView < 4) player.Say("123");
  else player.Say("456");
  player.Say("789");
}
else {
  if (player.NormalView < 4) player.Say("123");
  else player.Say("456");
}


can't quite work out how to get this working
something like

Code: ags

if (player.NormalView < 4) player.Say("123");
else player.Say("456");

then need and AND function in here so that
Code: ags

if (player.NormalView == 2 || player.NormalView == 5)player.Say("789");


if you get where i am going with this

Khris

What's wrong with:
Code: ags
if (player.NormalView < 4) player.Say("123");
else player.Say("456");
if (player.NormalView == 2 || player.NormalView == 5) player.Say("789");

?

Edit: Ah, I guess this should solve it:
Code: ags
String s;

if (player.NormalView < 4) s = "123";
else s = "456";

if (player.NormalView == 2 || player.NormalView == 5) s = s.Append("789");

player.Say(s);


Here's code with example text:
Code: ags
String g;
if (player.NormalView < 4) g = "guy, and now I'll";
else s = "girl, but I'll still";

String wr = "";
if (player.NormalView == 2 || player.NormalView == 5) wr = ", warrior-style";

player.Say(String.Format("I'm a %s bash your head in%s!", g, wr);


ShadowRifter666

ok that is cool, i think that should work, though I keep getting the error

Code: ags

Failed to save room room7.crm; details below
room7.asc(-10): Runtime error: unexpected eof


And just to make it more complicated than anything needs to be, I am trying to put in some "Display" text as well, though I know that wouldn't fall into defining the "string s" in that case would i need to define another string for the Display text so something like

Code: ags

string D;

if(player.NormalView > 3) D = "abc";
else D = " "


at that point i am lost trying to get into the player.Say section since it is a Display function rather than player.Say.
In simple terms i guess it would go something like

Code: ags

if (NormalView <4) player.Say "123"
else 
       {
         player.Say ("456")
         Display("789")
         player.Say ("abc")
        }


one other thing, is it possible to play a single room rather than go through every room each time i want to check everything is working?

AdamM

Yes: if 'Enable Debug Mode' in General Settings is set to True, then you can use the keycode Ctrl-X while testing your game to open a dialog box that will allow you to instantly warp to a chosen room.

ShadowRifter666

ok thaanks for that, any ideas on everything else?

also i maybe missing seeing it in the manual but how to you define one property of an object
say I just want to say an object is solid
Code: ags

oRock1.Solid = true;
[/code

i need something before that, since it keeps throwing an error at me when i just want that to be a constant in that room

Khris

The eof error usually means you didn't terminate a string. Look through your script for a missing ".

You don't have to declare another String variabe to use the display command.
Just replace "player.Say" with "Display".

About your latest post:
You can only declare variables directy in the room script, all other commands have to be inside a function. You'll probably want the room's before fadein event, select the room, open the events pane (bolt icon), select before fadein and click the ellipses button. The function is created in the room script, put the line in there.

ShadowRifter666

ok well i can't find a missing " heres there code i have so far

Code: ags


function oObject0_Look()
{
  player.Say("Now that is a big stasis tube");
  Display("Yup, there is the creature inside");
  
  String s;

  if (player.NormalView < 4) s = "The creatures looks like it is sounds asleep";
  else s = "Strange looking creature";
      Display ("Looks nearly human");
      player.Say ("Wonder if the named it yet?");

  String bs;
  if (player.NormalView == 21 || player.NormalView == 57) bs = "Though something about that creature seems rather familiar";

  player.Say(String.Format(s, bs);
}
  


ok thanks for the before fade-in, i thought i might need to be in there but i got the wrong function

Khris

If you want to stich two strings together, use String.Format("%s%s", a, b).
The first parameter has to be a string constant, i.e. text with "" around it.
Look up String.Format and the linked string formatting section in the help file.

In your code, you can also do:
Code: ags
  s = s.Append(bs);  // stich bs to the end of s
  player.Say(s);
     // say s

ShadowRifter666

ok that String.Format helped, though now I have another grevience, as shown in the code i put up in my last post I have 3 speeches, going player1--display--player2, but when i run the game it comes out   Display--player1--player2 so i need to solve that.

Also the second IF statement defining bs isn't being seen. i think it maybe a problem with ordering the script wrongly but i'm not sure.

The eof was solved, a missing ) rather than "

and finally the code to make an object solid
Code: ags

oRock1.Solid = true;


doesn't work, I have it placed right at the start of the room script in the
Code: ags

function room_Load()
{
 oRock1.Solid = true;
}

but the player walks straight through it

Trent R

Suggestions for your object.Solid problem:
-Check if function is linked, of course.
-See if you you are using any functions that will ignore walkable areas, such as the eAnywhere parameter of Walk.
-As a workaround, try putting a different walkable area around the rock object, and disable that.


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Khris

I think characters aren't solid by default, so you'll have to add player.Solid = true;

ShadowRifter666

well i set the player.Solid = true; anyway but i hadn't set the blocking height or width so that was allowing the player to pass through the object, I should of seen that first.

Hope someone has and idea on the different speech code I'm trying to do, 5 posts back on 25th Feb

I have a similar problem now though a little easier, i am trying to get 3 different speeches to appear depending on the character NormalView

Code: ags

function oRock1_Look()
{
  Display ("That big damn boulder is blocking the path");
  if (player.NormalView == 11 || player.NormalView == 35) player.Say("wonder if i could push it out the way?");
  if (player.NormalView == 45 || player.NormalView == 69) player.Say("wonder if I could Climb over it?");
  if (player.NormalView == 57 || player.NormalView == 21) player.Say("I think I could probably smash that rock into pieces");
}


I probably need an else in there but that would stop it reaching the last if i think

SMF spam blocked by CleanTalk