want player to be able to switch character using gui...

Started by evildustmite, Wed 10/09/2014 18:46:36

Previous topic - Next topic

evildustmite

I want to be able to switch between two players using a gui, I've set up the buttons in the gui already, but don't know how to script them to actually change to the player. I would also like to have different texts display depending on what character is interacting with a particular hotspot.
I tried something like this:
Code: ags
// room script file

function hUmbrella_Look()
{
  int cID;
  cID == Character.ID;
  If cID ="1";
   then Display("It's an Umbrella,It has a tag on the handle.");
   Else Display("It's your Umbrella,It says so right there on the tag.);
}

but it didn't work,

Crimson Wizard

#1
Hi, evildustmite.
Is your script example above a real script you typed, or just a "pseudo-code"?
If it is what you actually typed, then you are using completely wrong syntax and I would suggest you make yourself acquianted with the script syntax and other basics first:
http://www.adventuregamestudio.co.uk/wiki/Scripting_tutorial_part_1
http://www.adventuregamestudio.co.uk/wiki/Scripting_tutorial_part_2

AGS uses C/C++ - like syntax:
Code: ags

function hUmbrella_Look()
{
  int cID = player.ID;
  if (cID == 1)
    Display("It's an Umbrella,It has a tag on the handle.");
  else
    Display("It's your Umbrella,It says so right there on the tag.");
}


Alternatively, you may compare references, which is much cleaner:
Code: ags

function hUmbrella_Look()
{
  if (player == cTheFirstCharacter) // put here your actual character's script name
    Display("It's an Umbrella,It has a tag on the handle.");
  else
    Display("It's your Umbrella,It says so right there on the tag.");
}



//------------------------------------------------
To change the player character simply do:
Code: ags

cMyAnotherCharacter.SetAsPlayer(); // replace with your actual character script name



For this and other basic questions, there's a manual, which comes both in offline variant (called from AGS by pressing F1) and online variant:
http://www.adventuregamestudio.co.uk/manual/
I would advise to at least scan through script function names to learn what you can do in script.

evildustmite

#2
Thanks for the reply, yeah that was code I actually typed. I'm not really familiar with any programming languages other than BASIC, which even that I don't know a lot of. So, yeah I guess i'll have to study the syntax a bit more.
I tried your sample code and that didn't work, says the last line before the closing bracket has an error: end of input reached in middle of expression.

I appreciate your help

edit: figured out the problem, there was a missing double quote at the end of the text string.

Cassiebsg

evildustmite, it's just a quotation's mark that is missing... get use to those error msg, you'll get see plenty of them, and figuring out what they mean will help you along the way. ;)

The line should look like this:
Code: ags

    Display("It's your Umbrella,It says so right there on the tag.");


All text goes between " "... ;)
There are those who believe that life here began out there...

Crimson Wizard

Oops, I copy pasted that line without noticing :).

evildustmite

Quote from: Cassiebsg on Wed 10/09/2014 21:12:01
evildustmite, it's just a quotation's mark that is missing... get use to those error msg, you'll get see plenty of them, and figuring out what they mean will help you along the way. ;)

The line should look like this:
Code: ags

    Display("It's your Umbrella,It says so right there on the tag.");


All text goes between " "... ;)

thanks, I figured it out just before I saw your post.

SMF spam blocked by CleanTalk