[ZScript] Weird results with local variables

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: [ZScript] Weird results with local variables

Re: [ZScript] Weird results with local variables

by Graf Zahl » Sat Nov 12, 2016 8:22 am

Everything pointed out here should work correctly now

Re: [ZScript] Weird results with local variables

by D2JK » Fri Nov 11, 2016 7:34 pm

Huh, never thought of trying that... but you're right, thanks!

Re: [ZScript] Weird results with local variables

by Fishytza » Fri Nov 11, 2016 5:00 pm

D2JK wrote:If you try to use the two lines currently commented out, it should give an error message on startup: Unknown identifier 'invoker'.
If you put curly brackets around them then it works just fine.
(like so)

Code: Select all

{ A_ChangeVelocity(0,0, invoker.testing); }
{ A_LogInt(invoker.testing); }

[ZScript] Weird results with local variables

by D2JK » Fri Nov 11, 2016 12:28 pm

Code: Select all

Class NewPlayer : DoomPlayer
 {
  Default
   {
    Player.StartItem "NewPistol";
    Player.StartItem "Clip", 50;
    Player.WeaponSlot 2, "NewPistol";
   } 
 }



Class NewPistol : Pistol
 {
  int testing;
  States
   {
    Select:
     TNT1 A 0  {  invoker.testing = 9;  }
     Goto Super::Select;
    Fire:
     TNT1 A 0 A_ChangeVelocity(0,0, testing);
//   TNT1 A 0 A_ChangeVelocity(0,0, invoker.testing);
     SHTG A 35 A_LogInt(testing);	 
//   SHTG A 35 A_LogInt(invoker.testing);
     Goto Ready;
   }
 }
This will log "0" (zero) in the console, and A_ChangeVelocity has no effect. In my actual mod, the number logged in the console is random and very large (sometimes negative), such as 217 990 448.

If you try to use the two lines currently commented out, it should give an error message on startup: Unknown identifier 'invoker'.

Top