Object Vs room image question

Started by Shaque, Sat 18/11/2006 15:25:49

Previous topic - Next topic

Shaque

I have a problem with one section of my game. Eddie turns to his computer to check his emails, the monitor can be seen to switch on while he is online and then switches off when he turns the monitor off. Now...

1. First attempt to try this to work was to create a single image of the room, make an object invisible on it (the overlay for the monitor) so that when Eddie switches it on the object is shown, initially invisible. Since this action is only done once in the game, I have the object removed from the room. The problem is that when I interact with the monitor, I get a script error. I am sure I'm not doing it correctly, but I haven't found a solution in the forums so far. Basically, I want an object to show itself in the room (which is located over a room hotspot, where the initial interactions are run), then disappear once the scipt for the interaction is complete. I have added a conditional loop to not have this happen a second time, so I can discard this object after this interaction.

2. Second attempt to do this is to create the same image for the room, only in the second image I have the monitor turned on. Question: without animating the room, is there a way I can swap the room image from the original, to the monitor on image and back again? While I'm on this subject, is there any way I can place images in a room as overlays using the same interactions? Like non-object animated sprites.

Any help on this is much appreciated.
Knowledge is a right, wisdom is a choice.

monkey0506

How exactly did you "discard th[e] object?" You can't actually remove the object from the room or it will never exist at any point in your game.

What you'll want to do is read the manual entry for Object.Visible. When you want the mirror to turn on, you can use the Interaction Editor or in the script put:

Code: ags
oMonitor.Visible = true; // assuming oMonitor is the object's script o-name


To turn it back off you can do this:

Code: ags
oMonitor.Visible = false;


Alternately you could consider using a graphical overlay (Overlay.CreateGraphical) to temporarily hold the monitor's "on" sprite, however you can't define the interactions for an Overlay the same way you can with an Object (so if you need to interact with anything on the monitor you'd want to use an object).

Ashen

1. What was the error message? There's no reason what you describe can't work, so without knowing exactly what the error was it's difficult to say where you've gone wrong. Also, post the exact interactions (script or Interaction Editor commnds) you used.

2. Read the manual. SetBackgroundFrame will ock the frame to the one you set - just call it in one of the 'Player enters room' interactions to stop the animation from running, and again to change the state of the monitor. (There's no Interaction Editor equivilant way to do this.)
You can have Graphical Overlays as monkey said - but unless you code it to repeatedly change the graphic, they're not animated, and you can't interact with them. If you really don't want to use an Object for some reason (or can't, if you've reached the Room limit), you could maybe use a Character instead.
I know what you're thinking ... Don't think that.

Shaque

Like I said, I'm quite new to AGS and I have read the manual quite extensively. I must have missed the part about the graphic overlay, that seems like what I want it to do. I made a hotspot to interact with on the actual image of the monitor in the room. Once the interaction takes place, the overlay can appear to make it LOOK like the monitor is switched on, and then disappear once the string of commands are finished. I don't need this to happen anymore, but I want to keep the hotspot for future interactions, such as tellling the player character that action has already been done. I don't remember the error message I saw, since I tossed out the idea of having the monitor being an object. I do beg your forgiveness for my ignorance. I am usually very good with any kind of scripting and I tend to jump straight into a new engine thinking I can command it right away.

But since I'm here now and I got a few replies, I've been looking around for random scripts, but I can't find what I'm looking for anywhere in the forums. I would like to make a few NPC's walk randomly  around a room. Another thing... if my character changes to a top-down birds-eye view, I need to offset the walkable areas, because he only walks based on the bottom of the sprite (usually the feet). I know its a lot to ask for help on these, but I do try to find answers. It's just that I have not been able to and I don't want to be a pest asking random questions everywhere.
Knowledge is a right, wisdom is a choice.

monkey0506

#4
In regards to the birds-eye view, you could change the character's Baseline property to be halfway through his body that way AGS would determine his feet to be right in the center of his sprite (which in a bird's eye view they would be).

And from the way I'm reading your post, you no longer want to turn the monitor on? Or you've already figured it out?

In case I've misunderstood you, I'll post some example code (of using an Overlay):

Code: ags
// character turns on monitor function
if (DONE) { // DONE is a placeholder for whatever condition is set when the interaction has been completed
  Display("You're done with that for now.");
  return; // abort running this function, the interaction has already been completed
  }
Overlay* monitor = Overlay.CreateGraphical(X, Y, MONITOR_ON_SPRITE, true); // (X, Y) is the TOP LEFT corner of the monitor
                                                                           // MONITOR_ON_SPRITE is the slot number of the monitor's "on" graphic
// do interactions with monitor
// set DONE condition, i.e., you could define a variable: "bool HasUsedMonitor = false;" at the top of the script (outside of all functions)
//  then set it to true here: "HasUsedMonitor = true;", also replace DONE with HasUsedMonitor
//  "if (HasUsedMonitor)" is the same as "if (HasUsedMonitor == true)"
if (monitor != null) monitor.Remove(); // remove the monitor "on" graphic


Note that using an overlay the graphic will be drawn IN FRONT of EVERYTHING, all of your Characters and Objects will be behind the Overlay. If you need something drawn in front of the monitor while it is on, use an Object or Character instead of an Overlay.

Also, you don't need to apologize for not knowing everything about AGS. It's okay to ask questions if you can't find the answer. The rules are just that you're supposed to try and find it (i.e., read the manual and BFAQ, and do a forum search) before posting. If you find related threads but still have more questions it's okay to ask. ;)

Shaque

I didn't know that you could change the character's baseline. All this time I've cropped my character images to fit and the animation goes all wonky. So I leave a bit of space around the sprites and the character animated properly, but because of the space under his feet, the walkable area I shifted down a little. I had to do thid in the bird's-eye view walkable area too.

That was all very helpful, thanks. Now my monitor turns on, the character can walk away (and in front of) the computer, leave the room and return again to find the computer still on. He can switch it off and on again, but I gave it a conditional loop so I don't go through having to read the same email. Instead, I've decided to have regular access to the computer by making a whole list of variables and conditional loops. I'm only learning how to do this using the main AGS auto script functions, the only actual scripting I did was made the cursor change when I mouseover an entry/exit of the room. As frustrated as I can get, I'm still enjoying the learning.
Knowledge is a right, wisdom is a choice.

monkey0506

Quote from: Shaque on Thu 23/11/2006 21:42:38I'm still enjoying the learning.

That's the important bit isn't it?

Glad I could help. ;)

SMF spam blocked by CleanTalk