Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Zephyr

#1
Hi Matti,

You're a star! Thank you so much.
And thanks again to all of you - you've all been brilliant!  I'll try really hard not to bother you all again for a good long time!

-
Zephyr.   :-D
#2
Hi All,

Thanks, Crimson Wizard, that now works perfectly.  One last thing though - if you take a look at my original script you'll see that I made provision to lose each ingredient after its addition to the bag.  Now, of course, it no longer does this. How and where can I fit this back into the new code please?

Sorry to be such a pain in the ass!

-
Zephyr.
#3
Hi MorganW,

The code reads exactly as Khris posted earlier. The only difference I made was to substitute "cChristian" for "Player".

-
Zephyr.
#4
Aaargh!!!  Just hit a snag when I tried to run it.
Khris, it doesn't seem to recognise your "-1".  I put in everything (WITH proper indentation - you'd be proud!) in all the appropriate places, but here's what I got:

At the
Code: ags

if (ingredient_added[i]) {
    player.Say(String.Format("I already put %s in the bag.", ii.Name));
    return;

bit I got the error mssg:
"Error running function 'DrawstringBag_UseInv':
Error: Array index out of bounds (index:6, bounds:0..5)".

What went wrong? It made good sense to me!

- Zephyr.   (wtf)
#5
Hi Everyone,

Thank you for such a clear explanation about indentation!  That was one thing that was confusing me - being told to indent properly and yet seeing some of you adding a curly bracket right after the "if" bit.  Personally, I'd prefer to stick with the curly bracket on the next line, but I'm sure now that I understand what to do to make it clear. When I look at your coding, I can see what a difference it makes. Not that I intend to go in search of work in IT (this is strictly for fun for me!), but my fun isn't going to stop with this game and I'm always trying to learn more.

A special thanks to Khris for his coding example.  I think I get that and will give it a go.
You all ROCK!   (nod)
-
Zephyr,
:-* :-* :-*
#6
Hi Laura,

Right, I gotcha!  I have been finding it much better to indent the way I was (yeah I guess it was a bit unorthodox!) but I have to admit the way you do it makes it REALLY stand out, so I can definitely see the method in your "madness".  Time to learn new habits maybe.

Thanks again,

-
Zephyr.
:-*
#7
Hi Laura,

Thanks again for your help. Yeah, that makes perfect sense - I'll do that.
About the indentation - I actually have indented everything differently following your advice.  I guess not enough, huh?  OK, I'll make it much more obvious in the future.  You're quite right - it will make my code much clearer and easier to spot errors!   (nod)

What would I do without you?  ;-D

-
Zephyr.
x
#8
Hi again Everyone,

Here I am again with another bloody nested function - this one's a bit more complex though.

Here's what I have so far:

Code: ags

bool IsBagFull = false;
function iDrawstringBag_UseInv()
{
      if (cChristian.ActiveInventory == (iGroundNettles))
{
         cChristian.LoseInventory (iGroundNettles);
         BagEmpty = false;
}   
      if (cChristian.ActiveInventory == (iGroundBarberry))
 {
         cChristian.LoseInventory (iGroundBarberry);
         BagEmpty = false;
 }
      if (cChristian.ActiveInventory == (iGroundDust))
  {
         cChristian.LoseInventory (iGroundDust);
         BagEmpty = false;
  }
      if (cChristian.ActiveInventory == (iGroundBasil))
   {
          cChristian.LoseInventory (iGroundBasil);
          BagEmpty = false;
   }
      if (cChristian.ActiveInventory == (iGroundMandrake))
    {
         cChristian.LoseInventory (iGroundMandrake);
         BagEmpty = false;
    }
      if (cChristian.ActiveInventory == (iGroundLadySlippers))
     {
         cChristian.LoseInventory (iGroundLadySlippers);
         BagEmpty = false;
     }
         IsBagFull = true;
         Display ("The bag is full.");
         cChristian.LoseInventory (iDrawstringBag);
         cChristian.AddInventory (iFullBag);
}


I honestly thought I'd cracked this one on my own, but on running the game I find that I'm getting the "bag full" conditions when only ONE ingredient has gone into the empty bag!
Grrr! It's so annoying!  I'm pretty sure I've done something/neglected something really simple, but I can't see it for the life of me.
Any white knights/noble ladies out there who can help please?

-
Zephyr. :~(
#9
Hi Matti,

          I've had a good old play with your GUI idea and it works a treat - and so much simpler than the "change room" thing that I had before! Thanks so much for your help.  You're awesome!

- Zephyr.   ;-D  :-*
#10
Hi Matti,

          We can do that? Screen-sized??  Really?? Hmmm...I'm wondering now if I could make it look as good as what I have with a room...but the only little experiments I've made with GUIs haven't been terribly successful.  They always end up looking crappy to be honest - especially with text - but then again I didn't know you could work it that big.

Thanks, Matti. If nothing else, you've given me something to think about here.  Maybe I'll play with it.

- Zephyr.   (nod)
#11
OK, thanks Khris,

            It's very strange because the original code that I put in for a similar "book" room came from you and worked really well.  Since then, every time I've done similar rooms I've pretty much copy/pasted everything you taught me and it's been just fine until now. I'll have another play around with it and see if I can get to the bottom of it.

- Zephyr.
#12
Oh, right!  I don't know how to tell in which room the problem was occurring.  All I know is that the game was loading fine into the text room, displaying the "click to continue" etc., but after clicking - instant blackness, no cursor, no status bar, just music. 

I just don't get it!  But weirdly, your diagnostic has definitely fixed the issue.  And, as I said before, I have a few rooms like this that are working fine with my original scripting!

- Zephyr.   (wtf)
#13
Crimson Wizard, you're amazing!

            I put that line in and it works great!  I still don't understand WHY it worked or where my problem was, but I sure am glad to have it working again.  And yes, cChristian is my main player character.

Thank you very much for your time.

- Zephyr.   :-*
#14
Hi Cassiebsg,

           That part definitely still works.  I can enter the room that shows the text and says "click to continue".  It still displays just fine.  The problem is in the transition BACK to the original room.  On mouse click it just goes to black screen, although I do still have sound.

- Zephyr.
#15
Hi, Everyone,

           I really hope I'm not being too much of a nuisance but I've just been doing some game testing and I've come across a new error for something that was working perfectly until recently.  I have several books scattered throughout the game which, on interaction, change the room to show the books' texts (with no visible character).  In each case the previous room is restored on mouse click. 

I've coded each of these almost exactly the same (the only difference being room coordinates I want the character to go to) and they're all working perfectly - except for this one!  Can anyone see any errors in my script for this room please?

Code: ags

Overlay *textOverlay;

function room_Load()
{
         gStatus.Visible = false;
         textOverlay = Overlay.CreateTextual (155, 187, 200, eFontNormal, 53248, "Click to continue...");
}

function on_mouse_click(MouseButton button) 
{
       cChristian.ChangeRoom (cChristian.PreviousRoom);
       gStatus.Visible = true;
}


Thanks for your time and sorry to bother you again!

- Zephyr.    (roll)
#16
Thanks again, Everyone!

      You really are very patient teachers! I'm going to play about with block/no-block for a while now - seeing it "in action" will make it clearer, I think.
You've been amazing, all of you.

- Zephyr   (nod) :)
#17
Hi Laura,

Thanks again for that.  I'm also getting confused with the block/no-block thing.  The thing is, I also have an object animation running in the background and I wasn't sure if  the block command would interfere with that.  Could you maybe explain a little please?

Thanks again!
- Zephyr   :-\
#18
 :-D
Thanks so much everyone!  And a special thanks to Crimson Wizard and Laura Hunt for your straightforward, simple explanations and guidance. 
They do say that the older you get, the harder it is to learn a new language - and THIS old lady can confirm that!   (laugh)
I'm learning so much from you all though, so thanks again - I really appreciate it!

- Zephyr   :-* :-*
#19
Hi again Everyone,

         OK, so I'm building my first "shop" in my game, but it's a little complex in that 2 separate transactions can take place by interaction with only 1 hotspot.  This is further complicated by the fact that each transaction involves having:
a). the correct amount of cash
b). the correct inventory item.

I've messed around for hours trying to sort out the necessary nested functions and my brain is about to explode!
Here's what my last attempt was:-
Code: ags

function hFont_UseInv()
{      
      if (cChristian.ActiveInventory == (iEmptyBottle))
{
         cChristian.Walk (225, 168, eNoBlock, eWalkableAreas);
}
      if (Money >= 5)
{
         cChristian.LoseInventory (iEmptyBottle);
         cChristian.AddInventory (iHolyWater);
         Money -= 5;
         Display ("You have a bottle of Holy Water.");
}
    else
{
         Display ("Not enough money.");
}
      if (cChristian.ActiveInventory == (iStMichael))
{
         cChristian.Walk (225, 168, eNoBlock, eWalkableAreas);
}
      if ((Money >= 5)  // error msg reads "end of input reached in middle of expression"
{
          cChristian.LoseInventory (iStMichael);
          cChristian.AddInventory (iBlessedStMichael);
          Money -= 5;
          Display ("Your medallion has been blessed.");
}
     else 
{
          Display ("Not enough money.");
}
}


Can anyone please tell me where I've gone wrong and (in simple terms) WHY it's wrong?
Thanks again,
- Zephyr   :confused:
#20
Hi everyone,

Thanks again so much for your help. Sorry about the missing script - I must have mistyped as you said! 

@Crimson Wizard - Your suggestion about "import bool" is working perfectly, so many thanks for that.  I still get SO confused about what goes where and about the correct syntax!

@Khris - Yep! You got me there! It turns out that I'd mistakenly used ( instead of { in a couple of places.  Can't believe I made such a silly mistake (it just goes to show that scripting is NOT a good idea when you're tired!).

- Zephyr  :-[ :-*
x
SMF spam blocked by CleanTalk