Puzzle Spellcraft/Potion Macro

We are always looking for new tools to create to help facilitate the table top gaming experience. Let us know if you have an idea for a new gaming tool you'd like to see. (Note: this is NOT for feature requests on existing tools!)

Moderators: dorpond, trevor, Azhrei

Post Reply
Willbo
Kobold
Posts: 6
Joined: Fri Jul 08, 2016 3:12 pm

Puzzle Spellcraft/Potion Macro

Post by Willbo »

Hey guys :mrgreen:, anyone there could indicate me which way to go to develop a macro spells more or less with this idea:

Image

Where depending on a sequence that a button was pressed, a type of spell is cast, something perhaps as a array :shock: , if you understand me :lol:.

And following this idea a macro potions production:

Image

With perhaps a Drop down lists like this:

Image

where each space or square would have such a menu to which would add the item and the combination of the array would generate a potion at the end.
Thank ever since the attention, and I'm sorry for my English :oops:.
Last edited by Willbo on Sat Jul 30, 2016 6:42 pm, edited 1 time in total.

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

Re: Puzzle Spellcraft/Potion Macro

Post by wolph42 »

bit of work, but not too hard.

first one you can do with an html form where the 9 images are separate buttons each button with its own code e.g. 1,2,3,4,5 etc. and then a handler macro that each time a button is pressed it adds that number to stored number and if that sequence makes sense: spell, else nothing.
read the first link in my sig. check out 'forms tutorial' for the forms part.
storing the added numbers is best done on a lib:token property as thats accessible from any map.

the potions... i guess your on your way: dropdown list where you can choose OR if you want to go fancy: make each section a button which when pressed leads you to another html form with all ingredients (as button images) click one and your lead back to the original 'form' with the ingredient added: that is quite a hassle to build though!! but possible

Willbo
Kobold
Posts: 6
Joined: Fri Jul 08, 2016 3:12 pm

Re: Puzzle Spellcraft/Potion Macro

Post by Willbo »

wolph42 wrote:bit of work, but not too hard.

first one you can do with an html form where the 9 images are separate buttons each button with its own code e.g. 1,2,3,4,5 etc. and then a handler macro that each time a button is pressed it adds that number to stored number and if that sequence makes sense: spell, else nothing.
read the first link in my sig. check out 'forms tutorial' for the forms part.
storing the added numbers is best done on a lib:token property as thats accessible from any map.

the potions... i guess your on your way: dropdown list where you can choose OR if you want to go fancy: make each section a button which when pressed leads you to another html form with all ingredients (as button images) click one and your lead back to the original 'form' with the ingredient added: that is quite a hassle to build though!! but possible
Thank you friend :mrgreen: I'll break my head with it :oops: soon post my results or progress :lol: !!!

Willbo
Kobold
Posts: 6
Joined: Fri Jul 08, 2016 3:12 pm

Re: Puzzle Spellcraft/Potion Macro

Post by Willbo »

After checking countless tutorials ...
I must point out how nope I'm hahhaha ....
I'm caught in a point in question ....
I can not turn the image buttons on a link - to take me to another place or performs an action based on an external macro - note these examples here:

Image

here in case I could not link the inventory to the same button, so nor could advance the spellcraft moreover:

Image

I checked quite html tutorials on image buttons but got nothing relevant besides these results and the fact that I am a novice in this area makes this even more frustrating ... but do not want to give up, I need either help to make progress on that excuse me and thank you.

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Puzzle Spellcraft/Potion Macro

Post by Full Bleed »

Willbo wrote:I checked quite html tutorials on image buttons but got nothing relevant besides these results and the fact that I am a novice in this area makes this even more frustrating ... but do not want to give up, I need either help to make progress on that excuse me and thank you.
Take a look at macroLink.

So you could pull an image from a table like this:

Code: Select all

[h: inventory.icon = strformat('<img alt = "Inventory" border = 0 src="%s" />', tblImage("CharacterSheet", 1))]
And your macrolink would look like this:

Code: Select all

[r: macroLink(inventory.icon, "Inventory@Lib:Inventory", "", "", "")]
Clicking on the inventory image would launch the Inventory macro located on Lib:Inventory.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

Willbo
Kobold
Posts: 6
Joined: Fri Jul 08, 2016 3:12 pm

Re: Puzzle Spellcraft/Potion Macro

Post by Willbo »

Full Bleed wrote:So you could pull an image from a table like this:

Code: Select all

[h: inventory.icon = strformat('<img alt = "Inventory" border = 0 src="%s" />', tblImage("CharacterSheet", 1))]
And your macrolink would look like this:

Code: Select all

[r: macroLink(inventory.icon, "Inventory@Lib:Inventory", "", "", "")]
Clicking on the inventory image would launch the Inventory macro located on Lib:Inventory.

However only i had to add the id "impersonated" in order to correct the error
Error executing "getProperty": there is the impersonated token.

Code: Select all

[r: macroLink(inventory.icon, "Inventory@Lib:Inventory", "", "", "impersonated")]
Thank :D :mrgreen: uuuhhhhhhhhuuuuuu ....
it works, it works ....

I had found this link:
http://lmwcs.com/rptools/wiki/macroLink
previously in my travels ...
however to be an apprentice in the matter, it was like looking at a page in Japanese :lol: , if you understand me hahahahahah

I will follow your tip now in macro spell casting will soon return with the results and when everything is working, i will posting the link to download it ok.

Thank :D :mrgreen: uuuhhhhhhhhuuuuuu ....
it works, it works hahahahaha....

Willbo
Kobold
Posts: 6
Joined: Fri Jul 08, 2016 3:12 pm

Re: Puzzle Spellcraft/Potion Macro

Post by Willbo »

hi my friends !!! :lol:

Through trial and error, I walked up to this result:

https://drive.google.com/open?id=0B2Ddv ... VlPLTZnVTg

I used maptool-1.4.0.5

It is worth mentioning that there is still a lot I can not say whether this was the right way to do something and if it is, based on the evaluation of you, finish making possible combinations missing.
The example to posting has only horizontal combinations, still missing even if that way there that I did, which I'm sure must be outrageously wrong, but could not solve another hahahahaha mode, vertical and diagonal combinations.

I decided to post it anyway, so you can tell me how do you retrieve the value that is being add the tokem when preciona a sequence and so I click the button [submit/casting] he send this result to only chat instead the number itself a corresponding image of the table understand, tried to use the [getProperty] but it does not catch the number nor poco a related image.

Sorry for my bad english, I'm using google translator :oops: .

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

Re: Puzzle Spellcraft/Potion Macro

Post by wolph42 »

ok I had a look at your campaign file and you're in the right direction, but not quite there. You have created a 'handler macro' per button. That is terribly inefficient. You should create ONE handler macro to which is activated when a button is pressed. Every button can have its own identifier and is passed on as an argument to the handler macro. The handler macro then roughly does this:

Code: Select all

[storedSequence    = getLibProperty("storedSequence", "Lib:Spell")]
[buttonPressed    = arg(0)]
[newSequence    = listAppend(storedSequence, buttonPressed)]

[spellActivated    = 1]
[switch(newSequence):
    case "1, 2, 3": spell1();
    case "1, 8, 2": spell2();
    case "5, 4, 7": spell3();
    default:spellActivated = 0
]

[if(!spellActivated), CODE:{
    [if(listCount(newSequence) > 3), CODE:{
        <!-- assuming spell sequence is max 3 characters, if more are pressed, it automatically resets -->
        [newSequence = ""]
        [ broadcast("That sequence does not exist")]
    };{}]
};{
    <!-- spell is activated, so reset the sequence -->
   [ newSequence = ""   ] 
}]

[setLibProperty("storedSequence", newSequence, "Lib:Spell")]
<!-- refresh the button panel with the already pressed buttons (hence passed on as argument newSequence). In case newSequence is "" all buttons will be 'unpressed' -->
[macro("showSpellPanel@Lib:Spell"): newSequence]
  
something like that. This assumes that each spell is its own function, you can also use the code option in the switch statement and put the spell effect in that code block directly. Thats up to you.

This way you only need 1 macro with the form (which is created based on passed on arguments) and 1 macro handler which is always called when a button is pressed. It parses the argument and then automatically calls the 'form macro' again with the new sequence as argument.

note that i added a length check, you can leave that out (or not) and i didn't pay any attention to the last button (probly the 'activate spell') but this only means that you need to add that button identifier to the code in e.g. an if statement. (if that button is pressed, then get the sequence and check which spell it is, else just increase the sequence).

something like that.

edit:

here a working example of the 'showSpellPanel' macro:

Code: Select all

[h: spellCasting = getLibProperty("storedSequence", "Lib:Spell")]
<!-- a bit tricky, but this sequence creates variables fire=7, life=8, air=9 etc. -->
[h:buttonList    = "submit,earth,death,ice,spirit,balance,physical,fire,life,air"]
[h,count(10): set(listGet(buttonList, roll.count), roll.count)]
<!-- even trickier: here 9 is added to those variables IF it exists in the sequence -->
[h,foreach(num,spellCasting): set(listGet(buttonList, num), eval(listGet(buttonList, num))+9)]
[h:balance]


<!---------------------------  ACTIVE BUTTONS  ------------------------------>
[dialog("Spellcraft"): {
    <h2 align="center"><u>CASTING YOUR SPELL</u></h2>
    <TABLE border = 1 bgcolor="black"  align="center"><form>
        <h3 align="center">
        &nbsp &nbsp    [r: macroLink(strformat('<img alt = "Fire" border = 0 src="%s" />', tblImage("SpellButtons", fire)),"spellHandler@Lib:Spell", "all", fire, "impersonated")] &nbsp
                    [r: macroLink(strformat('<img alt = "Life" border = 0 src="%s" />', tblImage("SpellButtons", life)), "spellHandler@Lib:Spell", "all", life, "impersonated")] &nbsp
                    [r: macroLink(strformat('<img alt = "Air" border = 0 src="%s" />', tblImage("SpellButtons", air)), "spellHandler@Lib:Spell", "all", air, "impersonated")] &nbsp
        <br>
        &nbsp &nbsp [r: macroLink(strformat('<img alt = "Spirit" border = 0 src="%s" />', tblImage("SpellButtons", spirit)), "spellHandler@Lib:Spell", "all", spirit, "impersonated")] &nbsp
                    [r: macroLink(strformat('<img alt = "Balance" border = 0 src="%s" />', tblImage("SpellButtons", balance)), "spellHandler@Lib:Spell", "all", balance, "impersonated")] &nbsp
                    [r: macroLink(strformat('<img alt = "Physical" border = 0 src="%s" />', tblImage("SpellButtons", physical)), "spellHandler@Lib:Spell", "all", physical, "impersonated")] &nbsp
        <br>
        &nbsp &nbsp [r: macroLink(strformat('<img alt = "Earth" border = 0 src="%s" />', tblImage("SpellButtons", earth)), "spellHandler@Lib:Spell", "all", earth, "impersonated")] &nbsp
                    [r: macroLink(strformat('<img alt = "Death" border = 0 src="%s" />', tblImage("SpellButtons", death)), "spellHandler@Lib:Spell", "all", death, "impersonated")] &nbsp
                    [r: macroLink(strformat('<img alt = "Ice" border = 0 src="%s" />', tblImage("SpellButtons", ice)), "spellHandler@Lib:Spell", "all", ice, "impersonated")] &nbsp
                
        </h3>

        <h4 align="center">
        &nbsp &nbsp &nbsp[r: macroLink(strformat('<img alt = "Submit" border = 0 src="%s" />', tblImage("SpellButtons", 0)), "submit@Lib:Spell", "", "", "impersonated")]&nbsp &nbsp &nbsp
        </h4>
    </form></TABLE>
}]

 
these two macros are the ONLY two you need to use the panel. beyond this you only need the handling of the spells themselves.

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

Re: Puzzle Spellcraft/Potion Macro

Post by wolph42 »

I think im gonna use something similar for a game im designing so I though to take it to full length and get the core working. There are now three macros in total, minor incremental changes to what i posted before. but it entails all you need:

Code: Select all

[h:'<!-- ---------------------------------- showSpellPanel ---------------------------------------------- -->']

[h: spellCasting = getLibProperty("storedSequence", "Lib:Spell")]
<!-- a bit tricky, but this sequence creates variables fire=7, life=8, air=9 etc. -->
[h:buttonList	= "submit,earth,death,ice,spirit,balance,physical,fire,life,air"]
[h,count(10): set(listGet(buttonList, roll.count), roll.count)]
<!-- even trickier: here 9 is added to those variables IF it exists in the sequence -->
[h,foreach(num,spellCasting): set(listGet(buttonList, num), eval(listGet(buttonList, num))+9)]
[h:balance]


<!---------------------------  ACTIVE BUTTONS  ------------------------------>
[dialog("Spellcraft"): {
	<h2 align="center"><u>CASTING YOUR SPELL</u></h2>
	<TABLE border = 1 bgcolor="black"  align="center"><form>
		<h3 align="center">
		&nbsp &nbsp	[r: macroLink(strformat('<img alt = "Fire" border = 0 src="%s" />', tblImage("SpellButtons", fire)),"spellHandler@Lib:Spell", "none", fire, "impersonated")] &nbsp
					[r: macroLink(strformat('<img alt = "Life" border = 0 src="%s" />', tblImage("SpellButtons", life)), "spellHandler@Lib:Spell", "none", life, "impersonated")] &nbsp
					[r: macroLink(strformat('<img alt = "Air" border = 0 src="%s" />', tblImage("SpellButtons", air)), "spellHandler@Lib:Spell", "none", air, "impersonated")] &nbsp
		<br>
		&nbsp &nbsp [r: macroLink(strformat('<img alt = "Spirit" border = 0 src="%s" />', tblImage("SpellButtons", spirit)), "spellHandler@Lib:Spell", "none", spirit, "impersonated")] &nbsp
					[r: macroLink(strformat('<img alt = "Balance" border = 0 src="%s" />', tblImage("SpellButtons", balance)), "spellHandler@Lib:Spell", "none", balance, "impersonated")] &nbsp
					[r: macroLink(strformat('<img alt = "Physical" border = 0 src="%s" />', tblImage("SpellButtons", physical)), "spellHandler@Lib:Spell", "none", physical, "impersonated")] &nbsp
		<br>
		&nbsp &nbsp [r: macroLink(strformat('<img alt = "Earth" border = 0 src="%s" />', tblImage("SpellButtons", earth)), "spellHandler@Lib:Spell", "none", earth, "impersonated")] &nbsp
					[r: macroLink(strformat('<img alt = "Death" border = 0 src="%s" />', tblImage("SpellButtons", death)), "spellHandler@Lib:Spell", "none", death, "impersonated")] &nbsp
					[r: macroLink(strformat('<img alt = "Ice" border = 0 src="%s" />', tblImage("SpellButtons", ice)), "spellHandler@Lib:Spell", "none", ice, "impersonated")] &nbsp
		<br>
		&nbsp &nbsp &nbsp[r: macroLink(strformat('<img alt = "Submit" border = 0 src="%s" />', tblImage("SpellButtons", 0)), "submitSpell@Lib:Spell", "", "", "impersonated")]&nbsp &nbsp &nbsp
		</h3>
	</form></TABLE>
}]

Code: Select all

[h:'<!-- ---------------------------------- spellHandler (buttonPressed) ---------------------------------------------- -->']

[storedSequence	= getLibProperty("storedSequence", "Lib:Spell")]
[buttonPressed	= arg(0)]
[newSequence	= listAppend(storedSequence, buttonPressed)]
[broadcast(newSequence)]

[if(listCount(newSequence) > 3), CODE:{
	<!-- assuming spell sequence is max 3 characters, if more are pressed, it automatically resets -->
	[newSequence = ""]
	[broadcast("Sequence too long")]
};{}]

[setLibProperty("storedSequence", newSequence, "Lib:Spell")]
<!-- refresh the button panel with the already pressed buttons (hence passed on as argument newSequence). In case newSequence is "" all buttons will be 'unpressed' -->
[macro("showSpellPanel@Lib:Spell"): newSequence]
 
 

Code: Select all

[h:'<!-- ---------------------------------- submitSpell () ---------------------------------------------- -->']

[storedSequence	= getLibProperty("storedSequence", "Lib:Spell")]
[switch(storedSequence), CODE:
	case "1, 2, 3": {
		[broadcast("You activated spell 123")]
	};
	case "1, 8, 2": {
		[broadcast("You activated spell 182")]
	};
	case "5, 4, 7": {
		[broadcast("You activated spell 547")]
	};
	default:{[broadcast("That sequence is unknown")]}
]

[setLibProperty("storedSequence", "", "Lib:Spell")]
<!-- reset the button panel -->
[macro("showSpellPanel@Lib:Spell"): ""]
ive tested them and it works.

Willbo
Kobold
Posts: 6
Joined: Fri Jul 08, 2016 3:12 pm

Re: Puzzle Spellcraft/Potion Macro

Post by Willbo »

"wolph42"
hahahahaha. My friend, I sure would take a two lives and a half to get this result, you really was amazing.

I had found html tutorials about the switch, but all my conversions resulted in errors, so ended up with this result posted.
Based on your code posted I will terminate and return with a link to download beauty

these days to think about it, to use their tutorials in [Bag of Tricks] with this idea and create something like a key to unlock a door or trap if the player press the correct sequence.

and I will make a skill tree, then when finished will post the file ok. Thank you for your attention.

and with that idea, I will make a skill tree, then when finished, will post the file ok. Thank you for your attention.

I am glad that my idea has given you a way to project future.

Post Reply

Return to “Ideas for New Applications”