Gvar Scripting Problem -.-

Mr.Wolna

Vault Senior Citizen
Hi folks,

i have some trouble to getting my script working correctly.

There are two scripts.

Crane Control :
Code:
procedure use_p_proc begin
   gfade_out(3);
   set_global_var(GVAR_CRANE_CONTROL,1);
   gfade_in(3);
end

Car:
Code:
procedure critter_p_proc begin
   if (global_var(GVAR_CRANE_CONTROL) == 1) then begin
   destroy_object(self_obj); 
   end
end

it should work like this:

when I use a scenery object on the map (crane control)
with an other scenery object on the map (car) should be destroyed. But he did not accept my GVAR. Yes i update the global.h and even the vault13 but without Success. First i thought this is maybe because i use two different scripts (should not be, because gvars are global like the name says^^ )

But i even used it in the same procedure and had unfortunately no luck! So i do not see any error in the script, maybe you can help me out this dilemma.


so long

Mr.Wolna

edit: i don't know mayabe the procedure is false.
 
Turn on debug mode and do some debugging output. That should give you some clues on what's happening.
 
Instead of using "GVAR_CRANE_CONTROL" try gvar "number" from vault13.gam. Be sure that global.h points to the same gvar number as vault13.gam. Check this: mapper2.cfg --> run_mapper_as_game=1. Also there is limited number of new gvars you can add so you better replace old ones. Hope this helps.
 
Forgotten Knight said:
... Also there is limited number of new gvars you can add so you better replace old ones...

Not true. You can create new ones that go well past the original in the vault13.gam file (I have made room to accommodate almost 450 more for my project). Problem is that you must start a new game if you add a new line (i.e. add a new global variable) instead of just reusing/renaming an old one.
 
MIB88 said:
Not true. You can create new ones that go well past the original in the vault13.gam file (I have made room to accommodate almost 450 more for my project). Problem is that you must start a new game if you add a new line (i.e. add a new global variable) instead of just reusing/renaming an old one.

Ok, good to know someone tested this on a big scale :mrgreen:
 
First thanks for you answers. I found a other way to make this possible a better one with one script and no gvars:

here my procedure, when you like to see.



Code:
procedure use_p_proc begin
   variable car;
   variable crane;
   script_overrides; 
  // if  (global_var(GVAR_CRANE_CONTROL) == 1) then begin
   set_local_var(LVAR_CRANE_CONSOLE, (local_var(LVAR_CRANE_CONSOLE) + 1 ) );
  // end
   if (local_var(LVAR_CRANE_CONSOLE) == 1) then begin
      gfade_out(10);
      car:=tile_contains_pid_obj(18073,0,PID_CAR);
      crane:=tile_contains_pid_obj(16465,0,PID_CRANE_UP);
      destroy_object(car);
      destroy_object(crane);
      create_object(PID_CRANE_DOWN,16465,0);
      gfade_in(10);         
   end else
   if (local_var(LVAR_CRANE_CONSOLE) == 2) then begin
      display_msg(mstr(103));
      set_local_var( LVAR_CRANE_CONSOLE,1 );
   end   
end

thank your for your efforts
 
It's good you solved the problem, but that didn't make GVARs work in your case. You'll still have trouble using them.
 
taag said:
It's good you solved the problem, but that didn't make GVARs work in your case. You'll still have trouble using them.

Don't think so ;) It was AFAIK a problem with somethin other, vasue other scripts with gvar i made, work fine.
 
Code:
ERROR: attempt to reference global var out of range: 715
I'm getting this error in my mapper debug.log when my critter's script tries to set gvar no. 715 in VAULT13.gam. :question:
 
Huh. Never seen that error before. Please don't think that I am trying to insult you, it's just that sometimes we overlook the simplest things. That said, do you actually have at least 715 global variables? Or, perhaps there is a problem inside the script itself?
 
MIB88 said:
do you actually have at least 715 global variables

Yes, i've added new gvars and they work but any gvar >= 715 doesn't. I wasn't able to solve this for a long time so i started replacing old unused gvars. The script is as simple as it can be...

Code:
procedure node001
begin
   gsay_reply(1635,100);
   giq_option(4,1635,101,node991,50);
end

procedure node991
begin
   set_global_var(715,1);
end

Dialog with the NPC works but this error remains even after mapper reinstall. Like i said earlier, i've replaced old gvars and they work well but i would eventually come to the point where i can't find any place to put the new gvars in.
You know this could be some "isolated incident" since i'm using tons of modified files for my mod. Anyway, if no one else is having this problem you better --> :lalala:
 
Post here a fragment of vault13.gam where your 715th GVAR is defined. Dozen of rows should be enough, I think.
 
Back
Top