Building my first Framework(Help!)

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
armlessbastard
Kobold
Posts: 18
Joined: Tue Nov 10, 2009 2:53 pm

Building my first Framework(Help!)

Post by armlessbastard »

Hello to anyone interested in helping a guy out. My programming skills are all but faded and looking for even a basic framework for CyberPunk 2020 is impossible. I'm not looking to do anything fancy and I have made some basic steps, im looking for a way that people can make macro's for all of their different weapons. I managed to make a dialog box that inputs and saves values for a weapon some one might use following this tutorial on making dialog boxes.

http://forums.rptools.net/viewtopic.php?t=6107

But now I need to grab all of that data and turn it into a Macro that can be saved on the characters token so they can fire their weapon. Any help or guidance on where or how to begin?

User avatar
mfrizzell
Dragon
Posts: 762
Joined: Sat Feb 13, 2010 2:35 am
Location: California

Re: Building my first Framework(Help!)

Post by mfrizzell »

The best place to start is looking at other frameworks. See how they do things. Copy what will work for you and build on what you need to make it fit.

Ask specific macro questions. Unless someone else has an interest in your game, I don't thing you'll find anyone to build a frameworks for you.

You will get lots of input and help for very specific questions.

Good luck
DCI/RPGA# 7208328396 Skype ID mfrizzell77
Characters:
Strabor - Dwarf Avenger 5th Level
Tikkanan - Human Warlock 2nd Level
----------------------------------------------------
"People are more violently opposed to fur than leather because it's safer to harass rich women than motorcycle gangs."

meshon
Cave Troll
Posts: 75
Joined: Fri Mar 26, 2010 10:54 am
Location: AB, Canada

Re: Building my first Framework(Help!)

Post by meshon »

You might want to try using Wiki: createMacro() to allow players to build their own macros from input information. This is an old one I built a long time ago (it was build 76!) but you might find it useful as an example. It opens an input dialog and then builds a macro based on what was input.

Code: Select all

<!--This macro builds basic attack macros from input information-->

[h: defenseList = '["AC", "Fortitude", "Reflex", "Will"]']
[h: defenseChoices = json.toList(defenseList)]

[h: diceList = '["d4", "d6", "d8", "d10", "d12", "d20", "d100"]']
[h: diceChoices = json.toList(diceList)]

[h: penaltyList = '["None", "TempAllDefenses", "TempAC", "TempFort", "TempRef", "TempWill", "TempAttackModifier", "TempDamageModifier", "TempSavingThrowMod","DamageResistAll"]']
[h: penaltyChoices = json.toList(penaltyList)]

[h: stateList = getTokenStates("json")]
[h: stateChoices = json.toList(stateList)]

<!--This displays the input, and aborts the macro if you hit cancel-->
[h:status=input(
"powerName | Enter Power Here | Power Name | TEXT |",
"targetType | PCs Only, NPCs Only, All Creatures | Choose targets from | LIST | SELECT=1",
"totalAttackBonus | 0 | Total Attack Bonus | TEXT |",
"targetedDefense | " + defenseChoices + " | Targeted Defense | LIST | SELECT=0 VALUE=STRING",
"damageSettings | 1 | Does this power do damage? | CHECK",
"DamageDiceSides | " + diceChoices + " | Damage die | LIST | SELECT=2 VALUE=STRING", 
"DamageDiceTimes | 1 | How many Dice? | TEXT", 
"DamageDiceModifier | 0 | Damage modifier | TEXT",
"brutalBump | 0 | Brutal Weapon Value | TEXT",
"powerRange | 1 | Power Range | TEXT |",
"penaltyType | " + penaltyChoices + " | Penalty Type | LIST | SELECT=0 VALUE=STRING",
"penaltyModifier | 0 | Penalty Value | TEXT |",
"appliedState1 | None," + stateChoices + " | State to apply (1) | LIST | VALUE=STRING",
"appliedState2 | None," + stateChoices + " | State to apply (2) | LIST | VALUE=STRING",
"additionalInformation | None | Additional information | TEXT |"
)]
[h:abort(status)]

[h: penaltyType = if(penaltyType == "None", "", penaltyType)]
[h: additionalInformation = if(additionalInformation == "None", "", additionalInformation)]
[h: appliedState1 = if(appliedState1 == "None", "", appliedState1)]
[h: appliedState2 = if(appliedState2 == "None", "", appliedState2)]

[h: DamageDiceTimes = if(damageSettings == 0, 0, DamageDiceTimes)]

[h: brutalValue = brutalBump+1]

[h: placeholder1 = 9]
[h: placeholder2 = 7]

[h: macroVariables = strformat("
[h: powerName = '%s']
[h: totalAttackBonus = %d]
[h: targetedDefense = '%s']
[h: DamageDiceSides = '%s']
[h: DamageDiceTimes = %d]
[h: DamageDiceModifier = %d]
[h: powerRange = %d]
[h: penaltyType = '%s']
[h: penaltyModifier = %d]
[h: additionalInformation = '%s']
[h: targetType = %d]
[h: appliedState1 = '%s']
[h: placeholder1 = %d]
[h: appliedState2 = '%s']
[h: brutalValue = %d]
[h: damageSettings = '%s']
[h: placeholder2 = %d]
[h: attackPowerInfo = json.fromList('' + powerName + ',' + totalAttackBonus + ',' + targetedDefense + ',' + DamageDiceSides + ',' + DamageDiceTimes + ',' + DamageDiceModifier + ',' + powerRange + ',' + penaltyType + ',' + penaltyModifier + ',' + additionalInformation + ',' + targetType + ',' + appliedState1 + ',' + placeholder1 + ',' + appliedState2 + ',' + brutalValue + ',' + damageSettings + ',' + placeholder2 + '')]
[macro('autoAttacker@Lib:XGame'): attackPowerInfo]",
 powerName, totalAttackBonus, targetedDefense, DamageDiceSides, DamageDiceTimes, DamageDiceModifier, powerRange, penaltyType, penaltyModifier, additionalInformation, targetType, appliedState1, placeholder1, appliedState2, brutalValue, damageSettings, placeholder2)]

[h: createMacro(powerName, macroVariables, "autoExecute=true;color=red;group=Attacks", ";")]

[r, s, g: "creates " + powerName + " macro."]
 
And definitely you will get good answers if you find some specific questions. Best thing is to start building and ask when you get stuck, and often you will find answers by searching the forums.

good luck!

Meshon

armlessbastard
Kobold
Posts: 18
Joined: Tue Nov 10, 2009 2:53 pm

Re: Building my first Framework(Help!)

Post by armlessbastard »

thanks mfizzle - its hard to be precise when im not sure what to do with half the variables but ill try to give a bit more information.

in Campaign Properties, I created a new set called "PC" this has all the usual stuff in it, general attributes and so forth (That part i got). I also added a variable called 'weapons' to this list. using a few macro's I found in a tutorial I was able to use a counter and add as many weapons as I want to this variable - each with its own Weapon accuracy, damage dice and range. It works great - here is an example of a sample token that has made some weapons and what the input text of those weapons looks like in token properties.

Code: Select all

NumWeapons=5 ; Weapon1Name=Glockx2 ; Weapon1Damage=2d6 ; Weapon1WA=1 ; Weapon1Range=20m ; Weapon2Name=Uzi ; Weapon2Damage=1d6 ; Weapon2WA=2 ; Weapon2Range=50m ; Weapon3Name=Centaur ; Weapon3Damage=6d6 ; Weapon3WA=5 ; Weapon3Range=500m ;
Then using the same macro tutorial I created a dialog box where the player could view all weapon inputs. I was able to also add in checkbox's by each weapon name. Here is the code from the 'ViewWeapons' Macro.'

Code: Select all

[dialog("Weapons"): {
  <html>
    <head>
      <title>Weapons</title>
      <link rel="stylesheet" type="text/css" href="ViewWeapon_css@[r: getMacroLocation()]">
    </head>
    <body>
      [h,macro("GetWeaponNumbers@this"): ""]
      [h: wpList = macro.return]
      <table>
        [foreach(weapon, wpList, ""), code: {
          [h,macro("GetWeapon@this"): weapon]
          [h: wProp = macro.return]
          <tr class="WeaponName">
            <th><input type="checkbox" name=WPC value=0>
                       [r: getStrProp(wProp, "Name")]
             </th></input>
           </tr>
         <tr><td>
            <th>Damage</th>
            <td>[r: getStrProp(wProp, "Damage")]</td>
            <th>WA</th>
            <td>[r: getStrProp(wProp, "WA")]</td>
            <th>Range</th>
            <td>[r:getStrProp(wProp, "Range")]</td>
                      </tr></td>
        }]
      </table>
    </body>
  </html>
}]
Now I would like to design a way for the player to be able to check off a box and submit and roll the macro out in the chat, but I am unsure how to grab the properties I need and send them to the other macro. Any suggestions, thoughts, ideas?

User avatar
Bone White
Great Wyrm
Posts: 1124
Joined: Tue Aug 23, 2011 11:41 am
Location: Cornwall, UK

Re: Building my first Framework(Help!)

Post by Bone White »

Rather than "make macros for their weapons" why not have "a macro that equips a weapon to a character" and "a macro which attacks and reads the weapon from the character".

This is how most of the frameworks function here. I believe that createMacro just adds more complications.

Macro A Equip
Show an input list of weapons to equip.
PC chooses weapon to equip.
Saved as variable to the PC token.

Macro B Attack
Select a target to attack
Press Macro B (campaign window)
Macro pulls weapon from the variable on getOwned(getPlayerName())

You could even combine the two macros together and just have a drop-down list of all weapons, depends how complicated and user-friendly you want it to be.

armlessbastard
Kobold
Posts: 18
Joined: Tue Nov 10, 2009 2:53 pm

Re: Building my first Framework(Help!)

Post by armlessbastard »

@Meshon - how would this be used with the auto attacker macro that you have set up on your library token? Can you show me the code for that macro?

armlessbastard
Kobold
Posts: 18
Joined: Tue Nov 10, 2009 2:53 pm

Re: Building my first Framework(Help!)

Post by armlessbastard »

@Meshon - I have a few more questions about your macro, though looking at the library token macro it sends info to might help with some of them probably not all of them.

#1.
The form part makes sense to me and I have already rewritten some of it to work with the particular rpg I am looking to run. But im unsure why you have these 2 variables.

Code: Select all

[h: placeholder1 = 9]
[h: placeholder2 = 7]
#2.
my second question has to do with the following line of code.

Code: Select all

[h: macroVariables = strformat("
[h: powerName = '%s']
[h: totalAttackBonus = %d]
[h: targetedDefense = '%s']
[h: DamageDiceSides = '%s']
[h: DamageDiceTimes = %d]
[h: DamageDiceModifier = %d]
[h: powerRange = %d]
[h: penaltyType = '%s']
[h: penaltyModifier = %d]
[h: additionalInformation = '%s']
[h: targetType = %d]
[h: appliedState1 = '%s']
[h: placeholder1 = %d]
[h: appliedState2 = '%s']
[h: brutalValue = %d]
[h: damageSettings = '%s']
[h: placeholder2 = %d]
I am curious what the %d's and %s's are for - im guessing its making sure the variables information is to be saved as String (%s) or data (%d). Is this accurate?

Once again thanks for the macro that i can mess around with. Its helping me understand more and more.

User avatar
Bone White
Great Wyrm
Posts: 1124
Joined: Tue Aug 23, 2011 11:41 am
Location: Cornwall, UK

Re: Building my first Framework(Help!)

Post by Bone White »

varA = varB
varA = strformat("%s",varB)

Achieves the same result. strformat is sometimes used over simple variable setting because it helps bypass some of MapTool's character parsing nuances.

varA = "I have " + 100 + " Chickens"
varA = strformat("I have '%d' '%s'", 100, "Chickens")
varA = strformat("I have '%d' '%s'", "Chickens", 100)

All achieve the same result. The ordering of multiple instances of the same data type is important, and reads left to right as you'd expect.

For a list of what character means what in Wiki: strformat(), refer to the link.

meshon
Cave Troll
Posts: 75
Joined: Fri Mar 26, 2010 10:54 am
Location: AB, Canada

Re: Building my first Framework(Help!)

Post by meshon »

My apologies for a late reply! Here is the code for the "autoattacker" macro that the built macro calls. Hopefully it's still useful.

As to the placeholder values... I don't remember what they were for. I think it was my clunky way to deal with some issue I was having somewhere else in the code. Keep in mind that this is really old stuff. MapTool and me have both come a ways since this was written. Happy to answer more questions though.
And Bone White is right. This was the way I figured out to manage D&D 4E attack powers until I discovered Rumble, but, for example, in my Mordheim framework all the weapons are stored in a json object so the only data I need on the character token is the name of the weapon they are using.

Hopefully this all helps, glad to answer any other questions.

cheers,
Meshon

Edit: Haha, the code is too long (and inefficient!) I'll pm you with it.


User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Building my first Framework(Help!)

Post by Azhrei »

There were a couple things left unsaid by the wiki page for Wiki: strformat(), so I added a couple comments and a link to the Java documentation for the function that actually does the work.

User avatar
Bone White
Great Wyrm
Posts: 1124
Joined: Tue Aug 23, 2011 11:41 am
Location: Cornwall, UK

Re: Building my first Framework(Help!)

Post by Bone White »

Azhrei wrote:There were a couple things left unsaid by the wiki page for Wiki: strformat(), so I added a couple comments and a link to the Java documentation for the function that actually does the work.
Nice improvement, I understand the function better as a result, thanks.

Post Reply

Return to “MapTool”