More questions on Forms and Frames

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
Templar
Cave Troll
Posts: 65
Joined: Wed Sep 20, 2017 9:24 pm

More questions on Forms and Frames

Post by Templar »

Hi yet again,

Sorry that I keep putting these posts up but I really want to get the most out of MapTools if possible.
Unfortunately we have our own custom system that we have been playing for about 30 years now so I can't really use the fantastic pre-made macros that are available for downloading.

I have pretty much got the hang of Dialogues and have made a few basic macros but am interested in trying to work with Forms and Frames.
Unfortunately there are some basic concepts I seem to be missing.

After looking at some more complex Campaign downloads I decided to start simple (yeah I know, Obvious right).

I have been looking at this tutorial :
http://www.lmwcs.com/rptools/wiki/Forms ... t.2Feditor

Simple as it is, I still have some issues.
As I understand it:
openFrame states that a form is going to be created and calls displayForm to do it.
displayForm does the following:
- Defines where the data from the form will be stored (by calling processForm): [h: processorLink = macroLinkText("processForm@Lib:token", "all")]
- Performs an action on the data (printing it out to chat window: <form action="[r:processorLink]" method="json">
- Sets up the input fields and the submit button.

<---openFrame--->
[frame("myForm"): {
<h3>my form:</h3>
[r, macro("displayForm@Lib:token"): ""]
}]

<---displayForm--->
[h: processorLink = macroLinkText("processForm@Lib:token", "all")]
<form action="[r:processorLink]" method="json">
Character name: <input type="text" name="charName"><br>
Strength: <input type="text" name="str"><br>
<input type="submit" name="myForm_btn" value="Okay">
</form>

<---processForm--->
<pre>
[r: json.indent(macro.args,2)]
</pre>

======================================================
Assuming I have this correct (no certainty there :) )
I was interested in trying to do something else with the data.
I would like to take the 2 pieces of data into separate variables, modify them and add them to a token property.
e.g.
[TokenCharName = charName]
[TokenStrengh = str]
Assuming these are 2 token property names.
I have tried this and nothing seems to work.

Unfortunately I can't work out where to do it.

Since this is the line that "does something": <form action="[r:processorLink]" method="json">
I thought it might be in here. Perhaps using "code:{}" ??

Is anyone keen on doing some explaining to me?

Templar
Templar

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: More questions on Forms and Frames

Post by wolph42 »

As I understand it:
0. openFrame states that a form is going to be created and calls displayForm to do it.
displayForm does the following:
1 Defines where the data from the form will be stored (by calling processForm): [h: processorLink = macroLinkText("processForm@Lib:token", "all")]
2 Performs an action on the data (printing it out to chat window: <form action="[r:processorLink]" method="json">
3 Sets up the input fields and the submit button.
0. no. basically you can copy paste the code of 'displayForm' completely inside the
{<h3>my form:</h3>
->here<-
}
It is however unwise to do that because of nesting levels of {}. So you call 'displayForm' which generates a bunch of html and the resulting html ends up between the {}. OpenFrame IS the macro that creates the form!
1. no, defines to which macro it will be send to when you click 'submit', nothing is stored.
it does this in this line:
<form action="[r:processorLink]" method="json">
2. no. it allows to user to interact with the form. The form (and the macro 'displayform') does NOTHING with the data!! It is literally 'a form'.
3. yes. (well... it generates the html for a submit button, that is send to 'openFrame' and that creates the fields and the button...but that's semantics).

and then there is "4.", which would be 'processForm'. This is the part where the result of the form is send. It is send in the form of a json object (IRC). So if you want to do anything with it, you will need to extract it first from the json and THEN you can do stuff with it (inside that macro).

note that this stuff is all on that wiki page, it helps to read the entire article, instead of only a part.

Templar
Cave Troll
Posts: 65
Joined: Wed Sep 20, 2017 9:24 pm

Re: More questions on Forms and Frames

Post by Templar »

Thanks for the answer, it has made a big difference in my understanding.

I actually did read the whole tutorial a number of times prior to putting the post up.
I just required your answers to my questions and then a re-look at the tutorial and I suddenly understand some of the statements there.

There is a bit of a paradigm shift with using frames as apposed to more linear programming.
This is not any kind of criticism. I think anyone prepared to put the time into creating tutorials like this deserves a medal but some people (I am obviously one) need a little more detailed explanation.

Interestingly one section I obviously did miss was "Don't forget the token context"
Using the technique in the link there and your explanation of how the data flows between macros I was able to update Token properties.

Templar
Templar

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: More questions on Forms and Frames

Post by wolph42 »

good to hear!

now if you think that wiki could use some extra lines here and there so the message gets across better: contact craig (send him a pm) for wiki access. In the early days you could simply register there, but due to numerous spam bots that option has been closed down.

this will be much appreciated!

/cheerz.

Post Reply

Return to “Macros”