Expression editor question
I'm having problems with this expression.
I need to set a series of Alterable Values to the numeric conversion of a series of strings
value( "Hotspot1 WalkTo" )
value( "Hotspot2 WalkTo" )
value( "Hotspot3 WalkTo" )
value( "Hotspot4 WalkTo" )
value( "Hotspot5 WalkTo" )
etc.
but I'm trying to write a single action for many strings, so I need to enter the string's name through an expression which retrieves the first part of the name from an alterable string of the objects:
value( "Alterable String J( "Group.Indicator" )" + "WalkTo" )
but obviously I get a syntax error. I've tried many combinations of quotes and brackets without success.
Re: Expression editor question
You have to leave quotes off anything that's to be interpreted - in your example:
value( Alterable String J( "Group.Indicator" ) + "WalkTo" )
However, I'm still not sure what you're trying to do - the string "Hotspot5 WalkTo" (assuming the contents of Alterable String J is ("Hotspot 5 ") doesn't have a direct numeric conversion in the same way that, say, "6" or "94" do.
Re: Expression editor question
Quote:
Originally Posted by DavidN
You have to leave quotes off anything that's to be interpreted - in your example:
value( Alterable String J( "Group.Indicator" ) + "WalkTo" )
I've tried without quotes too, but I get a syntax error nonetheless.
Quote:
Originally Posted by DavidN
However, I'm still not sure what you're trying to do - the string "Hotspot5 WalkTo" (assuming the contents of Alterable String J is ("Hotspot 5 ")
yes, the contents of alterable string J of the Group.Indicator is a "Hotspot1", "Hotspot2", etc. different for each object, so combined with + " WalkTo" (preceded by a space) they should return the names of specific string objects I've created that contain the numeric values (when retrieved as values, since they're strings) I need.
value( Alterable String J( "Group.Indicator" ) + " WalkTo" )
or
value( [color:#FF0000]"[/color]Alterable String J( "Group.Indicator" )[color:#FF0000]"[/color] + " WalkTo" )
should work, but it doesn't, and it's a problem with quotes, I suspect, not with values, since the combined names refer to existing string objects containing text (numeric coordinates) retrieved as value. :crazy:
Re: Expression editor question
Try:
Str$( Val( Alterable String J( "Group.Indicator" ) ) )+ " WalkTo"
stephen1980
Re: Expression editor question
I don't think you can dynamically reference alterable strings, if that's what you're trying to do.
Re: Expression editor question
You can in the latest HWA build, but only by index. AltStrN$( "Active", > Enter value here <) for strings and AltValN( "Active", > Enter value here <) for values.
Re: Expression editor question
Really? I didn't know the names were even stored at runtime.
Re: Expression editor question
Quote:
Originally Posted by stephen1980
Try:
Str$( Val( Alterable String J( "Group.Indicator" ) ) )+ " WalkTo"
stephen1980
the expression editor says "Please enter a numeric expression"
Re: Expression editor question
Val(Str$( Val( Alterable String J( "Group.Indicator" ) ) )+ " WalkTo")
:grin: lol
Re: Expression editor question
Just tried that one too :(
EDIT:
I tried with "value", not "Val": with Val says it's a valid expression! I'm going to test it.
Re: Expression editor question
I have no idea what you're doing - adding "WalkTo" to a string and then converting it to a value is going to result in 0. Str$(Val(X)) is the same as X.
Re: Expression editor question
the result is 0 indeed
basically I'm trying to force some alterable values to be set to the numeric conversion of strings (= value("String name") ), and that's pretty usual, I suppose, and naturally it works, but I have lots of those: so the problem is that I'd like to get that string name composed by the content of an alterable string + a fixed portion of text. I hope it's clear enough... and I hope it's possible, or I'll have to create a quite big number of actions :cry:
Re: Expression editor question
Why do you need to do that?
Re: Expression editor question
because I'm setting up a sort of editor inside the game itself.
The numeric conversion of a string value() wants a name, the name of an existing string object:
value("Hotspot1 WalkTo")
and if I try to compose that name with two strings it fails to be recognized:
value("Hotspot1" + " WalkTo")
so the problem is not the alterable string in the first half of the expression,
value(Alterable String J( "Group.Indicator" ) + " WalkTo")
but the fact that I don't give to value() a plain object name.
Re: Expression editor question
Ah, you definitely can't dynamically reference objects by name. You could set an alterable string to a "name" instead, and dynamically reference them by that.
Re: Expression editor question
Quote:
Originally Posted by Jamie
Really? I didn't know the names were even stored at runtime.
Nope, as my post goes: You can in the latest HWA build, but only by index. AltStrN$( "Active", > Enter value here <) for strings and AltValN( "Active", > Enter value here <) for values.
Re: Expression editor question
Quote:
Originally Posted by Jamie
Ah, you definitely can't dynamically reference objects by name. You could set an alterable string to a "name" instead, and dynamically reference them by that.
but when I must set the alt value to the numeric conversion of a string object it asks for the object name: how can I give it that object name if -as you suggest- I have a string containing the name instead? MMF will check for the existence of a string object with that name, and it won't find it, because it's an expression and not an actual name. Right? I hope I'm wrong!
Re: Expression editor question
No. You can compare objects strings/values from within the expression editor.
You just need to make sure you select the right object first in your conditions so that it returns the name from he right object.
Re: Expression editor question
but is it possible in any way to compose an object's name with an expression?
let's say, I set a series of alt values to a corresponding series of strings (numeric conversion) whose names are composed by the alt values' names + another text string.
Re: Expression editor question
You can use ValueAdd to set and retrieve "extended alterable values" by name. That help?