RPTools.net

Discussion and Support

Skip to content

It is currently Fri Jan 19, 2018 12:41 pm 






Reply to topic  [ 4 posts ] 

Previous topic | Next topic 

  Print view

Author Message
User avatar  Offline
Cave Troll
 
Joined: Tue Apr 16, 2013 7:19 am
Posts: 27
Location: Netherlands
 Post subject: json.contains help
PostPosted: Sun Jan 07, 2018 10:11 am 
I might be looking over something but why is this code always reporting false for me? (maptool 1.4.0.5)

Code:
[R: RNA_Array = json.append("", 0, 0, 0, 1)]<br>
[R: RNA_Compair = 1]<br>

[R: json.contains(RNA_Array, RNA_Compair)]<br>

[R: if(json.contains(RNA_Array, RNA_Compair), "true", "false")]

_________________
My own 5th d&d character sheet framework (preview)


Top
 Profile  
 
User avatar  Offline
Great Wyrm
 
Joined: Mon May 10, 2010 11:59 am
Posts: 1748
Location: Chicagoland
 Post subject: Re: json.contains help
PostPosted: Sun Jan 07, 2018 1:21 pm 
I've had issues putting json functions directly into an IF statement before, but I haven't looked at the code yet so don't know the technical reason yet (suspect return type isn't a BigInteger or something along those lines...

You can avoid this by assigning to a variable first and then testing:
Code:
[R: RNA_Array = json.append("", 0, 0, 0, 1)]<br>
[R: RNA_Compair = 1]<br>

[R: result = json.contains(RNA_Array, RNA_Compair)]<br>

[R: if(result, "true", "false")]


Probably a bug to look into...

_________________
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork


Top
 Profile  
 
User avatar  Offline
Cave Troll
 
Joined: Tue Apr 16, 2013 7:19 am
Posts: 27
Location: Netherlands
 Post subject: Re: json.contains help
PostPosted: Sun Jan 07, 2018 1:48 pm 
k. was just checking that i did not make a mistake :P

btw. thats exactly the way i solved it atm.

_________________
My own 5th d&d character sheet framework (preview)


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7983
Location: Bay Area
 Post subject: Re: json.contains help
PostPosted: Sun Jan 07, 2018 3:33 pm 
I've had problems with the return type of some function where putting them in to their own variable before using them in a function solved the problem for me. This one surprises me a little since if used to be so forgiving.

I checked some other comparisons:
Code:
[r, if("1"):1;0)]

this throws an error

Code:
[r, if("1"==1):1;0)]

this returns 1

notice how the "1" is converted for the comparison, but not as a stand alone result. I'm okay with either logic, but it should be done consistently.

At one point I believe having a non-zero as an if condition resulted in true. So, strings, floats and anything but a zero or "false" (reserved word) would return true. I think the only thing that really threw an error was if the condition was null.

_________________
Downloads:


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 4 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 are 2 users online :: 1 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: Bing [Bot] and 1 guest





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

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman