TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

Does there exist a tintin object notation to JSON

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Script Help
View previous topic :: View next topic  
Author Message
rw3iss



Joined: 17 Jul 2014
Posts: 23

PostPosted: Mon Nov 06, 2017 10:31 am    Post subject: Does there exist a tintin object notation to JSON Reply with quote

Is anyone aware of a parser that can take an tintin object notation, ie. something like this:

Code:
#VARIABLE         {currentArea}  {{alias}{chessboard}{creator}{}{mobs}{{White Foot Soldier}{{aliases}{soldier}}{White Horseman}{{aliases}{horseman}}}{name}{Chess Board}{notes}{}}


And tranpose it to a normal JSON format such as:

Code:
currentArea = {
  "alias": "chessboard",
  "creator": "",
  "mobs": {
    "White Foot Soldier": {
      "aliases": "soldier"
    }
    "White Horseman": {
      "aliases": "horseman"
    }
  },
  "name": "Chess Board"
  "notes": ""
}


Otherwise I may write one! :-)

Thanks,
Ryan
Back to top
View user's profile Send private message
PowerGod



Joined: 04 Aug 2014
Posts: 339

PostPosted: Tue Nov 07, 2017 7:20 pm    Post subject: Reply with quote

There is something in the finished scripts, but seems to do the opposite.

Anyway, I did something just for fun to try this out...

It's not totally working anyway, there are issues with commas and the variable name is missing, but it could be something to start with:

Code:

#alias json-this {
   #local jsontmp {};
   #local cnt {};
   #list jsontmp CREATE $%1[];
   #foreach $jsontmp[] cnt {
      #if { "$%1[$jsontmp[$cnt]][]" != "" } {#showme "$jsontmp[$cnt]" : \x7B;json-this {%1[$jsontmp[$cnt]]}} {#showme {"$jsontmp[$cnt]" : "$%1[$jsontmp[$cnt]]",}}
   };
   #showme {\x7D}
}


Code:

#VARIABLE {currentArea} {{alias}{chessboard}{creator}{}{mobs}{{White Foot Soldier}{{aliases}{soldier}}{White Horseman}{{aliases}{horseman}}}{name}{Chess Board}{notes}{}}
#OK. VARIABLE {currentArea} HAS BEEN SET TO {{alias}{chessboard}{creator}{}{mobs}{{White Foot Soldier}{{aliases}{soldier}}{White Horseman}{{aliases}{horseman}}}{name}{Chess Board}{notes}{}}.

json-this {currentArea}

"alias" : "chessboard",
"creator" : "",
"mobs" : {
"White Foot Soldier" : {
"aliases" : "soldier",
}
"White Horseman" : {
"aliases" : "horseman",
}
}
"name" : "Chess Board",
"notes" : "",
}
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3770

PostPosted: Sun Nov 12, 2017 12:31 pm    Post subject: Reply with quote

This might be easier if tintin had an easier way to access variable names.

Right now $variable[] is the only way to do this, generating a list of all the keys in a table, which is problematic for large tables.

@ is used for functions.

& is used to get either the position of a variable or the size of a table.

This leaves *variable[+1] as a possible way to get it. I've ran into this problem several times so it might be about time to add support for it.

telopt.c has a parser that turns GMCP JSON tables into TT++ tables. This might be useful as a reference, it uses a programming principle that a lot of people find hard to comprehend.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Script Help All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group