Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: barefoot on Tue 15/02/2011 09:38:28

Title: Disable a ran option from room_RepExec
Post by: barefoot on Tue 15/02/2011 09:38:28
Hi,

my issue is about only running each ran once.. naturally ran 1 solves itself..  I have tried implementing DoOnceOnly but with no luck... Is there a way to disable a ran from the options as in option-off?



function room_RepExec()
{


    if (IsTimerExpired(1) == 1) {
    int ran=Random(2);
   
   if (ran == 0) {
     
    cuncle.Say("Er, um 1765");
    Display("You enter in the date");
    cSlocombe.Say("Nothing's happening");
    cuncle.Say("Let me think");
    SetTimer(1, 80);

}
    else if (ran == 1) {
    cuncle.Say("Er, um 1789");
    Display("You enter in the date");
    cSlocombe.Say("It's worked!!");
    object[0].Move(-282, 282, 1, eNoBlock, eAnywhere);
    object[1].Move(620, 282, 1, eNoBlock, eAnywhere);
    cuncle.FaceLocation(214, 70);
    RestoreWalkableArea(1);
   SetTimer(1, 0);

}
   

   else if (ran == 2) {
     
   cuncle.Say("Er, um 1799");
   cSlocombe.Say("Nothing's happening");
   cuncle.Say("Let me think");
   SetTimer(1, 80);
 
}
   
}
}


cheers

barefoot



Title: Re: Disable a ran option from room_RepExec
Post by: Khris on Tue 15/02/2011 09:58:19
There's no built-in way.

You can use bools though. Basically, put this above room_RepExec():

bool ran0, ran1, ran2;

Then for every option, do

    if (ran == 0) {
      if (ran0) SetTimer(1, 1); // already done, retry
      else {
        ran0 = true;   // set it to done
        cuncle.Say("Er, um 1765");
        ...
        ...


Not to be rude or anything, but when do you think are you going to get stuff like this (which is essential to programming) done by yourself?
This is basic logic, the prerequisite for any type of programming. You need to figure stuff like this out for yourself eventually, otherwise you'll always get stuck.
Title: Re: Disable a ran option from room_RepExec
Post by: barefoot on Tue 15/02/2011 10:14:13
Hi Khris

I'm trying to soak up the programming code language (syntax and stuff)..  perhaps I should spend much more time reading up about how to use and implement it? But you are right of course, so I will scourer wherever to learn it more.. until then... thanks..

Of course if we all knew it very well we would not need any help, but alas, I am but a mere aged mortal  :=

cheers

barefoot

Title: Re: Disable a ran option from room_RepExec
Post by: Khris on Tue 15/02/2011 10:29:01
This is not about knowledge or syntax, this is about logic.

You are fine with doing things in a set order and even some basic branching, but as soon as it gets a tad more complicated, you seem to be lost. I'm not telling you to stop making games altogether, but I'm wondering if it's the right thing for you if you have to rely on this forum almost on a daily basis.

You shouldn't be a carpenter if somebody else has to do all the sawing for you, you know?

Please don't be offended, and I know you aren't 25 anymore, I just wanted to point this out once.
Title: Re: Disable a ran option from room_RepExec
Post by: barefoot on Tue 15/02/2011 10:40:40
Hi Khris

point taken and no offence taken either.

I think the thing is is that I spend hours doing something only to find later on a better way of doing it.. such is life..

And I do intend to keep making games and with each one improve on my skills and gameplay.. So don't leave these forums   ;)

cheers again Khris...

barefoot
Title: Re: Disable a ran option from room_RepExec
Post by: Unai on Wed 16/02/2011 07:53:37
Hey barefoot,

I think you should buy a basic C Programation book with exercises and make them.

I think your problem is you never faced the very basic programing problems, and you just jumped to gaming, that's why you don't see the logic Khris talks about.