Greetings
I REALLY tried hard to search exhaustively to find a solution but I am coming up dry.
I need to create a couple of objects that need to be able to turn off and on in every room I create. To be more exact: the player picks up a compass at one point in the game. Hitting f4 should turn the compass on.. the background of the compass is the face, and the foreground is the needle which wobbles back and forth over the right direction.
I had minor success creating an overlay in the global script that turns the face on, but then when you leave the room, of course the overlay goes away, and if you hit f4 to try and toggle it, it has lost the overlay. I tried importing and exporting the overlay but it doesnt seem to be something you can import and export.
In short, does anyone have ANY idea how I can accomplish this in the global script so I dont have to have the same two objects in every room? I can do that and have a function that is imported into every room that controls the direction and animation and such, but that seems like the wrong way to go.
Again, the goal is to be able to hit f4 to toggle two objects. One is the compass background and one is the needle foreground.. and if it is possible to animate the foreground with a view, that is the ultimate goal.
Any advice would greatly be appreciated!
Lou
You could use characters, and maybe use on_event (http://www.adventuregamestudio.co.uk/manual/TextScriptEvents.htm) to make sure they move rooms with the player character.
However, you'd probably be better using a GUI, with two Buttons for the Compass face and needle. A GUI has the other advantage of staying in the same place on-screen, even in a scrolling room (something you'd have to code around with objects). Button graphics can be animated with the Button.Animate (http://www.adventuregamestudio.co.uk/manual/Button.Animate.htm) command, but you'll probably still need SOMETHING in each room, to make sure the direction, etc, is right.
How far along with that are you, apart from the problem of how to display it? Do you have the 'Toggle' code for F4 worked out?
a gui.. man.. ok, thats a great idea, I dont know why I didnt think of it before. Thank you!
I am pretty far along in the game.. really, this game was originally done in SCI, but I ran into too many limitations, so I moved to ags. I took a break for about 4 months from the game and it caused me to forget a lot of things, and I just need to get my brain back into the possibilities.
I have the toggle key done for sure, and I have made several custom guis for different purposes, this just didnt cross my mind.
my main thing is to be able to keep the state of the gui between rooms. If you turn it on, it needs to stay on in the next room until you turn it off. I can probably figure that out, the first thing that comes to mind is doing an on_event when the room changes.
as far as the individual rooms, I have always planned just setting an initial variable of something like: compass_direction = [1-8 depending on the direction] so thats not a problem.
Thanks again!
Lou
Quote
my main thing is to be able to keep the state of the gui between rooms. If you turn it on, it needs to stay on in the next room until you turn it off.
GUIs should do that by default - you'd actually need to code it to make them TURN OFF when you change rooms, not stay on.
One thing to keep in mind is that it'll be a lot easier if the visibility type of the GUI (set in the Editor) is 'Normal'. If it's 'Popup Modal' key presses won't work when it's on, so you wouldn't be able to toggle if off with F4, without coding it yourself (e.g. using
IsKeyPressed in
repeatedly_execute_always).
right you are.. I was pleasantly surprised to find that to be the default behavior. Everything is working great now. I just have a function that you call in the room
update_compass(1) for example
the function updates the gui immediately if it is on, if the gui is off, it just stores the information for update the next time you turn it on.
thanks again for your help :)
Lou