multiple object interface help

Started by Jojowl80, Wed 27/05/2020 02:09:43

Previous topic - Next topic

Jojowl80

hey! So I have two Identical lines of coding, one works(the television) the other does not. ID numbers are correct.

//Code
function hComputerscreen_AnyClick() {
  if(Verbs.UsedAction(eGA_WalkTo)) {

}
  else if(Verbs.UsedAction(eGA_Push)) {
    player.Say("Okay.");
{ object[1].Visible=true;
   
}
}}

function hTelevision_AnyClick() {
  if(Verbs.UsedAction(eGA_WalkTo)) {

}
  else if(Verbs.UsedAction(eGA_Push)) {
    player.Say("Okay.");
{ object[0].Visible=true;

}
}}

Not seeing the error. thanks!

Khris

I've removed the { and } around the .Visible assignment and fixed the indentation:

Code: ags
function hComputerscreen_AnyClick() {
  if (Verbs.UsedAction(eGA_WalkTo)) {

  } else if (Verbs.UsedAction(eGA_Push)) {
    player.Say("Okay.");
    object[1].Visible = true;
  }
}

function hTelevision_AnyClick() {
  if (Verbs.UsedAction(eGA_WalkTo)) {

  } else if (Verbs.UsedAction(eGA_Push)) {
    player.Say("Okay.");
    object[0].Visible = true;
  }
}


The first question is: did you type  hComputerscreen_AnyClick  yourself? Or did AGS insert that after you linked the function in the hotspot's events pane?

(also note that you can name objects and use their script name in room scripts, just like hotspots:  oTVScreen.Visible = true;)

Jojowl80

oh cool good to know! I did both instances. My first thought was that I put it in manually instead of the hot click, but it didn't seem to change anything. I will fool around with that some more. thank you very much!

Jojowl80

well I tried everything you suggested, I changed the name to Ocomputerscreen ,and hit the hot key in the events instead of manually typing it., and it still just wont work even with your updated code.
a mystery.

Cassiebsg

did it create a new function hComputerscreen_AnyClick() or not? If it did, did you move the code into this new function?

If you did not delete the previous text in the events (if there was one), it will not create a new one for you, instead it will try and jump to the old one.
There are those who believe that life here began out there...

Jojowl80

Ya I deleted the old event first, and used the hot click. then added the code. still doesn't work. very odd

Khris


Jojowl80

no he does not do anything at all

Khris

There's three possibilities:

1) the function isn't linked
2) you didn't use the Push verb
3) something else

1) is still the most likely candidate in my book; so just to be sure: when you go to edit hComputerscreen and click the lightning bolt icon, it says "hComputerscreen_AnyClick" next to "Any click on hotspot" in the Events table?

Jojowl80

that is correct is does indeed say that.
my push function works for all the other functions it is in. so I don't think it can be that.. so my guess is.. something else... quite the conundrum

Khris

Right, can you make sure the function is called at all? Like this:

Code: ags
function hComputerscreen_AnyClick() {
  Display("hComputerscreen_AnyClick called");
  if (Verbs.UsedAction(eGA_WalkTo)) {

  }
  else if (Verbs.UsedAction(eGA_Push)) {
    player.Say("Okay.");
    object[1].Visible = true;
  }
  else {
    Display("Hmm.");
  }
}

Jojowl80

Tried that and nothing showed up at all. so then I got the idea to try a simple hComputerscreen_Look Function and that didn't even work, ( I did not have one originally). So I can only imagine the function is not being called at all.

Crimson Wizard

Silly question, but do you actually have a hComputerscreen hotspot painted in the room? It should be different colour from other hotspots.

Jojowl80

Yes I do. Now I am having the problem where once I turn the Television screen on ( the one that worked) the function dissapears and the hot spot is there instead of the object. Maybe my problem is that I am putting objects on top of hot spots? but how else would I do it?

Jojowl80

or sorry rather the object replaces the hotspot and crashes the game when I interface with it

Crimson Wizard

Quote from: Jojowl80 on Thu 28/05/2020 00:45:55
Yes I do. Now I am having the problem where once I turn the Television screen on ( the one that worked) the function dissapears and the hot spot is there instead of the object. Maybe my problem is that I am putting objects on top of hot spots? but how else would I do it?

Oh, you want to have same hotspot area to click on, but there's an object appearing right over it, correct?

In such case for example you could set object non clickable in the properties, then clicks will go through them into hotspots.

Jojowl80

okay so here is the scenario. I have a TV hot spot and a button hot spot. the button turns the TV on. I want to make it so He can have the option of turning the TV back off. 

Jojowl80

okay so I changed the image of the screen object to a slightly different image. Now when I push the TV button its turning on the "computer" screen (not the television as it used to) and "calling" the function like Khris posted.  somehow the Object ID's got switched? maybe thats the problem is the Numbers are getting forced up or down by 1? This is very confusing for me.

Jojowl80

Progress!! also sorry for all he posts. first issue has been solved. for future reference the problem was I had the same name *hComputerscreen* for both the hotspot and the object, but for some reason it didnt give me the warning message that it was used elsewhere.

I would still like to be able to turn both the TV and screen back off by pressing the buttons tho. thanks for everyones help!

Gilbert

Just a reminder. You can edit your posts instead of posting new ones successively.
It is not mandatory to do that, but keeping stuff in one place when there are no posts from other people in between would help with readability.

SMF spam blocked by CleanTalk