"Else" trouble.

Here you can post threads requesting help on the official POL Ultima Online Emulator Core 098.
Post Reply
Havoc
Neophyte Poster
Posts: 34
Joined: Mon Feb 13, 2006 1:35 pm

"Else" trouble.

Post by Havoc »

I'm trying to get this function to work. Right now, if I have under 100 karma, it will return the message "You do not have enough Karma!", but the character graphic will still change. If I have above 100 karma, I will get the success message, and also, be turned into a Rat. I know this is probably something easy that I am just looking over, but I'm just a bit confused that the conditions being met/unmet changes the message but not the affect.

Any help is appreciated!

Code: Select all

function RatForm (character)
		//
		const karmarequired := 100;
		var current_karma := CInt(GetKarma(character));
		character.oldgraphic := character.trueobjtype;
		character.graphic := 0xD7;
		character.color := 0;
		//
		if (GetKarma(character)>=karmarequired);
			PrintTextAbovePrivate(Character, "Your bones crunch as they bend and conform to the shape of a Rat.", Character);
    			SetObjProperty(character, "Graphic", cint(character.graphic));
    			SetObjProperty(character, "color", cint(character.color));
		else
			PrintTextAbovePrivate(Character, "Your Karma is not high enough!", character);
		endif
endfunction
User avatar
*Edwards
Forum Regular
Posts: 303
Joined: Fri Dec 28, 2007 11:19 pm

Re: "Else" trouble.

Post by *Edwards »

Code: Select all

function RatForm (character)
      //
      const karmarequired := 100;
      var current_karma := CInt( GetKarma( character ));
      var oldgraphic := GetObjProperty( character, "Graphic" );
      //
      if ( current_karma>=karmarequired )
         PrintTextAbovePrivate( Character, "Your bones crunch as they bend and conform to the shape of a Rat.", Character );
             SetObjProperty( character, "Graphic", cint( character.graphic ));
             SetObjProperty(character, "color", cint( character.color ));
             character.graphic := 0xD7;
             character.color := 0;
      else
         PrintTextAbovePrivate( Character, "Your Karma is not high enough!", character );
         character.graphic := oldgraphic ;
      endif
endfunction
Damien.
Journeyman Poster
Posts: 63
Joined: Thu Feb 08, 2007 11:14 am

Re: "Else" trouble.

Post by Damien. »

You don't need the properties if they are of no further use too :) Storing properties is bad! :D
Havoc
Neophyte Poster
Posts: 34
Joined: Mon Feb 13, 2006 1:35 pm

Re: "Else" trouble.

Post by Havoc »

@*Edwards

I had already attempted this.. for some reason, the initial character.graphic overrides anything after else. I still turn into a rat regardless of my karma.
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Re: "Else" trouble.

Post by Yukiko »

Assuming the original or truegraphic is what is wanted here, try:

Code: Select all

      else
         PrintTextAbovePrivate( Character, "Your Karma is not high enough!", character );
         character.graphic := truegraphic ;
      endif
or

Code: Select all

      else
         PrintTextAbovePrivate( Character, "Your Karma is not high enough!", character );
         character.graphic := CInt(GetObjProperty( character, "Graphic"));
      endif
Havoc
Neophyte Poster
Posts: 34
Joined: Mon Feb 13, 2006 1:35 pm

Re: "Else" trouble.

Post by Havoc »

So, it turns out I was a bit of an idiot -- i wasn't using var before character.graphic, so instead of considering the argument it was just switching to the graphic!

Thanks Yukkiko, Damien, and *Edwards!

Code: Select all

function RatForm (character)
      //
      const karmarequired := 100;
      var current_karma := CInt( GetKarma( character ));
      var oldgraphic := GetObjProperty( character, "Graphic" );
	var truegraphic := character.trueobjtype;
      //
      if ( current_karma>=karmarequired )
         PrintTextAbovePrivate( Character, "Your bones crunch as they bend and conform to the shape of a Rat.", Character );
             SetObjProperty( character, "Graphic", cint( character.graphic ));
             SetObjProperty(character, "color", cint( character.color ));
             character.graphic := 0xD7;
             character.color := 0;
      else
         PrintTextAbovePrivate( Character, "Your Karma is not high enough!", character );
         character.graphic := truegraphic ;
      endif
endfunction
This works perfectly :cheesy:
Post Reply