Using my inv on teh hotspot.

Started by Phemar, Thu 02/09/2004 18:14:56

Previous topic - Next topic

Phemar


I see no sensible reason as to why this doesn't work:

Script header:
short SharpBlade; //Whether the sharpener is a blade or normal.

Other Click on inv 10 (sharpener)
  if (GetCursorMode()==8) {//if open
    if (SharpBlade==0) {//if blade is not removed
      Display ("Mark opens the sharpener and removes the blade.");
      SetInvItemPic(10,92);SetInvItemName(10,"Blade");//Switch to blade
      SharpBlade=1;return;}
    else if (SharpBlade==1) {//if blade is removed
      Speak ("That doesn't open.");}}//unhandled event
  else if (GetCursorMode()==5) {//else if pick up
    Speak ("I already have it.");}//unhandled event

Interact with hotspot 1 (floss dispenser)
if (player.activeinv==10) {// If sharpener/blade
    if (SharpBlade==1) {//If blade is out sharpener
      Walk (123,103);
      AnimateCharacter(MAR,13,15,0);Wait(15);
      Display ("Mark places the blade in the dispenser.");
      bladein=1;LoseInventory(10);}//Set it so the blade is in
    else if(SharpBlade==0){//if blade is still in sharpener
      unhandled_inv();}}//unhandled event
else {
  unhandled_inv();}//unhandled event


Well that's basically it. All it gives me is unhandled_inv everytime I use inv 10 on the hotspot.

Please help. I really see absolutely no reason for this not to be working.

Thanks, z0r.

Snarky

The first question seems fairly straightforward. If your problem is that you pass the screen coordinates as room coordinates, the solution is to NOT DO THAT.

Instead, convert them like this:

FaceLocation(EGO, mouse.x + GetViewPortX(), mouse.y + GetViewPortY() );

Mr Jake

I think he means that the engine automaticly passes the co-ord as that

Phemar


no it works fine now ... How did I not think of that? I think it's 'cos I'm dumb...

now on to #2 folks...

Scorpiorus

#4
Try removing the last Wait(1) next to FadeIn(1), and see if it helps.
If it doesn't help then what if you remove the othe Wait(1) as well?

Phemar


It's definately not the wait commands, because FadeIn and FadeOut are blocking commands, acting like Wait.

Scorpiorus

I've just tried something similar and it doesn't flicker for me. What's the code behind the FaceLeft() function?

Phemar


Well yeah just remembered that now.

function FaceLeft () {
  FaceLocation (MAR, player.x-10, player.y);
  Wait (1);}

I tried without the wait and it just fades in to black and thern everything pops up, like instantly. I know this because I can only see my cursor fade...

Barbarian

Perhaps try setting the "Room transistion style" option to something different (such as Dissolve) and see if you still get the "flicker"?

You could also run the command from a script (Before Fadein for example), somthing like:

SetScreenTransition (TRANSITION_DISSOLVE);

You might also try using the "Resources split every MB" option (1 or 2 or 3 MB), and see if adjusting those settings will improve things for you?

I dunno, just some thoughts that might help.
Conan: "To crush your enemies, see them driven before you, and to hear the lamentation of the women!"
Mongol General: "That is good."

Blade of Rage: www.BladeOfRage.com

Gilbert

Hmmm I think ScreenTransition types won't affect background frame changing.
What colour depth was your game in?
If it's 256 colour, try to make the frames share the same palette when importing, if they use independent palettes I think that flash is hard to avoid.

Scorpiorus

#10
[EDIT]

Ah, yeah Gil is right.
FadeIn wouldn't work correctly unless a Wait() command was called. Wait(1) updates the screen (to reflect the changes being made by SetBackgroundFrame(0))but, here unfortunately, the palette is updated as well, so we see a new frame for a moment.

Sharing palette should do the trick but if you can't share the palette for some reason then the only way out is to write our own fadein/fadeout functions.

Take a look at the following thread: http://www.agsforums.com/yabb/index.php?topic=8484.msg103906#msg103906 in the Technical Archive forum.

There is a code I have written before. Using it we can have:

at the top of room script:
import function SavePalette();


on fading in/out:

SavePalette();
fadeout(0,0,0,63);


ReleaseCharacterView(MAR);
ReleaseCharacterView(BOS);
GUIOn(0);
FaceLeft();
SetLabelColor (0,13,40);
SetLabelText(0,13,"Walk to");

SetBackgroundFrame(0);

SavePalette();
fadein(0,0,0,1);


How does it turn out?

Phemar


Well, I guess that did the trick. There wasn't really need to post all that script, all I needed to do was to share the pallette.

Thanks guys!

Scorpiorus

Hehe, I just decided to give it a go and carry out a research on what can we do if backgrounds having different palettes is an issue, since anyway the fadein/out function had been written before. Then I shared the results. :)

Phemar


Scorpiorus

Hmm, what if you replace "if (player.activeinv==10)" with "if (character[GetPlayerCharacter()].activeinv==10)"?

Phemar


It doesn't make any difference.

Scorpiorus

Did you try that and it doesn't work? Hmm, try adding Display()s before each 'if' statement to display the condition value, like:

Display("player.activeinv=%d", player.activeinv);
if (player.activeinv==10) {// If sharpener/blade
Ã,  Ã,  Display("SharpBlade=%d", SharpBlade);
Ã,  Ã,  if (SharpBlade==1) {//If blade is out sharpener
Ã,  Ã,  Ã,  Walk (123,103);
Ã,  Ã,  Ã,  AnimateCharacter(MAR,13,15,0);Wait(15);
Ã,  Ã,  Ã,  Display ("Mark places the blade in the dispenser.");
Ã,  Ã,  Ã,  bladein=1;LoseInventory(10);}//Set it so the blade is in
Ã,  Ã,  else if(SharpBlade==0){//if blade is still in sharpener
Ã,  Ã,  Ã,  unhandled_inv();}}//unhandled event
else {
Ã,  unhandled_inv();}//unhandled event

Ashen

Three suggestions (don't know if any will help, but best to check):
1.
(What Scorpiorus said, while I was typing.)

2.
Try using the item name, rather than SharpBlade, e.g.:
Code: ags

if (player.activeinv==10) {// If sharpener/blade
 Ã, string name;
 Ã, GetInvName (10, name);
 Ã, if (StrComp ("Blade", name) == 0) {//If item is called Blade
 Ã,  Ã, Walk (123,103);
 Ã,  Ã, AnimateCharacter(MAR,13,15,0);
 Ã,  Ã, Wait(15);
 Ã,  Ã, Display ("Mark places the blade in the dispenser.");
 Ã,  Ã, bladein=1;
 Ã,  Ã, LoseInventory(10);
 Ã, }//Set it so the blade is in
 Ã, else unhandled_inv();
}
else unhandled_inv();

(not sure about the scripting)

3. (least likely)
QuoteInteract with hotspot 1 (floss dispenser)
(from your first post).
Check the code is in the 'Use inventory on hotspot' interaction, and not 'Interact hotspot'.
I know what you're thinking ... Don't think that.

Phemar


Scorpiorus: I did those debugging displays like you said, and when I pick up the sharpener SharpBlade is 0. That's fine.
When I open it SharpBlade is 1. That's fine.
When I look at it and it's open, it's 1. That's fine.
When I look at it and it's closed, it's 0. That's fine.
When I use it on Hotspot 1, it's 0. How does it go from 1 to 0? What sets it like that?

Ashen: Amazingly, this works. I's still like to find the origin of why it didn't work before though.

strazer

Maybe because declaring variables in the script header actually creates seperate variables for the global script (inv interaction) and each room (hotspot interaction)?

SMF spam blocked by CleanTalk