Is there a way to use a variable in a chat command?

Unofficial support for the creating and editing of metas.
HittingSmoke
Posts: 28

Is there a way to use a variable in a chat command?

Post #1 »

For example let's say I have meta profile 1, 2, and 3.

Meta profile 1 is a profile that is loaded by 2 or 3, then I would like 2 or 3 to return to 1 when complete.

The way I would like to accomplish this is to have profiles 2 and 3 set a variable when run like setvar[currentprof, 2] then when 1 is finished have it issue the chat command /vt meta load getvar[currentprof].

However there doesn't seem to be any way to interact with chat using expressions. Is this not possible?

Dmdtt
Moderator
Posts: 271

Post #2 »

yup I posted a write up about this actually in the meta tips and tricks thread. viewtopic.php?f=24&t=60

scroll down to where I explain examples for how to use a call. basic premise is though when you load meta 2 or 3 you setup a call and return, then in that meta for the return state it automatically /vt meta loads back into the previous meta.

another option is in meta 1 set variables for both profile and state name ex. setvar[Profile, HuntingMeta] that you want to return to then in meta 2 or 3 when finish ChatExpr \/vt meta load +getvar[Profile] then when the meta is finished it will load HuntingMeta

HittingSmoke
Posts: 28

Post #3 »

Dmdtt wrote:yup I posted a write up about this actually in the meta tips and tricks thread. viewtopic.php?f=24&t=60

scroll down to where I explain examples for how to use a call. basic premise is though when you load meta 2 or 3 you setup a call and return, then in that meta for the return state it automatically /vt meta loads back into the previous meta.

another option is in meta 1 set variables for both profile and state name ex. setvar[Profile, HuntingMeta] that you want to return to then in meta 2 or 3 when finish ChatExpr \/vt meta load +getvar[Profile] then when the meta is finished it will load HuntingMeta
I tried setting up something similar to your option with the call and I was having trouble getting timing right or something. Something things I could not pin down would put it into a loop where it would just do the first step in a route (a portal recall in this case) over and over again until running out of comps.

Option 2 is what I was trying to do. Had a few problems getting it to work related to escaping and understanding how the chatexpr differs from expr. Was also missing the + to cat. I got it after you showed me an example in /vcg.

Just to clarify I want to make sure I have your call meta option understood. I tried it but not before I changed up my meta to load profiles instead of having a ridiculous amount of states. I didn't think calling a state would work cross-profiles like variables will.

Let's say meta profile FiunPeas is a pea collecting profile and the primary running state is Hunting.

When packslots <=0 condition is met, FiunPeas would have a call meta state action with Selling in the first slot and Return in the second slot. The Selling state would only have one action, the chat command /vt meta load SellPeas.

In the SellPeas profile it would go do it's thing, then when it hits the Return From Call action it would actually switch back to the FiunPeas profile and set the state Return?

Dmdtt
Moderator
Posts: 271

Post #4 »

not exactly in meta 1 you run low on pack space you would send the call action at the same moment you also load the next meta

so All{Chat Command: /vt meta load SellPeas, Call: Selling, Return to: FiunPeasReturn} now the state you are returning to will be one you actually make in the SellPeas meta and it will have only 1 line Always Chat Command: /vt meta load FiunPeas

this way you only need to add 1 line to each of your hunting metas to add in a sell/recomp and 1 additional state for every hunting meta you add will also need to be added to the Sell/Recomp meta

HittingSmoke
Posts: 28

Post #5 »

Dmdtt wrote:not exactly in meta 1 you run low on pack space you would send the call action at the same moment you also load the next meta

so All{Chat Command: /vt meta load SellPeas, Call: Selling, Return to: FiunPeasReturn} now the state you are returning to will be one you actually make in the SellPeas meta and it will have only 1 line Always Chat Command: /vt meta load FiunPeas

this way you only need to add 1 line to each of your hunting metas to add in a sell/recomp and 1 additional state for every hunting meta you add will also need to be added to the Sell/Recomp meta
Hmm. I'll give that a try. I have the variable method working almost 100% now. Only have one little hiccup.

I can't seem to get \/vt meta load +getvar[location] in a chatexpr to work if I specify a state using your guide up above.

I tried "\/vt meta load +getvar[location]+, Set Meta State: Return" but it have an operand syntax error. I figured , or : just needed to be escaped (can't find a full list of characters that must be escaped on the wiki) but escaping either of them gave an invalid path error. The traceback doesn't include the actual path it's trying so I can't figure out exactly what's causing it. I've tried escaping , : and both. No luck.

Am I wrong in assuming the + is to concatenate the string ('/vt meta load ') and the variable ('getvar[location])? If so I'm using it incorrectly here. I use Python so that's what I thought was going on.

User avatar
HellsWrath
Site Admin
Posts: 389

Post #6 »

You would never type "Set Meta State: Return" in a chat command. That's just the text displayed in meta when you select the rule from the action dropdown.

You are correct, a + is used for concatenation.

HittingSmoke
Posts: 28

Post #7 »

HellsWrath wrote:You would never type "Set Meta State: Return" in a chat command. That's just the text displayed in meta when you select the rule from the action dropdown.

You are correct, a + is used for concatenation.
I copied that example from Dmdtt's guide linked above:
Switching to a different meta with a different starting state than Default


All: {Chat Command: /vt meta load MetaName, Set Meta State: dead}


this will allow you start directly in dead state when switching to a different meta rather than having it initially

load Default.

Dmdtt
Moderator
Posts: 271

Post #8 »

HittingSmoke wrote:
HellsWrath wrote:You would never type "Set Meta State: Return" in a chat command. That's just the text displayed in meta when you select the rule from the action dropdown.

You are correct, a + is used for concatenation.
I copied that example from Dmdtt's guide linked above:
Switching to a different meta with a different starting state than Default


All: {Chat Command: /vt meta load MetaName, Set Meta State: dead}


this will allow you start directly in dead state when switching to a different meta rather than having it initially

load Default.
yes that is an All{} with two separate meta actions being performed inside of it not a single chat command

make an all Action then add a Chat Command to the list and set it to /vt meta load MetaName

then add a Set Meta State action to the list for the all and select the state or create it if it doesn't exist in the current meta.