RPTools.net

Discussion and Support

Skip to content

It is currently Mon Dec 18, 2017 3:39 pm 






Reply to topic  [ 6 posts ] 

Previous topic | Next topic 

  Print view

Author Message
User avatar  Offline
Kobold
 
Joined: Thu Jul 20, 2017 6:27 pm
Posts: 8
 Post subject: Unknown JSON type "NULL" in function "json.get"
PostPosted: Thu Jul 20, 2017 6:33 pm 
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:
[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.


Top
 Profile  
 
User avatar  Offline
Kobold
 
Joined: Thu Jul 20, 2017 6:27 pm
Posts: 8
 Post subject: Re: Unknown JSON type "NULL" in function "json.get"
PostPosted: Fri Jul 21, 2017 3:27 am 
After monkeying around with the macro, I have fixed it all by my self! :D

This is it:
Code:
[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.


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9427
Location: Netherlands
 Post subject: Re: Unknown JSON type "NULL" in function "json.get"
PostPosted: Fri Jul 21, 2017 4:05 am 
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.

_________________
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent and
DPI.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS


Top
 Profile  
 
 Offline
Cave Troll
 
Joined: Mon Apr 10, 2017 4:50 am
Posts: 28
 Post subject: Re: Unknown JSON type "NULL" in function "json.get"
PostPosted: Sat Jul 22, 2017 3:51 am 
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


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9427
Location: Netherlands
 Post subject: Re: Unknown JSON type "NULL" in function "json.get"
PostPosted: Sat Jul 22, 2017 4:56 am 
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.

_________________
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent and
DPI.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS


Top
 Profile  
 
User avatar  Offline
Kobold
 
Joined: Thu Jul 20, 2017 6:27 pm
Posts: 8
 Post subject: Re: Unknown JSON type "NULL" in function "json.get"
PostPosted: Tue Sep 05, 2017 5:58 pm 
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 6 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 1 guest





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman