Hey!
Is it possible to change "hotspot[0]" in to a string name?
hotspot[0].RunInteraction(eModeLookat);
to
stringname.RunInteraction(eModeLookat);
can't get it to work!
You mean call hotspot functions on a named Hotspot variable rather than an index? Sure! Try this:
Hotspot* myHotspot;
// We need to assign some value to myHotspot. For example:
myHotspot = hotspot[0]; // Set it to hotspot[0]
myHotspot = Hotspot.GetAtScreenXY(mouse.x, mouse.y) // ... or the hotspot under the mouse cursor
myHotspot.RunInteraction(eModeLookat);
If you mean to use a string value (the hotspot's name, I assume), you can't do that so easily (though it is possible with a bit of work). Probably you're trying to do something the wrong way, so maybe explain what you're trying to achieve?
Edit: By the way, don't try to run any methods on the hotspot outside of the room it's in (e.g. by using myHotspot after you've left the room where you set it).
crap, I know it was a hook! :tongue:
I want to pass the hotspot name or number, from the rom over to globalscript and back again to the rom!?
Right now i pick up the name like this in a string!
Is the solution to use import and export?
location = Game.GetLocationName(mouse.x, mouse.y);
From my limited experience you can run Snarky's code from the Global Script and it will grab the relevant room hotspot just fine.
In these situations I just get the hotspot/object number then use hotspot[int].RunInteraction(eModeLookat);
I would avoid the whole string thing altogether. :)
yes it works, but i must be right over the hotspot!
When i click the hotspot i have a gui that's popup and there's
mHotspot.RunInteraction(eModeLookat);
when i click here am i not over that hotspot! :confused:
You are actually use
location = Game.GetLocationName(mouse.x, mouse.y);
to get the name of whatever the mouse is over into the string variable.
If the co-ordinates are on a GUI, a blank string is returned.
I'm not sure if it will make a difference,
Try to create another gui with a label, then you rename the label text in the editor with @OVERHOTSPOT@
This special mark get the name of the hotspot which the cursor is over.
Everything works, except that I can not pass my string from the room in to the Global Script.???
In the string i have the hotspot that's the mouse was over when i clict the hotspots in the room!
can i do that in a different way maybe?
I think that the method you are using is just fine.
If you need to pass your String from a room in to the Global script you can easily create a Global String from the editor panel (Global variables) and add a new variable String that you can access everywhere :)
Quote from: Martyn on Thu 05/11/2015 22:35:04
I want to pass the hotspot name or number, from the rom over to globalscript and back again to the rom!?
Right now i pick up the name like this in a string!
I'm still not clear on exactly what you're trying to achieve.
To identify a hotspot, you can use a pointer (
Hotspot*) or an integer (
hotspot[index], this number is identical to the
Hotspot.ID property). If you want to pass a hotspot from one function to another, you should use one of these, not any kind of string.
Refer to the manual:
http://www.adventuregamestudio.co.uk/site/ags/tutorial/ags/3/
http://www.adventuregamestudio.co.uk/manual/ags65.htm#topic57
In your room code, if you want to refer to a specific hotspot, look up the Name or ID value of the hotspot (in the room view, under the hotspot properties). For example, if you've created a hotspot called hCloud with ID 3, and you want to call a globalscript function with this hotspot, you can do:
// Global script
void globalscriptFunction(Hotspot* hotspot)
{
String hotspotName = hotspot.Name; // Same as @OVERHOTSPOT@ â€" if I remember correctly this is the "hotspot description" under the hotspot properties
String propertyValue = hotspot.GetProperty("propertyName"); // Assuming you've defined a custom property with this name
// TODO: Do something with one of these strings ...
}
// PS: Don't forget to import this function in the header!
And then in the room script:
// Room script
globalscriptFunction(hCloud);
or alternatively:
// Room script
globalscriptFunction(hotspot[3]);
Martyn, please describe in a general, non-tech way the game mechanic you want to implement.
It's probably something quite simple, for which there exists a simple, well-known solution.
Okay, nice! Thanks Vincent, thats was helping a bit :smiley:!
I realast now that i also misunderstand the Location Name thing!
I thought that it was like this "hotspot[0]"
myHotspot = Game.GetLocationName(mouse.x, mouse.y);
This works almost the way i want.
myHotspot = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
This get error, can not convert hotspot* to int or string! ???
is myHotspot a String, Int or a Pointer ??? ??? ???
Please explain what you are trying to accomplish, then someone could help you quite easily I'm sure.
First problem was Global variables. :smiley:
And the second is Game.GetLocationName/Hotspot.GetAtScreenXY.
Have tried both String and Int. But the "Game.GetLocationName" works fine.
But i cant figure out why i cant get something out of Hotspot.GetAtScreenXY??
Thanks anyway! :smiley:
Oh FFS! For the nth time: Explain what you're trying to do, the goal your code is meant to accomplish, not just the steps you've tried! If we knew what your end-goal is, it would almost certainly be very simple to implement, but you keep just mentioning individual methods, leaving us to guess what you're actually doing and trying to do with them.
Actually, I think I have a pretty good idea what the problem is, but as long as you're not cooperating I don't see why I should keep trying to help.
Also: The manual. If you're having a problem with Hotspot.GetAtScreenXY(), go look it up.
Wow, take it easy! :shocked:
Vince post fixt it, however I missed it at first, sorry!
QuoteI think that the method you are using is just fine.
If you need to pass your String from a room in to the Global script you can easily create a Global String from the editor panel (Global variables) and add a new variable String that you can access everywhere :)
OK, well that's the last time I'll try to help you.
However as Snarky prompt before I would check the (Custom Properties) because are very handly :)
You can create a custom property for "Default event", for example, and then have some simple code in the global script to use the setting accordingly.
You'll notice that characters, objects, hotspots, rooms and inventory items all have a "Properties" option in their property grids.
Click the 'Edit Schema' button and choose "Add property".
You can set various options about the new property for example:
Type - this specifies what type of property you want. "Text" gives you a larger text box which can store a
string.
To access the properties from the script, there are various script functions.
See their descriptions for how they work.
By the way, all that I have written is documented in the manual.
Quote from: MiteWiseacreLives! on Fri 06/11/2015 16:40:33
is myHotspot a String, Int or a Pointer ??? ??? ???
Should not be that hard to guess :D
Formerly known as global function GetLocationName,
static String Game.GetLocationName(int x, int y)
Sorry if you feel that way Snarky! :sad:
I was trying to explain, but its not easy when I miss something from the the beginning!
Vincent, true! I read the manual all the time but sometimes, I don't know really where the problem lies,
especially when iam not so skilled. :smiley:
Quote from: Vincent on Fri 06/11/2015 18:30:02
Quote from: MiteWiseacreLives! on Fri 06/11/2015 16:40:33
is myHotspot a String, Int or a Pointer ??? ??? ???
Should not be that hard to guess :D
Formerly known as global function GetLocationName,
static String Game.GetLocationName(int x, int y)
I asked this question because if he made it a String (which he keeps a close secret) myHotspot = Hotspot.GetAtScreenXY(mouse.x, mouse.y); will make no sense, myHotspot would have to be a Hotspot pointer.
ie:
Hotspot *myHotspot;
myHotspot = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
String myString;
myString = myHotspot.Name;
Vincent your only encouraging bad behaviour, Should not be that hard to guess :D ....
I think what Martyn needs, is to store a pointer to Hotspot in global script, and them use that pointer to get hotspot properties in room script :).
Quote from: Martyn on Fri 06/11/2015 18:43:57
Sorry if you feel that way Snarky! :sad:
I was trying to explain, but its not easy when I miss something from the the beginning!
Martyn, I think there is a misunderstanding here. What Snarky (and others) were asking you to do, is to explain what you want to have in a more general way, not related to any script mechanics (global variables and such).
:offtopic:
I'm not encouraging anyone to a bad behaviour as you claim.
Rather, I support all of you who say that need to be clear as well when you are intended to ask a question.
I want only to make you understand that what you asked could be answered shortly.
Because
Quote from: Martyn on Thu 05/11/2015 22:35:04
Right now i pick up the name like this in a string!
location = Game.GetLocationName(mouse.x, mouse.y);
After he
probably added a new global variable String called 'myHotspot'
Quote from: Martyn on Fri 06/11/2015 16:35:01
myHotspot = Game.GetLocationName(mouse.x, mouse.y);
This works almost the way i want.
Quote from: Martyn on Fri 06/11/2015 16:35:01
myHotspot = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
This get error, can not convert hotspot* to int or string! ???
Actually, Im not wonder what 'myHotspot' is, except the clarity of his intentions.
Yes, what CW said. A good technical question starts by explaining WHY you're doing what you're trying to do. I just saw this example from a reference librarian (whose job it is to help people find information they're looking for):
Bad way to ask for help: "Where are the books about dogs?"
Good way to ask for help: "Hi, I'm starting a dog grooming business and I need information on the local market for my business plan."
It should be obvious (though clearly it isn't), and it doesn't take any technical expertise to do.
For the technical part, post the code you've tried that isn't working IN CONTEXT. Not just a single line, but the code around it, the variable declaration, the functions it's trying to call, etc. Post the error message you get, too. If you had done that, I'm sure we would have found your mistake right away. (Although even after you've solved it, it's not exactly clear what the problem was, making this thread useless for anyone else who might be having similar difficulties.)
Anyway, lots of people don't follow this simple advice. What really got me mad was that you kept ignoring us when we asked you about it over and over:
Quote from: Snarky on Thu 05/11/2015 21:19:53maybe explain what you're trying to achieve?
Quote from: Khris on Fri 06/11/2015 11:12:39
Martyn, please describe in a general, non-tech way the game mechanic you want to implement.
It's probably something quite simple, for which there exists a simple, well-known solution.
Quote from: MiteWiseacreLives! on Fri 06/11/2015 16:40:33
is myHotspot a String, Int or a Pointer ??? ??? ???
Please explain what you are trying to accomplish, then someone could help you quite easily I'm sure.
You never answered this; never even acknowledged the question. That is just damn rude when people are trying to help you.
Quote from: Vincent on Sat 07/11/2015 09:56:58
I want only to make you understand that what you asked could be answered shortly.
Yes, I assumed (after the first couple of rounds of confused questions) that his immediate problem was that he'd defined myHotspot as a String instead of a Hotspot*, but changing that wouldn't be enough if the method in the GlobalScript expected a String. Which is why a fuller explanation of his process was necessary. I don't see how defining a global String variable would solve this problem anyway, so I'm actually skeptical that he has fixed the problem correctly.
Quote from: Snarky on Sat 07/11/2015 10:29:03
Yes, I assumed (after the first couple of rounds of confused questions) that his immediate problem was that he'd defined myHotspot as a String instead of a Hotspot*, but changing that wouldn't be enough if the method in the GlobalScript expected a String. Which is why a fuller explanation of his process was necessary. I don't see how defining a global String variable would solve this problem anyway, so I'm actually skeptical that he has fixed the problem correctly.
Yes, I think so too indeed.
A fuller explanation of the process that you are intended to achieve is compulsory.
In this way you allows people in the community to help you properly.
Also, this would avoid as well someone that have your same problem to collapse in a no achievement thread.
Because the goal to be achieved is not clear.
Sorry for the confusing mess!
I should have been more distinkt when the problem was solved att the reply 3 and 7!
I miss them att first! And then clerd out that the first question was not the real problem here:
QuoteIs it possible to change "hotspot[0]" in to a string name?
More like this:
QuoteI can not pass my string from the room in to the Global Script.
Yesterday i was at the school and could only write shortly, not as you guys, i'm impressed!
You are amazing here att AGS! :grin:
here is a description:
One click att a hotspot, A GUI windows poppups, in that window ther is a few moment and choises to do, and when the GUI is close, it go back and run the rest of the script in that hotspot.
The problem was that ther was no myHotspot to run myHotspot.RunInteraction with.
with help of Vincent tip of Global variabels and AGS manuals i get it to work.
Now it locks lik this and myHotspot goes over Global variabels:
hotspot[myHotspot].RunInteraction(eModeInteract);
It work perfect and I certainly think it can be solved in other ways too! :-)
Has difficult to explain in English from the beginning, so i'm definitely not gonna try again! :wink:
What can I say, sorry!
Wow, I'm surprised that actually works.
I would use the hotspot number or (more neatly) a pointer... but if it works with a String, party on ;)
Quote
After he probably added a new global variable String called 'myHotspot'
I can make pretty good guesses too, Vincent, but probably doesn't hold much water when trying to help with scripting.
I know your only being helpful, sorry I let this get me upset. :)
Quote from: Vincent on Fri 06/11/2015 18:30:02
Should not be that hard to guess :D
This was a humorous saying about the context unclear.
My intention was not to offend you or anything else.
I'm sorry you did misinterpreted it.
Quote from: MiteWiseacreLives! on Sat 07/11/2015 16:34:31
I can make pretty good guesses too, Vincent
Stupot+ should arranges the next tournament because I'd like to challenge you (jokes) :)
(http://s22.postimg.org/ga9l5kln5/Immagineags2cd.png)
Quote from: Martyn on Sat 07/11/2015 14:08:31
Now it locks lik this and myHotspot goes over Global variabels:
hotspot[myHotspot].RunInteraction(eModeInteract);
It work perfect and I certainly think it can be solved in other ways too! :-)
Quote from: MiteWiseacreLives! on Sat 07/11/2015 16:34:31
Wow, I'm surprised that actually works.
I would use the hotspot number or (more neatly) a pointer... but if it works with a String, party on ;)
It should not work with String.
Either myHotspot is an integer, or there is a bug in AGS script compiler. I would suggest testing whether this works with all hotspots before continuing.