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!
I've removed the { and } around the .Visible assignment and fixed the indentation:
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;)
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!
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.
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.
Ya I deleted the old event first, and used the hot click. then added the code. still doesn't work. very odd
So does the player say "Okay"?
no he does not do anything at all
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?
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
Right, can you make sure the function is called at all? Like this:
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.");
}
}
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.
Silly question, but do you actually have a hComputerscreen hotspot painted in the room? It should be different colour from other hotspots.
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?
or sorry rather the object replaces the hotspot and crashes the game when I interface with it
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.
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.
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.
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!
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.
Quote from: Jojowl80 on Thu 28/05/2020 01:34:03the 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.
Not possible; you will always get an error message like "Variable 'hComputerscreen' is already defined" in _AutoGenerated.ash if you try to save your game like that.
Maybe you've entered the same name as Name and Description? But the latter isn't reflected in your script in that case.
Regarding the other problem I'm guessing you accidentally removed an object too many, and when re-adding the screen object, it ended up being object #0 or something? Anyway, you can avoid that problem if you name the objects (like oComputerScreen) then use that in the room script instead of the global array to access them.
As for the original problem, it sounds like you never clicked the hotspot in the first place (the function is linked but was never called, so clearly the hotspot wasn't clicked). One explanation is that you didn't actually draw a hotspot (but, say, a walkable area) and where clicking an area without a hotspot, another explanation is that the hotspot was covered by an object.
Provided you have entered a Description for your Hotspots and Objects, hovering them will show that Description in the Thumbleweed template's action bar. That way you will always know what you're going to click.