NATION

PASSWORD

Automatic Statistic Updating Query

Bug reports, general help, ideas for improvements, and questions about how things are meant to work.
User avatar
Former Citizens of the Nimbus System
Ambassador
 
Posts: 1704
Founded: Jul 21, 2016
New York Times Democracy

Automatic Statistic Updating Query

Postby Former Citizens of the Nimbus System » Thu Jul 28, 2016 6:20 pm

Hello!

I have been wondering whether there is a way to automatically input up-to-date statistics from a nation into dispatches and other writing. This would mostly be used to avoid doing this manually over and over again in my (as yet by no means complete) factbooks. I've been able to discern that this would involve the use of NationStates API.

Unfortunately, I have essentially no knowledge of coding.

I think that the best course of action, therefore, is for me to ask for both the precise code used by anyone else who has been able to do this previously and permission to utilise it; that is what I am doing here. Does anybody possess this information? I would be incredibly grateful to know.
We are the Nexus Wardship of Former Citizens of the Nimbus System, not just a collection of people; please use the full name!

Emmet: You might see a mess -
Lord Business: Exactly: a bunch of weird, dorky stuff that ruined my perfectly good stuff!
Emmet: Okay. What I see are people, inspired by each other and by you - people taking what you made and making something new out of it.

The central Nimban cultural ideal summed up in an exchange from The Lego Movie.

Supporter of the campaign to add Economic Freedom to the home page!

User avatar
Imperium Anglorum
Powerbroker
 
Posts: 9530
Founded: Aug 26, 2013
Left-Leaning College State

Postby Imperium Anglorum » Thu Jul 28, 2016 6:29 pm

From a coding perspective, this would require a dynamic webpage, something like PHP, ASP, or JSP would be best for that. However, problematically, such is currently impossible in NationStates. You cannot create a dynamic factbook or webpage using bbCode.

Author: 1 SC and 33 GA resolutions
Maintainer: GA Passed Resolutions
Developer: Communiqué and InfoEurope
Toxic villainous globalist kittehs
Delegate for Europe
Elsie Mortimer Wellesley (EMW); OOC unless otherwise indicated
Ideological Bulwark 285, WALL delegate
Dastardly villain providing free services to the community sans remuneration

User avatar
Trotterdam
Powerbroker
 
Posts: 8602
Founded: Jan 12, 2012
Left-Leaning College State

Postby Trotterdam » Thu Jul 28, 2016 7:13 pm

Imperium Anglorum wrote:From a coding perspective, this would require a dynamic webpage,
It would be considerably easier to write a program that plugs API-retrieved values into a template to produce fully-formed BBCode that can then be manually copy+pasted into a factbook without further manual processing, which is what I assume the original poster was asking about. This shouldn't be hard for anyone with a basic grasp of coding, but unfortunately I can't just supply ready-made code because it depends on your programming environment (my own current scripts are kludge-jobs that are decidedly not portable).

With somewhat more effort, you could make a program that automatically logs into your nation and uploads the new factbook every time you run it, skipping the need for the copy+paste part (this requires making scripted non-API calls, which have tighter rules restrictions, but since the script is only affecting your own nation, it would be legal - meanwhile, coding-wise, it'd be harder because your script needs to be able to handle cookies and webpages not designed for machine-readability, but it's certainly possible).

User avatar
[violet]
Site Admin
 
Posts: 14540
Founded: Antiquity

Postby [violet] » Thu Jul 28, 2016 9:59 pm

Former Citizens of the Nimbus System wrote:automatically input up-to-date statistics from a nation into dispatches

Huh, interesting idea. What kind of stats/info do you want?

User avatar
Former Citizens of the Nimbus System
Ambassador
 
Posts: 1704
Founded: Jul 21, 2016
New York Times Democracy

Postby Former Citizens of the Nimbus System » Fri Jul 29, 2016 2:20 am

[violet] wrote:
Former Citizens of the Nimbus System wrote:automatically input up-to-date statistics from a nation into dispatches

Huh, interesting idea. What kind of stats/info do you want?

Those from the different variables listed under 'Rank'. I just thought that it would be a convenient thing to have for factfiles and so forth, ensuring that the figures listed in a factbook were always accurate.
We are the Nexus Wardship of Former Citizens of the Nimbus System, not just a collection of people; please use the full name!

Emmet: You might see a mess -
Lord Business: Exactly: a bunch of weird, dorky stuff that ruined my perfectly good stuff!
Emmet: Okay. What I see are people, inspired by each other and by you - people taking what you made and making something new out of it.

The central Nimban cultural ideal summed up in an exchange from The Lego Movie.

Supporter of the campaign to add Economic Freedom to the home page!

User avatar
Trotterdam
Powerbroker
 
Posts: 8602
Founded: Jan 12, 2012
Left-Leaning College State

Postby Trotterdam » Fri Jul 29, 2016 11:11 am

One problem with completely automatic updating is that it could result in the text not matching the data presented. Like, you might have your Average Income value automatically plugged into your factbook, but if you embellished it with something like "this is a rich country, with an average income of [census=72] SMU", or a more detailed explanation of how your economy works, or something, and then you do something gameside that causes your economy to crash, your factbook will still claim you're a rich country even though the numbers no longer match.

If the factbook really does nothing but quote the game values, with no embellishment, then you might as well not bother. Just link to the game's analysis pages.

User avatar
Almonaster Nuevo
Senator
 
Posts: 4483
Founded: Mar 11, 2007
Civil Rights Lovefest

Postby Almonaster Nuevo » Fri Jul 29, 2016 11:23 am

But the problem lies with "this is a rich country" which would happen anyway under the current system, whereas the "average income of [census=72] SMU" would be accurate, which is the proposed improvement.
Christian Democrats wrote:Would you mind explaining what's funny? I'm not seeing any humor.
The Blaatschapen wrote:I'll still graze the forums with my presence
Please do not TG me about graphics requests. That's what the threads are there for.

User avatar
Former Citizens of the Nimbus System
Ambassador
 
Posts: 1704
Founded: Jul 21, 2016
New York Times Democracy

Postby Former Citizens of the Nimbus System » Fri Jul 29, 2016 1:02 pm

Trotterdam wrote:One problem with completely automatic updating is that it could result in the text not matching the data presented. Like, you might have your Average Income value automatically plugged into your factbook, but if you embellished it with something like "this is a rich country, with an average income of [census=72] SMU", or a more detailed explanation of how your economy works, or something, and then you do something gameside that causes your economy to crash, your factbook will still claim you're a rich country even though the numbers no longer match.

If the factbook really does nothing but quote the game values, with no embellishment, then you might as well not bother. Just link to the game's analysis pages.

I think that a situation such as a major economic crash would warrant a factbook update anyway; the proposal is instead intended to ensure that minor fluctuations do not necessitate constant changes for accuracy's sake.
We are the Nexus Wardship of Former Citizens of the Nimbus System, not just a collection of people; please use the full name!

Emmet: You might see a mess -
Lord Business: Exactly: a bunch of weird, dorky stuff that ruined my perfectly good stuff!
Emmet: Okay. What I see are people, inspired by each other and by you - people taking what you made and making something new out of it.

The central Nimban cultural ideal summed up in an exchange from The Lego Movie.

Supporter of the campaign to add Economic Freedom to the home page!

User avatar
Austria and Bavaria
Minister
 
Posts: 3477
Founded: Jul 14, 2015
Ex-Nation

Postby Austria and Bavaria » Fri Jul 29, 2016 1:03 pm

I like this idea.
Political: Monarchist, Integralist, National Syndicalist/Third Position, Christian Humanist.
Hobbies: Apprentice Blacksmith, Amateur Poet, and Board Gaming Fanatic.
Personal: Roman Catholic, Scots-German Southerner, North Carolinian. Deo Vindice.

User avatar
Ivelboria
Diplomat
 
Posts: 746
Founded: Dec 13, 2015
Inoffensive Centrist Democracy

Postby Ivelboria » Sat Jul 30, 2016 1:39 pm

[violet] wrote:
Former Citizens of the Nimbus System wrote:automatically input up-to-date statistics from a nation into dispatches

Huh, interesting idea. What kind of stats/info do you want?


Maybe if it was all stats. I like the idea as well. :)
❤ The United Democratic Republic of Neviersia ❤
A nation of peace and unity! We wish everyone a happy, joyful day!

Government Website | Meet the Countryballs! | Anthem | Wikipedia | Embassy Programme | Political Parties
Neviersia is a 16 civilization, according to this index! Former Universal Pact Administration Team Member, resigned 10/2/20.
This nation does not use any NS stats. Only rely on the factbooks (partly represent my political views).

Also I'm such a workaholic who keeps making factbooks.. :P

Aussi, je parle le francais un peu !

Neviersian Language | IIWiki
Political Compass:
Economic: 0.63 (2016), 1.0 (2019)
Social: 0.97 (2016), -2.97 (2019)

A proud pro-EU Filipino living in the UK!

How you can put a spoiler within another spoiler!

User avatar
Former Citizens of the Nimbus System
Ambassador
 
Posts: 1704
Founded: Jul 21, 2016
New York Times Democracy

Automatic Statistic Updating Query

Postby Former Citizens of the Nimbus System » Mon Aug 08, 2016 3:11 am

Any news on this?
We are the Nexus Wardship of Former Citizens of the Nimbus System, not just a collection of people; please use the full name!

Emmet: You might see a mess -
Lord Business: Exactly: a bunch of weird, dorky stuff that ruined my perfectly good stuff!
Emmet: Okay. What I see are people, inspired by each other and by you - people taking what you made and making something new out of it.

The central Nimban cultural ideal summed up in an exchange from The Lego Movie.

Supporter of the campaign to add Economic Freedom to the home page!

User avatar
[violet]
Site Admin
 
Posts: 14540
Founded: Antiquity

Postby [violet] » Tue Aug 09, 2016 5:54 pm

Actually yes! Still in development, but if you like you can have a play. Dispatches support tags in the format "[data:TAG]", where TAG is one of the keywords below.

They don't work in preview mode at the moment, only in published dispatches.

Tags:

population
animal
currency
capital
faith
region
influence
gdp
tax
income
census-score-N
census-rank-N
census-regionrank-N

With the last three, the N should be replaced with a census ID number, e.g. 3 for population.

Example test dispatch.

User avatar
Trotterdam
Powerbroker
 
Posts: 8602
Founded: Jan 12, 2012
Left-Leaning College State

Postby Trotterdam » Tue Aug 09, 2016 6:28 pm

When it comes to very large numbers (population, GDP), there are three formats people might want them in: plain ("123000000000"), comma-separated ("123,000,000,000"), and formatted ("123 billion").

Looking at your example dispatch, it seems that currently using [data:census-score-3] and [data:census-score-76] produce the "123,000,000,000" format, while [data:population] and [data:gdp] produce the "123 billion" format (though not in an entirely consistent manner - why does it display the population as "28,192 million" instead of the "28.192 billion" on your nation page?). That's a fine way to handle it, but make sure to put that in the documentation when this becomes official :)

I also think that [data:gdp] shouldn't automatically include the currency name. (The game using local currencies when it means SMUs is annoying.)

[violet] wrote:animal
currency
capital
faith
Capital and faith but no leader? Is this an oversight?

I also note currently-nonfunctioning [data:flag] and [data:name] on the dispatch. When would you ever need [data:name]? [data:pretitle], maybe. (Though often people use their factbook to mention their "official" roleplay pretitle while setting their in-game one to "Holy Violet Egg Hunters" or something.)

User avatar
Topid
Minister
 
Posts: 2826
Founded: Dec 29, 2008
Capitalizt

Postby Topid » Tue Aug 09, 2016 6:45 pm

Awww, I'm so sad this wasn't what I thought it was.

It will be cool though!
Last edited by Topid on Tue Aug 09, 2016 6:54 pm, edited 2 times in total.
Founder, Pacifica

User avatar
Austria and Bavaria
Minister
 
Posts: 3477
Founded: Jul 14, 2015
Ex-Nation

Postby Austria and Bavaria » Tue Aug 09, 2016 9:26 pm

[violet] wrote:Actually yes! Still in development, but if you like you can have a play. Dispatches support tags in the format "[data:TAG]", where TAG is one of the keywords below.

They don't work in preview mode at the moment, only in published dispatches.

Tags:

population
animal
currency
capital
faith
region
influence
gdp
tax
income
census-score-N
census-rank-N
census-regionrank-N

With the last three, the N should be replaced with a census ID number, e.g. 3 for population.

Example test dispatch.



It's happening! :)
Political: Monarchist, Integralist, National Syndicalist/Third Position, Christian Humanist.
Hobbies: Apprentice Blacksmith, Amateur Poet, and Board Gaming Fanatic.
Personal: Roman Catholic, Scots-German Southerner, North Carolinian. Deo Vindice.

User avatar
Bears Armed
GA Secretariat
 
Posts: 19235
Founded: Jun 01, 2006
Ex-Nation

Postby Bears Armed » Wed Aug 10, 2016 3:54 am

Trotterdam wrote:When it comes to very large numbers (population, GDP), there are three formats people might want them in: plain ("123000000000"), comma-separated ("123,000,000,000"), and formatted ("123 billion").

*<mutters grumpily that when & where I went to school [1965-'78, in England] we were always taught to use apostrophes, not commas: and when using commas, isn't there a risk of large numbers getting mistaken for lists of smaller ones?>*
The Confederated Clans of the Free Bears of Bears Armed
(includes The Ursine NorthLands) Demonym = Bear[s]; adjective = ‘Urrsish’.
Our population is approximately 20 million. We do have a national government, although its role is strictly limited. Economy = thriving. Those aren't "biker gangs", they're our traditional cross-Clan 'Warrior Societies'... and are generally respected, not feared.
Author of some GA Resolutions, via Bears Armed Mission; subject of an SC resolution.
Factbook. We have more than 70 MAPS. Visitors' Guide.
The IDU's WA Drafting Room is open to help you.
Author of issues #429, 712, 729, 934, 1120, 1152.

User avatar
Former Citizens of the Nimbus System
Ambassador
 
Posts: 1704
Founded: Jul 21, 2016
New York Times Democracy

Postby Former Citizens of the Nimbus System » Wed Aug 10, 2016 6:44 am

[violet] wrote:Actually yes! Still in development, but if you like you can have a play. Dispatches support tags in the format "[data:TAG]", where TAG is one of the keywords below.

They don't work in preview mode at the moment, only in published dispatches.

Tags:

population
animal
currency
capital
faith
region
influence
gdp
tax
income
census-score-N
census-rank-N
census-regionrank-N

With the last three, the N should be replaced with a census ID number, e.g. 3 for population.

Example test dispatch.

Oh - wow! Thank you!
We are the Nexus Wardship of Former Citizens of the Nimbus System, not just a collection of people; please use the full name!

Emmet: You might see a mess -
Lord Business: Exactly: a bunch of weird, dorky stuff that ruined my perfectly good stuff!
Emmet: Okay. What I see are people, inspired by each other and by you - people taking what you made and making something new out of it.

The central Nimban cultural ideal summed up in an exchange from The Lego Movie.

Supporter of the campaign to add Economic Freedom to the home page!

User avatar
Trotterdam
Powerbroker
 
Posts: 8602
Founded: Jan 12, 2012
Left-Leaning College State

Postby Trotterdam » Wed Aug 10, 2016 8:13 am

Bears Armed wrote:*<mutters grumpily that when & where I went to school [1965-'78, in England] we were always taught to use apostrophes, not commas: and when using commas, isn't there a risk of large numbers getting mistaken for lists of smaller ones?>*
Ha, you're lucky! In many countries in Europe, the practice is to use commas to mark fractional parts and dots to separate large numbers, as opposed to the international standard of doing it the other way around. It's annoying.

User avatar
Imperium Anglorum
Powerbroker
 
Posts: 9530
Founded: Aug 26, 2013
Left-Leaning College State

Postby Imperium Anglorum » Wed Aug 10, 2016 11:37 am

Bears Armed wrote:
Trotterdam wrote:When it comes to very large numbers (population, GDP), there are three formats people might want them in: plain ("123000000000"), comma-separated ("123,000,000,000"), and formatted ("123 billion").

*<mutters grumpily that when & where I went to school [1965-'78, in England] we were always taught to use apostrophes, not commas: and when using commas, isn't there a risk of large numbers getting mistaken for lists of smaller ones?>*

Well, I was not taught that way, but this is quite smart... would not be bad to see a comeback.

Author: 1 SC and 33 GA resolutions
Maintainer: GA Passed Resolutions
Developer: Communiqué and InfoEurope
Toxic villainous globalist kittehs
Delegate for Europe
Elsie Mortimer Wellesley (EMW); OOC unless otherwise indicated
Ideological Bulwark 285, WALL delegate
Dastardly villain providing free services to the community sans remuneration

User avatar
Almonaster Nuevo
Senator
 
Posts: 4483
Founded: Mar 11, 2007
Civil Rights Lovefest

Postby Almonaster Nuevo » Wed Aug 10, 2016 2:50 pm

I was taught in England and Scotland over the same time period, and we learned the comma variant.

It does highlight the importance of including a space after a comma when using it as punctuation.
Christian Democrats wrote:Would you mind explaining what's funny? I'm not seeing any humor.
The Blaatschapen wrote:I'll still graze the forums with my presence
Please do not TG me about graphics requests. That's what the threads are there for.

User avatar
Enfaru
Minister
 
Posts: 2921
Founded: Apr 20, 2012
Ex-Nation

Postby Enfaru » Wed Aug 10, 2016 6:22 pm

I know this is a new thing but can we tweak this (pretty please).

I'm not precisely sure what the data tag does but I would like to modify it.

So...

[calc:[data:GDP]/1000] would output the GDP reduced by three places. Using number Special Char number as the format the code behind could easily perform simple calculations that then update automatically.

or event...

[data:gdp&/&1000]

This would be great for role-players.
Last edited by Enfaru on Wed Aug 10, 2016 6:24 pm, edited 1 time in total.
Sovereign Charter Quick Links
Factbook · Role-plays · RMB · Map (Origin | Quantum) · Chat · Members: 73
Myraxia: One does not learn to GM; One throws oneself in and prays they don't fuck up too badly.
Game Master
Founder of the Sovereign Charter,
4th President and,
Tutor of the College of Theatrics

User avatar
Aclion
Negotiator
 
Posts: 5641
Founded: Apr 12, 2016
Anarchy

Postby Aclion » Thu Dec 29, 2016 5:20 am

[violet] wrote:I totally forgot I already implemented this:

viewtopic.php?f=15&t=385192&p=29573864

People are supposed to be testing and providing suggestions for more tags.

At the risk of necroing: What about the motto, denonyms, leader and possibly WA Category(though I'm not sure if anyone would use it in a factbook)


Enfaru wrote:I know this is a new thing but can we tweak this (pretty please).

I'm not precisely sure what the data tag does but I would like to modify it.

So...

[calc:[data:GDP]/1000] would output the GDP reduced by three places. Using number Special Char number as the format the code behind could easily perform simple calculations that then update automatically.

or event...

[data:gdp&/&1000]

This would be great for role-players.

As someone who is using nearly stat other then population and the stats derived from it this would wonderful. No more manually calculating population density, GDP, Industry size, an spending just because the population is used as a proxy for nation age.
XKI: Recruiter, TITO Tactical Officer, Deputy WA Secretary, Emissary to Forest
TEP: Deputy Minister for WA affairs
Forest: Cartographer Emeritus
Oatland: Consul ,Caesar and Cartographer Emeritus
The people who participated in China's denial of their role in this outbreak deserve the same scorn and derision of those who've helped past regimes deny their own atrocities.

User avatar
New Legland
Chargé d'Affaires
 
Posts: 439
Founded: Apr 21, 2017
Civil Rights Lovefest

Postby New Legland » Tue Jan 09, 2018 3:31 pm

[violet] wrote:Actually yes! Still in development, but if you like you can have a play. Dispatches support tags in the format "[data:TAG]", where TAG is one of the keywords below.

They don't work in preview mode at the moment, only in published dispatches.

Tags:

population
animal
currency
capital
faith
region
influence
gdp
tax
income
census-score-N
census-rank-N
census-regionrank-N

With the last three, the N should be replaced with a census ID number, e.g. 3 for population.

Example test dispatch.

Sorry if I'm asking for too much, but would it be possible to use these without units of measurement and words included?

Enfaru wrote:I know this is a new thing but can we tweak this (pretty please).

I'm not precisely sure what the data tag does but I would like to modify it.

So...

[calc:[data:GDP]/1000] would output the GDP reduced by three places. Using number Special Char number as the format the code behind could easily perform simple calculations that then update automatically.

or event...

[data:gdp&/&1000]

This would be great for role-players.


This is also a pretty good idea
Last edited by New Legland on Sat Jan 13, 2018 7:45 am, edited 3 times in total.

User avatar
Ikheria
Bureaucrat
 
Posts: 61
Founded: Sep 28, 2019
Left-Leaning College State

Any New Update

Postby Ikheria » Fri Jun 26, 2020 10:52 pm

Hello, anyway, this macro in factbook ([data:leader]) don't work, so it stil in development or stoped?
Last edited by Ikheria on Fri Jun 26, 2020 10:54 pm, edited 1 time in total.

Federal Democratic Republic of Ikheria
A proud member of Europeia
Remember, Ikherian Language is Cyrillic script of Indonesian!

Current President: Sergey Lebankov
Current Parliament Speaker: Anatoly Eakandov (Federal Representative Council-Ikheria Social Democrat Party)|Antony Denasky (General Representative Council-Ikheria Nationalist Party)
Ikheria ambassador for WA: Jan Paul Diwenensky (Ikheria ambassador for Monsone)

User avatar
Merni
Ambassador
 
Posts: 1160
Founded: May 03, 2016
Democratic Socialists

Postby Merni » Sat Jun 27, 2020 12:03 am

Ikheria wrote:Hello, anyway, this macro in factbook ([data:leader]) don't work, so it stil in development or stoped?


Just a few posts above yours:
[violet] wrote:Actually yes! Still in development, but if you like you can have a play. Dispatches support tags in the format "[data:TAG]", where TAG is one of the keywords below.

They don't work in preview mode at the moment, only in published dispatches.

Tags:

population
animal
currency
capital
faith
region
influence
gdp
tax
income
census-score-N
census-rank-N
census-regionrank-N

With the last three, the N should be replaced with a census ID number, e.g. 3 for population.

Example test dispatch.

"leader" is not one of them.
COVID19 still exists! | Free time? Help Gutenberg!
The Labyrinth | GA Committee List | Tools written by me | NS Parliament 2: Zhang Xiaoqing

Admins: Please allow blocking WA TGs!
Fora
I've noticed that everybody that is for abortion has already been born. — Ronald Reagan

When the people are being beaten with a stick, they are not much happier if it is called 'the People’s Stick.' — Mikhail Bakunin (to Karl Marx)

You're supposed to be employing the arts of diplomacy, not the ruddy great thumping sledgehammers of diplomacy. — Ardchoille

The West won the world not by the superiority of its ideas or values or religion [...] but rather by its superiority in applying organised violence. — Samuel P. Huntington (even he said that!)

Compass E:-7.75 S:-3.64


Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Aurum Raider, Graag Brom

Advertisement

Remove ads