getting a mobile ph gui to work

Started by gypsysnail, Tue 24/10/2006 03:08:13

Previous topic - Next topic

gypsysnail

I have a question - I have looked thru the forums for this sort of function but could not really find any relating to the one I want. So here goes, I have a mobile phone and I want to use it from my inventory and have the phone really close up (maybe this would mean making a room just for this?) and interact with the phone - sending text messages and receiving them. Any idea on how I could achieve this? I am aware that maybe I will need to use 'hotspots' for each button on the phone and interactions within each.... Also I am hoping to make a puzzle of moving things into a particular place, a board game within the adventure game that the character has to complete to get to next point - would this be similar to the phone one? So once again, any ideas? I am such a nooob :P :D
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Theeph

I've done a phone before, using a Gui. Your room idea would work too though. I guess it's up to personal preference. You're right about the hotspots too.

Anyway to get something like this working with a gui...

Draw a phone in a paint program and import it as the background for the gui.
Make ten number buttons (or twelve if you want the * and #). Also make a Label where the screen would be, and that will let you display text messages and so forth.

If you wanted to replicate, for instance, a Nokia navigation style it gets a bit tricky, but is still quite managable. You'll just have to add in the up/down buttons.

Personally, I would just add a button where the screen is that said something like "Send text message" (with a transparent background on the button). When the player clicks that they can type in their message with an inputText field and press a send button.

Complicated but getting an SMS is easier. Just play a beep sound, then do something like:

phoneLabel.Text = "C u l8r 4 adVn2ur";


It really depends on how complex you want to go. Do you want the player to enter a phone number? Actually type a message, or just have the character automatically enter one... etc.

I can be more specific if necessary

gypsysnail

You are tops Theeph!!! I am getting very excited! I am currently drawing the open part of the phone in photoshop and it's coming a long nicely, yep its a Nokia phone too!! ;). I wouldn't enter a nbr, but let character send to the person such as "Mum" as this character would have nbrs in her ph directory ;).

About this one:
QuoteAlso make a Label where the screen would be, and that will let you display text messages and so forth.

How will I do this one? and also why would it be a background for the gui? Forgive me for being so noob lol.

Yes I would like to actually type a message each time the character is to send a text. I like this part u mentioned
QuoteinputText field and press a send button
that would work well I am sure :) Look fwd to hearing more on this from you :):).
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Theeph

#3
Hey again.

Here's a quick mock up of how you could layout the gui. Note where the label is, as well as the "invisible" buttons for using the phone (these are just normal buttons with the "New Button" text deleted.



So... the label displays what the player types. The buttons send or cancel. Then down the bottom somewhere you'd draw a Gui text box that says "Enter text here". The player types what they want and it displays on the label like this:

label.Text = textBox.Text;

(you could probably even improve it by putting the following in the on_key_press section)

if(gPhone.Visible == true){
     if(keycode >= 0){
          label.Text = textBox.Text;
   }
}

That should update the label every time the player types in a key, not just when they press enter.

Then whatever you want to do with the message, you can get the message from the label:

string message = label.Text;

Also note the pink background of the gui - meaning it will be transparent when it's on screen, so only the phone will show up and you'll still be able to see the game behind it. Might not be what you're going for, but seeings as it demonstrates the pic on the background of the gui I thought I'd throw it in. If you do this though you have to set the gui border and background colour to 0.

Cheers.

EDIT: If you want to see a good example of this working, check out Ben Jordan 3 by Grundislav. Great game too.

gypsysnail

Oh thank you thank you! That is brilliant! I will use your example. You worked hard to help me so here is a blue cup with a hot cuppa coffee or chocolate of whatever you like as a reward *passes a blue cuppa over to you - its hot!*. I am excited to try this out once I have finished drawing my phone. I think I will try for a nice background like a spiraly one of a couple of colours. Hopefully I can integrate the characters hand in to press the send button, would look interesting :). I have to go to work in 10 minutes which is a bit of a bugger when I could be working all day and night on the game lol but got to earn money! At the weekend after Thurs I will be trying out the idea you gave me and let you know how it goes and if any probs I will ask :). Enjoy your blue cuppa drink :D
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Theeph

Hey no problem. :)

About the character's hand thing... when you get a chance you should check out Alien Time Zone by Babar:

http://www.adventuregamestudio.co.uk/games.php?action=detail&id=620

The Start New Game page features something similar. I think it's a big mouse cursor or a sprite tied to mouse.x and mouse.y in a limited range. Very cool effect. Good game too.

gypsysnail

I have drawn an animating mobile phone, and made its gui, added gui buttons for player to click 'send' and 'exit' ph gui and a label for the screen to show the text that will be typed in a text box that I created outside the phone (rather than pressing buttons on the ph to type a txt) but I am unsure on how to get the script (as shown below) to work to make the send function work. I asked a friend how to make a gui ph and he helped me so greatly :):):) now I am ready for the next step. If anyone can help with this, that would be so good! :)

so far in my script it has this:
Code: ags
code:
#sectionstart unhandled_eventÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function unhandled_event(int what, int type) {
Ã,  
}
#sectionend unhandled_eventÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart typingtxt_ActivateÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function typingtxt_Activate(GUIControl *control) {
Ã,  
}
#sectionend typingtxt_ActivateÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart send_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function send_Click(GUIControl *control, MouseButton button) {
Ã,  
}
#sectionend send_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart exitphone_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function exitphone_Click(GUIControl *control, MouseButton button) {
Ã,  Ã,  Ã, gMobph.Visible = false;
Ã,  Ã,  Ã, cEgo.Say("Glop Glop.... Brilliant! That's a text sent!");
}

}
#sectionend exitphone_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart sendsms_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function sendsms_Click(GUIControl *control, MouseButton button) {
Ã,  
}
#sectionend sendsms_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart inventory5_aÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function inventory5_a() {
Ã,  // script for Inventory item 5 (mobph): Other click on inventory item
Ã,  
}
#sectionend inventory5_aÃ,  // DO NOT EDIT OR REMOVE THIS LINE



Now I think I have the exit one covered but I am not sure about the Send click one and type sms ones, if someone can help me with this, that would be great! I know some of the scripts function sections look empty but I am waiting for the help and trying to work out what to put in for each section to make the phone work ;).

EDIT:
And now I have this error message coming up when I go to test game and it says Parse Error 'gInventory' The script is as below:

Code: ags
code:
#sectionstart interface_clickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function show_mobph_window () {
	// is called when mouse clicks on mobile phone in inventory to interact
	// with the mobile phone gui
Ã,  if(mouse.Mode == eModeInteract){
Ã,  Ã,  Ã,  Ã,  Ã, Display("You open the phone");
Ã,  Ã,  Ã,  Ã,  Ã, gInventory.Visible == false;
Ã,  Ã,  Ã,  Ã,  gMobph.Visible == true;

Ã,  Ã,  Ã,  Ã,  Ã, gMobph.BackgroundGraphic = (128);
Ã,  Ã,  Ã,  Ã,  Ã, Wait(5);
Ã,  Ã,  Ã,  Ã,  Ã, gMobph.BackgroundGraphic = (124);
Ã,  Ã,  Ã,  Ã,  Ã, Wait(5);
Ã,  Ã,  Ã,  Ã,  Ã, gMobph.BackgroundGraphic = (125);
Ã,  Ã,  Ã,  Ã,  Ã, Wait(5);
Ã,  Ã,  Ã,  Ã,  Ã, gMobph.BackgroundGraphic = (126);
Ã,  Ã,  Ã,  Ã,  Ã, Wait(5);
Ã,  Ã,  Ã,  Ã,  Ã, gMobph.BackgroundGraphic = (127);

}


You can see I have animations of the phone but I have made the gui with the graphic number 127 as that is the open phone to use to send/receive messages but have I gone the correct way in this part?

EDIT:
and now it has the error on key already defined and the code is:
Code: ags
code:
#sectionstart on_key_pressÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function on_key_press(int keycode) {
Ã,  // called when a key is pressed. keycode holds the key's ASCII code
Ã,  if (IsGamePaused() == 1) keycode=0;Ã,  // game paused, so don't react to keypresses
Ã,  if (keycode==17)Ã,  QuitGame(1);Ã,  Ã, // Ctrl-Q
Ã,  if (keycode==363) SaveGameDialog();Ã,  Ã, // F5
Ã,  if (keycode==365) RestoreGameDialog();Ã,  // F7
Ã,  if (keycode==367) RestartGame();Ã,  // F9
Ã,  if (keycode==434) SaveScreenShot("scrnshot.bmp");Ã,  // F12
Ã,  if (keycode==9)Ã,  Ã, show_inventory_window();Ã,  // Tab, show inventory

Ã,  if (keycode==19)Ã,  Debug(0,0);Ã,  // Ctrl-S, give all inventory
Ã,  if (keycode==22)Ã,  Debug(1,0);Ã,  // Ctrl-V, version
Ã,  if (keycode==1)Ã,  Ã, Debug(2,0);Ã,  // Ctrl-A, show walkable areas
Ã,  if (keycode==24)Ã,  Debug(3,0);Ã,  // Ctrl-X, teleport to room
}

function on_key_press
if(gMobph.Visible == true){
Ã,  Ã,  Ã, if(keycode >= 0){
Ã,  Ã,  Ã,  Ã,  Ã,  label.Text = textBox.Text;
Ã,  Ã, }
}
#sectionend on_key_pressÃ,  // DO NOT EDIT OR REMOVE THIS LINE


I am going to add in a big hand cursor so it looks like the character is touching the close-up image of the phone and interacting with it and I am sure I will need help with this when the time comes.

I do have a tiny version of the ph in the inventory box and I know the interactions will link this to the gui through on any other click on this inventory item - run script but we need to get thru the other errors above first, but this gives you the idea of what I have done so far..... Thanks heaps for your time :)

I know this is a very very long post and I apologise but I am at my wits end and really keen to learn how to do this properly.
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Ashen

#7
Topics merged and renamed, as it's really a continuation of the same question.

Not very helpfully (but as you might've expected from me :)): The answer to the first question (setting up the send and type buttons) depends a great deal on how exactly you want it to work.

(Next bit edited, after re-reading the post and realising it was slightly pointless.)
For the 'Send' button, we need to know what will happen when they send the message - not in script terms, but 'in-game'. Will the message just disappear into the ether, or will it need to be checked and stored for something later? (Apologies if you've mentioned this, but I can't see it.)

The edits are much easier:
Quote
And now I have this error message coming up when I go to test game and it says Parse Error 'gInventory' The script is as below:

Like I've said in a PM, '==' is for CHECKING values in a conditional (if (x == y), to set values use '='. Which means:
Code: ags

         gInventory.Visible == false;
        gMobph.Visible == true;


Should be:
Code: ags

         gInventory.Visible = false;
        gMobph.Visible = true;

Other than that, the animating part should work OK, but shouldn't you have it animate closed when you turn the GUI off, as well?

Quote
and now it has the error on key already defined and the code is:

If a function already exists (like on_key_press, repeatedly_execute(_always), on_mouse_click) you should add your code to it, and not create another instance of the function. So, that should read:
Code: ags

#sectionstart on_key_press  // DO NOT EDIT OR REMOVE THIS LINE
function on_key_press(int keycode) {
  // called when a key is pressed. keycode holds the key's ASCII code
  if(gMobph.Visible == true){
     if(keycode >= 0){
          label.Text = textBox.Text;
     }
  }
  if (IsGamePaused() == 1) keycode=0;  // game paused, so don't react to keypresses
  if (keycode==17)  QuitGame(1);   // Ctrl-Q
  if (keycode==363) SaveGameDialog();   // F5
  if (keycode==365) RestoreGameDialog();  // F7
  if (keycode==367) RestartGame();  // F9
  if (keycode==434) SaveScreenShot("scrnshot.bmp");  // F12
  if (keycode==9)   show_inventory_window();  // Tab, show inventory

  if (keycode==19)  Debug(0,0);  // Ctrl-S, give all inventory
  if (keycode==22)  Debug(1,0);  // Ctrl-V, version
  if (keycode==1)   Debug(2,0);  // Ctrl-A, show walkable areas
  if (keycode==24)  Debug(3,0);  // Ctrl-X, teleport to room
}
#sectionend on_key_press  // DO NOT EDIT OR REMOVE THIS LINE


But, that code could just as well be trimmed, and placed in repeatedly_execute_always:
Code: ags

  if(gMobph.Visible == true){
    label.Text = textBox.Text;
  }

(And, just to check, do you actually have a Label called label and a TextBox called textBox?)
I know what you're thinking ... Don't think that.

gypsysnail

Hey thanks Ashen, yes silly me I didnt realise that there was another thread, glad you merged them :).

Yes sorry I hadn't thought to mention the message where it would go lol. I would like the messages to disappear but to return a message from that person I send to.... after maybe 2 minutes. Thing is there may need to be a small address book in phone just for those few ppl character has to send to. Any ideas on this one?

(also a timer may need to be added to this - I might start a separate thread on timers to put in game if there isnt already a thread on this from the past - post link here of the thread if there is one on it).

Quote(And, just to check, do you actually have a Label called label and a TextBox called textBox?)
I am glad you asked me this because I could not understand that part, it was from my friend - it was an example and I have the label ready, but could not quite work out what part of the label's name went in what part etc.
AH EDIT!!!! :D I put two and two together and realised what I had called my label and text box under the script field in the floating box and it worked! :):)

Ok now I have done some more editing and I get this very annoying error message saying Undefined symbol 'label' and here is the code below:
Code: ags
code:#sectionstart send_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function send_Click(GUIControl *control, MouseButton button) {
Ã,  String send = label.smsMsg;
label.smsMsg = "";
Ã,  
}
#sectionend send_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE


What I dont understand is why is this doing it when I have clearly called my label smsMsg (the label that I placed on the mobile phone screen).

And when I removed this code temporarily, the test game does work but when I go to inventory and click on my mobile ph with the arrow, the gui does not come up. Why is this happening? That gui has never ever shown up once at all in the test game even though I have put in the interactions on "Other click on inventory item - run script
and I put in that script
Code: ags
code:if(mouse.Mode == eModeInteract){
Ã,  Ã,  Ã, Display("This is your mobile phone. Do you want to send a message?");
}


and for the animating the phone to a closed view on exit, I am not sure how this would be done? Repeat of animated code but back to front? I have no idea of this kind of thing at this stage.

And the hand cursor - I actually would like to have a big hand cursor in the gui so it looks like character is touching the buttons etc, I have drawn the hand cursor and added it to the cursors pane in ags through sprite manager, but not quite sure how to make it work? Only want that cursor within this phone gui. If you want the whole script in edited form of what I have done so far, please feel free to ask me to post it and I will :). Many thanks for the help.
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Ashen

#9
QuoteWhat I dont understand is why is this doing it when I have clearly called my label smsMsg (the label that I placed on the mobile phone screen).

Take another look at the GUI Label functions and properties. The correct usage would be LabelName.Function (e.g. smsMsg.Text). I guess what you want is:
Code: ags

#sectionstart send_Click  // DO NOT EDIT OR REMOVE THIS LINE
function send_Click(GUIControl *control, MouseButton button) {
  String send = smsMsg.Text; // Copy message to 'send'
  smsMsg.Text = ""; // Clear label
 
}
#sectionend send_Click  // DO NOT EDIT OR REMOVE THIS LINE


Quote
Why is this happening? That gui has never ever shown up once at all in the test game even though I have put in the interactions on "Other click on inventory item - run script
and I put in that script

First, a general observation: If you're using one of the standard cursor modes (Look, Use, Talk, Use Inventory) it doesn't need to go in 'Any Click..' with the if(mouse.Mode == condition, there should be interactions for them to go in (e.g. 'interact inventory item'). The way you've got it won't cause any problems, I just wondered why you were doing it.
You don't say what happens instead of opening the phone, but if I were to take a guess, I'd say that the problem is that you're using eModeInteract. By default (that is, unless you've checked the 'Handle inventory clicks in script' option), that makes the current item the Active Inventory item, and won't actually run any code attached to the item (like your 'Do you want to send a message?' line). If this IS the case, You'll need to either use a different mode (e.g. emodeTalkto - you'll also need to add another button to the Inventory GUI) or add something to repeatedly_execute_always that checks if the phone is the Active item, and runs the code accordingly. (This is actually mentioned in the BFAQ.)

Quoteand for the animating the phone to a closed view on exit, I am not sure how this would be done? Repeat of animated code but back to front?

Yes, exactly that. I guess this is the 'animate open' bit:
Code: ags

         gMobph.BackgroundGraphic = (128);
         Wait(5);
         gMobph.BackgroundGraphic = (124);
         Wait(5);
         gMobph.BackgroundGraphic = (125);
         Wait(5);
         gMobph.BackgroundGraphic = (126);
         Wait(5);
         gMobph.BackgroundGraphic = (127);


So to close it use:
Code: ags

         gMobph.BackgroundGraphic = (127);
         Wait(5);
         gMobph.BackgroundGraphic = (126);
         Wait(5);
         gMobph.BackgroundGraphic = (125);
         Wait(5);
         gMobph.BackgroundGraphic = (124);
         Wait(5);
         gMobph.BackgroundGraphic = (128);



Quote
And the hand cursor - I actually would like to have a big hand cursor in the gui so it looks like character is touching the buttons etc, I have drawn the hand cursor and added it to the cursors pane in ags through sprite manager, but not quite sure how to make it work?

Change the cursor mode to the one with the Hand graphic, or change the graphic of one of the other modes to use the Hand.

Quote
Yes sorry I hadn't thought to mention the message where it would go lol. I would like the messages to disappear but to return a message from that person I send to.... after maybe 2 minutes. Thing is there may need to be a small address book in phone just for those few people character has to send to. Any ideas on this one?

How should AGS know what to reply with? What I mean is, should it just be a generic 'Message received' reply, or would you actually need to 'read' the message and reply accordingly? The first one fairly easy, the second one not so much.
I'd suggest using a ListBox to store the addresses. Then, when you click the 'Send' button, turn the smsMsg label off, and the ListBox on.
I know what you're thinking ... Don't think that.

gypsysnail

#10
Ok trying to get my head around the use interact button that should be put in inventory, but I am not understanding a thing sorry. I have clicked all links, none help me and the only link (Doracan's) is broken. What happens when I click the arrow on the phone in inventory is all it does is select the phone and I have tried to click ph on character, the gui for the phone close up view does not come up at all, nothing happens, just a phone cursor in the main game. Yes I had it in other clicks in the inventory interactions not knowing what for - thats how new I am to this. "Talk to" interaction would be good one, but how am I going to put a hand in the inventory pane? I havent reached this point yet so not experienced yet.

EDIT: I have just added the hand icon to the inventory gui and set the script in the floating box.... lets hope I can script it right in the global script.... ;)

RE-EDIT: Alright!!! Hand added to inventory and interaction as Talk to - Show gui. The gui shows up!! But now the problem is how to actually get this to work, typing message (limited to only 6 letters or to the end of the first line and then cant type anymore, wonder why this is?) and the sending and exits? This is the next step I need help with scripting in - as you can see below this message. And the animation doesnt work - only get the open view of the phone thats already in the gui,... hmmm........ and as said below when I add the send script I get the following:

Now I am getting this bother of an error message saying "local variable cannot have the same name as an import" what on earth does this mean? It relates to this code I added from here:
Code: ags
Code:
#sectionstart send_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function send_Click(GUIControl *control, MouseButton button) {
Ã,  String send = smsMsg.Text; // Copy message to 'send'
Ã,  label.smsMsg = ""; // Clear label

}
#sectionend send_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE


And how would I add the closing animation to the existing opening one, so that it doesnt close until I click exit?

Anyhow.... let me know what is going wrong? Thanks :)
Cheers, Snail
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Ashen

The 'local variable cannot have the same name as an import' error is because you're trying to use a String with the same name as a button (send). Changing the name of one of them (e.g. rename the button btnSend) or even just the capitalisation (send vs Send) should solve that. You shouldn't need to change the function name (send_Click), though. (Sorry, didn't bother to check the button name before. I also copy-pasted the wrong thing, so my correction was wrong - see the re-edited version above.)

Quote
And how would I add the closing animation to the existing opening one, so that it doesnt close until I click exit?

By putting the 'animate' code in the Exit button's function? I wasn't suggesting that that code should go in the same function as the 'animate open' code, just that that's probably what you would use, at some point. You might want to make a hide_mobph_window function (like you've got for open_mobph_window) that you can call from anywhere you'll want to close the phone (send, cancel, whetever) rather than having to repeat the code.

And I'm not sure why the animation isn't working ... Where & how are you turning the GUI on? Are you using the show_mobph_window function (which should run the animation), or could you just be using gMobph.Visible = true;?

The limit on the length of the message is most likely due to the width of the TextBox you're using to actually capture the input - because TextBoxes don't 'scroll' with long lines of text, once it's full, you're stuck. The simplest solution would probably be to just make it very, very wide - wide enough that you can fill the 'screen' (the Label smsMsg), at least.
I know what you're thinking ... Don't think that.

gypsysnail

Hi again :)
Thanks for clearing the send issue - thats been resolved so no more error message. Now when the gui pops up, I can only type a message but when I attempt to click on Send button the cursor changes to walk and then does nothing more, does not send message. Where could I be going wrong on this one? Its great we are doing well step by step :). Getting there....

Yes I did feel the closing animation should be in exit but I think I will go with show and hide mobph functions - you are right to ask me if I even have show mobph or visible=true and I unfortunately do have visible=true, so how to change to show and hide mobph only, etc so that its effective anywhere in the game as well?

At the moment my mobile visible is like this in that section as you can see in code:
Code: ags
#sectionstart interface_clickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function show_mobph_window () {
// is called when mouse clicks on mobile phone in inventory to interact
// with the mobile phone gui
Ã,  if(mouse.Mode == eModeTalkto){
Ã,  Ã,  Ã, Display("Glop glop... ah you open the phone with your slimy snail hands.");
Ã,  Ã,  Ã, gInventory.Visible = false;
Ã,  Ã,  Ã, gMobph.Visible = true;
}

Ã,  Ã,  Ã,  Ã,  Ã, gMobph.BackgroundGraphic = (128);
Ã,  Ã,  Ã,  Ã,  Ã, Wait(5);
Ã,  Ã,  Ã,  Ã,  Ã, gMobph.BackgroundGraphic = (124);
Ã,  Ã,  Ã,  Ã,  Ã, Wait(5);
Ã,  Ã,  Ã,  Ã,  Ã, gMobph.BackgroundGraphic = (125);
Ã,  Ã,  Ã,  Ã,  Ã, Wait(5);
Ã,  Ã,  Ã,  Ã,  Ã, gMobph.BackgroundGraphic = (126);
Ã,  Ã,  Ã,  Ã,  Ã, Wait(5);
Ã,  Ã,  Ã,  Ã,  Ã, gMobph.BackgroundGraphic = (127);

}
#sectionend interface_clickÃ,  // DO NOT EDIT OR REMOVE THIS LINE


and have a look at this part of the script in the on key press... just to give you an idea.....

Code: ags
#sectionstart on_key_pressÃ,  // DO NOT EDIT OR REMOVE THIS LINE
Ã,  function on_key_press(int keycode) {
Ã,  // called when a key is pressed. keycode holds the key's ASCII code
Ã,  if(gMobph.Visible == true){
Ã,  Ã,  Ã, if(keycode >= 0){
Ã,  Ã,  Ã,  Ã,  Ã,  smsMsg.Text = typesms.Text;
Ã,  Ã,  Ã, }
Ã,  }


And this - maybe you can help me define this part of the script for the phone gui I just found in my script:
Code: ags
#sectionstart typingtxt_ActivateÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function typingtxt_Activate(GUIControl *control) {
Ã,  
}
#sectionend typingtxt_ActivateÃ,  // DO NOT EDIT OR REMOVE THIS LINE


I can see there is nothing in that activate section, to be filled but exactly how? It seems it is for the text box in the phone gui where someone types the text to be sent via the phone.

Ah yes I would like to get some replies for each person like "Yes, I have been good my psychic skills are really good today and the crystal will work on this and that...." and I think each person (will be 4 people max in the address book already at the start of the game) that she has to txt to will reply and their first reply will be the most important text as it contains clues to the game. If the player sends the same person another txt, it will just come back as something like "thats good..." or "have a good day, love mum" every time she texts that person thereafter. Each of the 4 people will have their own message - the 1st one of each being very important but then 2nd, 3rd 4th, and so on times from that person will just have a generic message each (different to each other of course) for each day. Each day it will change and everyday 1st msg always important then after that, the msg will be the same. You know what I mean....? :) I think it d be a lot easier than having to have different messages all the time in one day from 4 different people, would be like 100's of different messages lol. :)
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Ashen

#13
Using show_mobph_window (and hide_mobph_window, when you make it, or in fact ANY custom function) is a lot like using a custom variable. Firstly you need to be sure it comes earlier in the script than anything that tries to use it. Secondly, if you're likely to want to use it in other scripts (i.e. Room Scripts) you'll need to make it Global. Unlike variables, functions don't need to be exported, so just go into the Script Header (Ctrl-H) and import it. Don't forget to include any parameters the function might have in the import (not a problem for show/hide_mobph_window, just a general note).

Since you only want to be able to use show_mobph_window from the Phone Inventory item (right?) you should be alright on both counts (Item Interactions are in the Global Script not Rooms, and are added below interface_click - where you've declared it), but double check to make sure.

So just open the interaction for the Phone Item, replace gMobph.Visible = true; with show_mobph_window();, and you sould be good to go.


The typingtxt_Activate function is linked to the TextBox, you're right - it's what gets run when the Enter key is pressed. Unless you want to allow the message to be sent that way, it can be left empty. If you do want to send messages that way, you'll need to copy the code from the 'Send' button into there. (What that code will be, I'm not sure - still working on it, unless someone beats me to it. How are you measuring 'days', since you'll obviously need to know what day it is, to change the messages?)
I know what you're thinking ... Don't think that.

gypsysnail

#14
Oh good thanks :) I am going to try what you have suggested and about the days measured. I want to measure days on the time - hours 24 hour clock. At the start of each day, the 1st message will be new from each person. The player only has to type anything and she will get the reply that holds the clue for the game and then after that in the day, any txt she sends to any of the people will just come back the same such as "oh thats good.. love mum" etc....Ã,  'Mum's first txt of the day would be more interesting than her 2nd, 3rd and so on txts in the rest of the day til the next day. Hope I explained properly :). And yes I want the mobile gui to pop up straight from the inventory pane when clicking hand on phone to use :).

I am not sure what you meant by
QuoteSo just open the interaction for the Phone Item, replace gMobph.Visible = true; with show_mobph_window();, and you sould be good to go.
? So I just delete the gMobph.Visible = true in the existing show_mobph_window section or add 'show_mobph_window' in the section where the 'visible' part in the script was?

Im afraid I am a bit confused as to what variables are exactly... I know they have values but what exactly are they? In context I need to really learn what this one means so I can code properly in the future etc. Yes this ph gui will have to be global as it will be used allÃ,  throughout the game so thats covered well :).

EDIT: I read the import and export links you gave me, a few times over and I think I know what variable is so its setting in. Goodo! :)

Ok... import... hmmmm I admit I am a bit lost there. I know the header script, this would be within the gui pane in AGS, but what to import for show_mobph? I will try and work it out, meanwhile let me know of the above including this. Parameters.... just trying to get my head around the exact meaning of parameters how it will relate to this one.

Ah the send code to be copied to the text box one... here it is: (I tried to send it by pressing enter after typing something but nothing.... so here goes, we cud try the following below):
Code: ags
#sectionstart send_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function send_Click(GUIControl *control, MouseButton button) {
Ã,  String send = smsMsg.Text; // Copy message to 'send'
Ã,  smsMsg.Text = ""; // Clear label

}
#sectionend send_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
and it is in its own section but hmmm I should copy it or just move it to this part of the script below?
Code: ags
#sectionstart typingtxt_ActivateÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function typingtxt_Activate(GUIControl *control) {
Ã,  
}
#sectionend typingtxt_ActivateÃ,  // DO NOT EDIT OR REMOVE THIS LINE


We're working as a great team! :):):) It looks like it is coming along well, with a few errors here and there lol. Will do some playing around with the script while I wait for your reply :)


RE-EDIT: tried import, does not work at all. All I get is this error saying "expected variable function after import, not 'show_mbph_window' so confused...? Don't quite understand.
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Ashen

Quote
I am going to try what you have suggested and about the days measured. I want to measure days on the time - hours 24 hour clock.

I understood that, I meant 'What system are you using to measure the time?', like are you using Gilbot's module (mentioned in this thread), something you've worked out yourself or gotten from somewhere else, or are you not that far along yet? If not, you need to consider (as KhrisMUC said in the other thread) how time will pass - 'Real Time'; one 'Game hour' is, say, 10 real minutes; number of Rooms visited (like Da_Elf); event triggered (once you've acheived a specific goal time advances, until then it's perminantly 4PM). And that other thread is probably the best place to ask for help with that, since it's already there.

Quote
So I just delete the gMobph.Visible = true in the existing show_mobph_window section or add show_mobph_window' in the section where the 'visible' part in the script was?

OK, now you've got me confused. show_mobph_window(); needs to go wherever it is you want to open the GUI. I believe that'll be the 'Talk to inventory item' Interaction for the Phone item. If that's what you meant by "add show_mobph_window' in the section where the 'visible' part in the script was" then yes, do that. If it wasn't, then No, don't. The code for the function itself is fine, you shouldn't need to change that at all.


Quote
Ok... import... hmmmm I admit I am a bit lost there. I know the header script, this would be within the gui pane in AGS, but what to import for show_mobph?

No, it's on the 'Script' menu, accessable from any pane, or by pressing Ctrl-H. Is the manual not clear on how to use it? To import show_mobph_window you'd just need to put:
Code: ags

import function show_mobph_window();


However, do you really need to make that function global? How will it be accessed? If it's only by the Phone Inventory Item, them there's no need to make it a global function - it and the Inventory interactions are both in the Global Script, already. You'd only need to make it global if it needs to be accessed by Room Scripts (e.g. an Object or Hotspot interaction), like if you had Payphones dotted around the game that you could send messages from.


I only brought up variables as I thought you understood them - apparently I just confused you more, sorry about that. Try reading the BFAQ Entry Working with variables: The Basics, and maybe Creating your own custom functions as well.


Quote
Ah the send code to be copied to the text box one... here it is: (I tried to send it by pressing enter after typing something but nothing.... so here goes, we cud try the following below):
CODE
and it is in its own section but hmmm I should copy it or just move it to this part of the script below?

Copy it over, as in the same code will need to be in both places. However, the current code really doesn't do anything - it just copies the message to a String, clears the screen, and then (because the String was declared inside a function) 'forgets' the message. It might be worth copying it over anyway, just so you can see if typingtxt_Activate works.
Also, at the risk of further confusion, if typingtxt_Activate is further down the script than send_Click, you could just call send_Click directly, meaning you won't have to worry about updating two lots of code. So you'd have:
Code: ags

#sectionstart send_Click  // DO NOT EDIT OR REMOVE THIS LINE
function send_Click(GUIControl *control, MouseButton button) {
  String send = smsMsg.Text; // Copy message to 'send'
  smsMsg.Text = ""; // Clear label
  // Or whatever it ends up being
}
#sectionend send_Click  // DO NOT EDIT OR REMOVE THIS LINE


And:
Code: ags

#sectionstart typingtxt_Activate  // DO NOT EDIT OR REMOVE THIS LINE
function typingtxt_Activate(GUIControl *control) {
  send_Click(control, eMouseLeft);
}
#sectionend typingtxt_Activate  // DO NOT EDIT OR REMOVE THIS LINE
I know what you're thinking ... Don't think that.

gypsysnail

Alright I'm afraid we are going to have to start afresh, this has gotten way too confusing for me :(. This show mobph part is starting to drive me crazy as I dont understand it. Here is how I would like the phone to work:

* in inventory pane in game, player to click on phone
* then phone gui shows up (and this is where the problem is - the animation does not happen at all, all I get is straight on open phone, no animation - maybe its not worth bothering with an animation as the phone seems ok open straight up. The only thing is the display message I called in the script does not show at all) code that included that is:
Code: ags
#sectionstart interface_click  // DO NOT EDIT OR REMOVE THIS LINE
function show_mobph_window () {
// is called when mouse clicks on mobile phone in inventory to interact
// with the mobile phone gui
  if(mouse.Mode == eModeTalkto){
     Display("Glop glop... ah you open the phone with your slimy snail hands.");
}
         gMobph.BackgroundGraphic = (128);
         Wait(5);
         gMobph.BackgroundGraphic = (124);
         Wait(5);
         gMobph.BackgroundGraphic = (125);
         Wait(5);
         gMobph.BackgroundGraphic = (126);
         Wait(5);
         gMobph.BackgroundGraphic = (127);

}
#sectionend interface_click  // DO NOT EDIT OR REMOVE THIS LINE
and now I think the animation is not working. I put the import function bit in header but does not make any difference. I feel really stupid as I thought I was doing ok but obviously not. Oh not meant to be in global script? Not sure anymore about any of it. :(

* then I would want the player to be able to send a message (but its not sending, and moreover that stupid text "Type Here" remains in the lable on the mobile screen (probably should remove via floating box in gui pane of AGS), making no difference for the text box's typing function below - I placed the text box to type in, at the bottom outside the phone, in its background. I can show a screenshot now:


      And when I click on the send button (biggest button in middle of phone button pad), all I get is the cursor change to walk cursor and nothing more

* and then I will want the player/character to receive a message back from that person and then read msg as it shows up, then finish with the phone after send and receive message done.

It seems the phone gui is totally functionless and useless. I am doing something stupidly wrong and its really frustrating me. I am so sorry, all the hard work you have done to help me with, my stupid brain has made the ph not work. Maybe we will have to start back up again, like I have typed above - to put it into a nutshell.
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Ashen

1. What interactions ('Talk to inventory item', 'Interact inventory item', 'Look at inventory item', 'Use inventory on this item', 'Other click on inventory item') do you have for the Phone Item? This is where the GUI gets switched on - animated or not - so this is where the problem is likely to be.

2. What is the 'Left click' property for the 'Send' button? (Will be 'Run script' - what you want - No action, or Set Cursor Mode - what it sounds like it is.) If it's set to 'Run script' and still isn't working, what is the 'Click' property? (We want it to be 'send_Click'.)
I know what you're thinking ... Don't think that.

gypsysnail

Yep ok here goes:

1. At the phone inventory, interactions are as follows:
Look at Inventory item: Game - display a message (9) which works well with the look icon.

Talk to inventory item: Game - Show GUI (4) - that is the phone gui. The talk to icon is actually a hand one, like you suggested yesterday so that part did work. But I have a feeling you are going to say the interactions I have chosen for this inventory to work its gui isn't really enough lol. I will wait for your reply on this interaction set.

2. ah... the send buttons click property in the floating box of the gui in AGS is set to send_Click and from what you have said, it doesnt sound right.... hmmm. Do you need to see the code again? If so, let me know and I will post it.
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Ashen

Quote
Talk to inventory item: Game - Show GUI (4) - that is the phone gui.

Well, see, there's your problem. That's an Interaction Editor command equivilant to gMobph.Visible = true;. What you'll need to do is make that a Run script interaction, edit the script and paste show_mobph_window(); (including the '();' bit) into it.

It's OK, 'send_Click' is right for the 'Click' property. (How does that not sound right? I said "We want it to be 'send_Click'.")
Now, what's the 'Left click' property (two rows above 'Click' on the floating box) set to?
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk