Unknown JSON type "NULL" in function "json.get"

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
User avatar
elaxter
Kobold
Posts: 8
Joined: Thu Jul 20, 2017 7:27 pm

Unknown JSON type "NULL" in function "json.get"

Post by elaxter »

I'm working on a relatively simple macro for specific hit location. It's supposed to ask the player if the attack is coming from the front or back, and where the previous hit was (face, neck, etc). Here's what I got:

Code: Select all

[H:frontBackList = "Front, Back"]
[H:locList = "Face, Leg, Arm, Extremity, Chest, Abdomen, Neck"]
[h: input("frontBack | "+frontBackList+" | Is the attack from the front or the back? | LIST | SELECT==0")]
[h: input("loc | "+locList+" | Where is the attack? | LIST | SELECT == 0")]
[h: FaceLocTab = " [
  "jaw",
  "nose",
  "easrs",
  "cheek",
  "cheek",
  "eyes"
]" ]
[h: LegLocTab = ' [
  "shin",
  "shin",
  "shin",
  "knee",
  "thigh",
  "thigh vein (if cut, imp, or tbb)"
]']
[h: ArmLocTab = ' [
  "forearm",
  "forearm",
  "forearm",
  "elbow (joint if cr)",
  "upper arm",
  "shoulder (vein/artery if cut, imp, or tbb)"
]']
[h: ExtremLocTab = ' [
  "joint (if cr, cut, pi, or tbb)",
  "extremity",
  "extremity",
  "extremity",
  "extremity",
  "extremity"
]']
[h: ChestLocTab = ' [
  "[h: if(frontBack==0, "vitals (if cr, imp, pi, or tbb)","spine (if cut")]",
  "chest",
  "chest",
  "chest",
  "chest",
  "chest"
]']
[h: AbdLocTab = ' [
  "vitals (if cr, imp, pi, or tbb)",
  "digestive tract",
  "digestive tract",
  "digestive tract",
  "pelvis",
  "groin"
]']
[h: NeckLocTab = ' [
  "[h: if(frontBack==0, "vitals (if cr, imp, pi, or tbb)","spine (if cr")]",
  "neck",
  "neck",
  "neck",
  "neck",
  "neck"
]']
[h: Result=1d6-1]
[h: FaceLoc=json.get(FaceLocTab,Result)]
[h: LegLoc=json.get(LegLocTab,Result)]
[h: ArmLoc=json.get(ArmLocTab,Result)]
[h: ExtremLoc=json.get(ExtremLocTab,Result)]
[h: ChestLoc=json.get(ChestLocTab,Result)]
[h: AbdLoc=json.get(AbdLocTab,Result)]
[h: NeckLoc=json.get(NeckLocTab,Result)]
[h: HitLoc = if(loc == 0, FaceLoc)]
[h: HitLoc = if(loc == 1, LegLoc)]
[h: HitLoc = if(loc == 2, ArmLoc)]
[h: HitLoc = if(loc == 3, ExtremLoc)]
[h: HitLoc = if(loc == 4, ChestLoc)]
[h: HitLoc = if(loc == 5, AbdLoc)]
[h: HitLoc = if(loc == 6, NeckLoc)]
The target is struck in the [r: HitLoc].
It's a little messy, but I'm new to this. When I activate the macro, I get "Unknown JSON type "NULL" in function "json.get"." I used another macro from a campaign framework to help me write this, so I don't really have an understanding of the language. Help would be appreciated.

User avatar
elaxter
Kobold
Posts: 8
Joined: Thu Jul 20, 2017 7:27 pm

Re: Unknown JSON type "NULL" in function "json.get"

Post by elaxter »

After monkeying around with the macro, I have fixed it all by my self! :D

This is it:

Code: Select all

[H:locList = "Face, Leg, Arm, Extremity, Chest, Abdomen, Neck"]
[h: input("loc | "+locList+" | Where is the attack? | LIST | SELECT == 0")]
[h: FaceLocTab = ' [
  "jaw",
  "nose",
  "ears",
  "cheek",
  "cheek",
  "eyes"
]']
[h: LegLocTab = ' [
  "shin",
  "shin",
  "shin",
  "knee",
  "thigh",
  "thigh vein (if cut, imp, or tbb)"
]']
[h: ArmLocTab = ' [
  "forearm",
  "forearm",
  "forearm",
  "elbow (joint if cr)",
  "upper arm",
  "shoulder (vein/artery if cut, imp, or tbb)"
]']
[h: ExtremLocTab = ' [
  "joint (if cr, cut, pi, or tbb)",
  "extremity",
  "extremity",
  "extremity",
  "extremity",
  "extremity"
]']
[h: ChestLocTab = ' [
  "vitals (if cr, imp, pi, or tbb) or spine (if cut from rear)",
  "chest",
  "chest",
  "chest",
  "chest",
  "chest"
]']
[h: AbdLocTab = ' [
  "vitals (if cr, imp, pi, or tbb)",
  "digestive tract",
  "digestive tract",
  "digestive tract",
  "pelvis",
  "groin"
]']
[h: NeckLocTab = ' [
  "vitals (if cr, imp, pi, or tbb) or spine (if cr from rear)",
  "neck",
  "neck",
  "neck",
  "neck",
  "neck"
]']
[h: roll=1d6-1]

[h,switch(loc):
case 0: HitLoc = json.get(FaceLocTab,roll);
case 1: HitLoc = json.get(LegLocTab,roll);
case 2: HitLoc = json.get(ArmLocTab,roll);
case 3: HitLoc = json.get(ExtremLocTab,roll);
case 4: HitLoc = json.get(ChestLocTab,roll);
case 5: HitLoc = json.get(AbdLocTab,roll);
case 6: HitLoc = json.get(NeckLocTab,roll);
default: HitLoc = "nothing"]
The target is struck in the [r: HitLoc].
I removed the front/back check and properly used a switch at the end. I'm going to combine it with another hit location macro so they work simultaneously.

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

Re: Unknown JSON type "NULL" in function "json.get"

Post by wolph42 »

the best way to learn stuff is by doing it yourself! congrats on your debugging!

btw. im guessing the 1d6-1 is for testing purposes, but it will never result in 6 and that makes part of the case statement obsolete.

Dracwrym
Cave Troll
Posts: 28
Joined: Mon Apr 10, 2017 5:50 am

Re: Unknown JSON type "NULL" in function "json.get"

Post by Dracwrym »

wolph42 wrote:the best way to learn stuff is by doing it yourself! congrats on your debugging!

btw. im guessing the 1d6-1 is for testing purposes, but it will never result in 6 and that makes part of the case statement obsolete.
He could do 2*(1d4-1) or for more random opportunities (1d4-1)+(1d4-1). Then all case statements can be reached. :D

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

Re: Unknown JSON type "NULL" in function "json.get"

Post by wolph42 »

Dracwrym wrote:He could do 2*(1d4-1) or for more random opportunities (1d4-1)+(1d4-1). Then all case statements can be reached. :D
2*(1d4-1) has: 0,2,4 and 6 as result

how about 1d7-1.

User avatar
elaxter
Kobold
Posts: 8
Joined: Thu Jul 20, 2017 7:27 pm

Re: Unknown JSON type "NULL" in function "json.get"

Post by elaxter »

This is a late reply, but I reckon I should post this so newer users will know what's up. I used "1d6-1" in the code because the way the arrays (i think that's what they call 'em) work, they start at 0 and not 1. Therefore, a 1 becomes a 0, a 2 a 1, a 3 a 2, and so on.

Post Reply

Return to “Macros”