"Else" trouble.

Here you can post threads requesting help on the official POL Ultima Online Emulator Core 098.

Moderator: POL Developer

Post Reply
Havoc
Neophyte Poster
Posts: 34
Joined: Mon Feb 13, 2006 1:35 pm

"Else" trouble.

Post by Havoc » Tue Sep 22, 2009 11:35 am

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: 302
Joined: Fri Dec 28, 2007 11:19 pm
Location: Montreal, Canada

Re: "Else" trouble.

Post by *Edwards » Tue Sep 22, 2009 12:33 pm

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
Location: Sweden

Re: "Else" trouble.

Post by Damien. » Tue Sep 22, 2009 12:34 pm

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 » Tue Sep 22, 2009 12:38 pm

@*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: 2736
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: "Else" trouble.

Post by Yukiko » Tue Sep 22, 2009 1:20 pm

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 » Tue Sep 22, 2009 1:48 pm

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