Disable a ran option from room_RepExec

Started by barefoot, Tue 15/02/2011 09:38:28

Previous topic - Next topic

barefoot

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?


Code: ags

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



I May Not Be Perfect but I Have A Big Heart ..

Khris

There's no built-in way.

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

Code: ags
bool ran0, ran1, ran2;


Then for every option, do

Code: ags
    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.

barefoot

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

I May Not Be Perfect but I Have A Big Heart ..

Khris

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.

barefoot

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
I May Not Be Perfect but I Have A Big Heart ..

Unai

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.
I am a deeply superficial person

SMF spam blocked by CleanTalk