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 - riseryn

#81
Thanks for your reply.

I have check all my code million times.
by default side =0;
only selected ball have side 1 or 2.

all my functions are in global script and imported in room script file.

Basically I click on hotspot to attribute a side and a ball.
one hotspot for each side and a global int for each side.
left GI 46 and right GI 47

the code when interacting each ball is:
(exemple with ball[4])

Code: ags


//in room script file
if(GetGlobalInt(46) == 0  && GetGlobalInt(47) == 0)

{Display("you must select a side first.");}

else{
  
  if(GetGlobalInt(46) == 1)
  {
    ball_side(4,1);    
    SetGlobalInt(47, 0);
    SetGlobalInt(46, 0);
    }
  
  if(GetGlobalInt(47) == 1)
  {
    ball_side(4,2);
    SetGlobalInt(46, 0);
    SetGlobalInt(47, 0);
    }
}   



//in main global script

function ball_side(int ball,int side)
{
ball[ball].side = side;

}

function Compareweight( w_left,  w_right)
{
  if(w_right < w_left){ return 1;}

  if(w_right > w_left){ return 2;}
}



function Weighing()
{
int i = 0;

int w_left = 0;
int w_right = 0;
int big_w = 0;


while(i<5){

if (ball[i].side == 1)
{w_left += ball[i].weight;}

if (ball[i].side == 2)
{ w_right += ball[i].weight;}
i++;
}

big_w = Compareweight( w_left,  w_right);
Display("Left %d", w_left);
Display("Right %d", w_right); 
return big_w;
}	


The last hotspot is used to calculate the weight on each side.

the code when interacting is:

Code: ags


int Bigger;

Bigger = Weighing();

if(Bigger == 1)
{
 Display("Side left."); 
 }
 

if(Bigger == 2)
{
 Display("Side right.");
 
}




everything seems to be ok but.....
:'(


#82
I have done the same thing in a game.
It works fine.
But I dont put the changeroom in a function and my character is stored in a room above 300 before I call it (not sure it's really important).
Hope that helps.
:)
#83
Hi

my function works but results are unexpected.
Code: ags

function Weighing()
{
int i = 0;

int w_left = 0;
int w_right = 0;
int big_w = 0;


while(i<5){

if (ball[i].side == 1)
{w_left += ball[i].weight;}

if (ball[i].side == 2)
{ w_right += ball[i].weight;}
i++;
}

big_w = Compareweight( w_left,  w_right);
Display("Left %d", w_left);
Display("Right %d", w_right); 
return big_w;
}	

ihave five balls
ball 1 to 4     ball.weight =1
ball 5            ball.weight =3


my problem
imagine a roberval balance where B1 B2.. are  ball[1].weight  ball[2].weight ..
 
|_B1_B2_|       |_B3_B5_|
        |___________|

first time calling function
    (2)                          (4)

No problem result expected

second time

|_B3___|       |___B5_|
        |___________|

results sometimes
   (1)                       (7)
sometimes
(3)                         (3)


Any idea  what I'm doing wrong?

Thanks
#84
thanks for your quick response

it works
#85
Hi
after wandering through the forum for one hour without finding a solution i'm completely lost.

the array ball is part of a structure and there is no problem with it.
it goes from ball[0] to ball[4]

int randi = Random(4);
int randj = Random(2)+1;
int k=0;
while(k<5)
{
if(k == randi){ ball[k].weight = randj;}

else{ball[k].weight =1;   }
k++;
}

when running, this code give me:
Error:  Array index out of bounds (index:4 bounds:0..3)

I dont understand why :(
maybe its very simple :)

Any suggestions?

Thanks
#86
Quote from: JRock on Sat 17/11/2007 17:52:08
Ok, but where do you put this code?  Do you put it right after the code for the new journal entry or in REPEATEDLY_EXECUTE?  Cuz I tried both and it still doesn't change to the new entry????

Yes you put it after the code for the journal entry.
:)
#87
ok your solution is better  :)

re thanks  :)
#88
ok i solve the problem with globalint


#sectionstart room_a  // DO NOT EDIT OR REMOVE THIS LINE
function room_a() {
// script for Room: Player enters room (after fadein)

if(getglobalint(1) ==0)
   {
    credit stuff
    ...
    SetGlobalInt(1,1);
    }

Credits[0].Run();

}
#sectionend room_a  // DO NOT EDIT OR REMOVE THIS LINE



thanks


#89
HI

if my credit is something like " ags"

first time it show
ags

second time it show
ags
ags

third time
ags
ags
ags

etc..
 
i try
Credits[0].Reset(0);
at the beginning of the script but it dont works.
Any idea?


Thanks                             
#90
Hi
I have solved this problem by changing:

JournalLabel.SetText(JournalModule.GetJournalCurrentText());

by
JournalLabel.Text=JournalModule.GetJournalCurrentText();

hope this help
#91
Hints & Tips / Re: A Tale Of Two Kingdoms
Wed 14/11/2007 12:41:42
Thanks  ;D
but i have to find a way to go there ^^
#92
Hints & Tips / Re: A Tale Of Two Kingdoms
Wed 14/11/2007 03:17:36
Hi
i'm stucked chapter 8

Spoiler

in the castle i have to find a door with the self bored stone but i can't find it.
Any clue?
[close]
SMF spam blocked by CleanTalk