How to make a localized string message contain a variable?

You need help? It's here!
LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

How to make a localized string message contain a variable?

Post by LegendaryAgent » Thu 13 Oct , 2011 3:02 am

Hey all, as usual thanks for all the great help ive been offered so far, i would like to know if what im trying to do is easy or not, basically im trying to make a dynamic message, what i mean with that is i want a message which will contain a variable, lets consider this:

Code: Select all

var int countpickuptimes

static function string GetLocalString(
	optional int                   iMessage,
	optional PlayerReplicationInfo RelatedPRI_1,
	optional PlayerReplicationInfo RelatedPRI_2
) {
	switch (iMessage) {
		case 0:
			return "You cant heal past your normal health limit with Health PowerUps.";

		case 1:
			return DynamicMessage;
	}

	return Super.GetLocalString(iMessage, RelatedPRI_1, RelatedPRI_2);
}

defaultproperties
{
DynamicMessage="You have picked up this item" $countpickuptimes $"."
}
if i attempt this it will start whinning about only beying able to access "default values of variables" in getlocalstring:
Error, You can only access default values of variables here

Im not following what on earth is going on here, is there a simple way to overcome this? whats causing this such extreme issue that it wont let me access variables outside that function?

Best Regards!

User avatar
Azarael
UT2004 Administrator
Posts: 5365
Joined: Thu 11 Feb , 2010 10:52 pm

Re: How to make a localized string message contain a variabl

Post by Azarael » Thu 13 Oct , 2011 12:13 pm

Which line produces the error? I suspect it's your default properties line. If that's the case, you need to construct your string somewhere else.

Code: Select all

var int CountPickupTimes;

static function string GetLocalString(
   optional int                   iMessage,
   optional PlayerReplicationInfo RelatedPRI_1,
   optional PlayerReplicationInfo RelatedPRI_2
) {
   switch (iMessage) {
      case 0:
         return "You can't heal past your normal health limit with Health powerups.";
      case 1:
         return DynamicMessage $ countpickuptimes $".";
      default:
         return "Unexpected value of iMessage.";
   }

  //return Super.GetLocalString(iMessage, RelatedPRI_1, RelatedPRI_2);
  //pointless
}

defaultproperties
{
DynamicMessage="You have picked up this item"
}

LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

Re: How to make a localized string message contain a variabl

Post by LegendaryAgent » Thu 13 Oct , 2011 4:49 pm

Azarael wrote:Which line produces the error? I suspect it's your default properties line. If that's the case, you need to construct your string somewhere else.

Code: Select all

var int CountPickupTimes;

static function string GetLocalString(
   optional int                   iMessage,
   optional PlayerReplicationInfo RelatedPRI_1,
   optional PlayerReplicationInfo RelatedPRI_2
) {
   switch (iMessage) {
      case 0:
         return "You can't heal past your normal health limit with Health powerups.";
      case 1:
         return DynamicMessage $ countpickuptimes $".";
      default:
         return "Unexpected value of iMessage.";
   }

  //return Super.GetLocalString(iMessage, RelatedPRI_1, RelatedPRI_2);
  //pointless
}

defaultproperties
{
DynamicMessage="You have picked up this item"
}


Hey the error comes from the case 1: return line, i have even tried leave it unconstructed, ive declared the var string just below the class extending line and left it with no value in defaultproperties, the problem is still the same :\

iZumo
Disappeared Administrator
Posts: 4196
Joined: Fri 19 Mar , 2010 1:21 am
Location: Earth
Contact:

Re: How to make a localized string message contain a variabl

Post by iZumo » Thu 13 Oct , 2011 5:09 pm

It's static function, so only default props can be accessed.

Code: Select all

var int CountPickupTimes;

static function string GetLocalString(
   optional int                   iMessage,
   optional PlayerReplicationInfo RelatedPRI_1,
   optional PlayerReplicationInfo RelatedPRI_2
) {
   switch (iMessage) {
      case 0:
         return "You can't heal past your normal health limit with Health powerups.";
      case 1:

         return default.DynamicMessage ....; <- the other must be passed via parameter.
      default:
         return "Unexpected value of iMessage.";
   }

  //return Super.GetLocalString(iMessage, RelatedPRI_1, RelatedPRI_2);
  //pointless
}

defaultproperties
{
DynamicMessage="You have picked up this item"
}

LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

Re: How to make a localized string message contain a variabl

Post by LegendaryAgent » Thu 13 Oct , 2011 5:52 pm

Izumo_CZ wrote:It's static function, so only default props can be accessed.

Code: Select all

var int CountPickupTimes;

static function string GetLocalString(
   optional int                   iMessage,
   optional PlayerReplicationInfo RelatedPRI_1,
   optional PlayerReplicationInfo RelatedPRI_2
) {
   switch (iMessage) {
      case 0:
         return "You can't heal past your normal health limit with Health powerups.";
      case 1:

         return default.DynamicMessage ....; <- the other must be passed via parameter.
      default:
         return "Unexpected value of iMessage.";
   }

  //return Super.GetLocalString(iMessage, RelatedPRI_1, RelatedPRI_2);
  //pointless
}

defaultproperties
{
DynamicMessage="You have picked up this item"
}

hmm alright so is there a solution to overcome this? or am i stuck with making 1 trillions cases? :P

LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

Re: How to make a localized string message contain a variabl

Post by LegendaryAgent » Thu 13 Oct , 2011 7:39 pm

LegendaryAgent wrote:
Izumo_CZ wrote:It's static function, so only default props can be accessed.

Code: Select all

var int CountPickupTimes;

static function string GetLocalString(
   optional int                   iMessage,
   optional PlayerReplicationInfo RelatedPRI_1,
   optional PlayerReplicationInfo RelatedPRI_2
) {
   switch (iMessage) {
      case 0:
         return "You can't heal past your normal health limit with Health powerups.";
      case 1:

         return default.DynamicMessage ....; <- the other must be passed via parameter.
      default:
         return "Unexpected value of iMessage.";
   }

  //return Super.GetLocalString(iMessage, RelatedPRI_1, RelatedPRI_2);
  //pointless
}

defaultproperties
{
DynamicMessage="You have picked up this item"
}

hmm alright so is there a solution to overcome this? or am i stuck with making 1 trillions cases? :P

Well guys if its trully that hard, then may i ask another question related to this class im making but unrelated to this specific message issue in this thread so i wont have to create a new one?

User avatar
Azarael
UT2004 Administrator
Posts: 5365
Joined: Thu 11 Feb , 2010 10:52 pm

Re: How to make a localized string message contain a variabl

Post by Azarael » Thu 13 Oct , 2011 9:29 pm

Go ahead.

LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

Re: How to make a localized string message contain a variabl

Post by LegendaryAgent » Thu 13 Oct , 2011 11:52 pm

Azarael wrote:Go ahead.
ty!

that powerup uses this line to add hp to the instigator:

Code: Select all

Instigator.GiveHealth(HPAmount, Instigator.HealthMax);
this works fine but, normally when u pickup a healt pack or health vial, the health hud icon animates for a second, i think the thing that does it is this:

Code: Select all

simulated static function UpdateHUD(HUD H)
{
    H.LastPickupTime = H.Level.TimeSeconds;
    H.LastHealthPickupTime = H.LastPickupTime;
}
how can i do that animation here? it adds hp and appears fine in the hud but it doesnt animate the hp(cross like) icon

Is this also complicated?

User avatar
Azarael
UT2004 Administrator
Posts: 5365
Joined: Thu 11 Feb , 2010 10:52 pm

Re: How to make a localized string message contain a variabl

Post by Azarael » Fri 14 Oct , 2011 1:20 am

You can most likely work this out from analysing how the health pickups work first.

LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

Re: How to make a localized string message contain a variabl

Post by LegendaryAgent » Fri 14 Oct , 2011 1:28 am

Azarael wrote:You can most likely work this out from analysing how the health pickups work first.
well they are an extension of tournamentpickup, maybe thats why but the item im making is not a tournament pickup, thats why im kinda confused, those 2 lines of code i have got from the healthpack and its super classes.

Post Reply

Who is online

Users browsing this forum: No registered users and 38 guests