Page 1 of 2

Automatic Statistic Updating Query

PostPosted: Thu Jul 28, 2016 6:20 pm
by Former Citizens of the Nimbus System
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.

PostPosted: Thu Jul 28, 2016 6:29 pm
by Imperium Anglorum
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.

PostPosted: Thu Jul 28, 2016 7:13 pm
by Trotterdam
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).

PostPosted: Thu Jul 28, 2016 9:59 pm
by [violet]
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?

PostPosted: Fri Jul 29, 2016 2:20 am
by Former Citizens of the Nimbus System
[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.

PostPosted: Fri Jul 29, 2016 11:11 am
by Trotterdam
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.

PostPosted: Fri Jul 29, 2016 11:23 am
by Almonaster Nuevo
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.

PostPosted: Fri Jul 29, 2016 1:02 pm
by Former Citizens of the Nimbus System
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.

PostPosted: Fri Jul 29, 2016 1:03 pm
by Austria and Bavaria
I like this idea.

PostPosted: Sat Jul 30, 2016 1:39 pm
by Ivelboria
[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. :)

Automatic Statistic Updating Query

PostPosted: Mon Aug 08, 2016 3:11 am
by Former Citizens of the Nimbus System
Any news on this?

PostPosted: Tue Aug 09, 2016 5:54 pm
by [violet]
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.

PostPosted: Tue Aug 09, 2016 6:28 pm
by Trotterdam
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.)

PostPosted: Tue Aug 09, 2016 6:45 pm
by Topid
Awww, I'm so sad this wasn't what I thought it was.

It will be cool though!

PostPosted: Tue Aug 09, 2016 9:26 pm
by Austria and Bavaria
[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! :)

PostPosted: Wed Aug 10, 2016 3:54 am
by Bears Armed
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?>*

PostPosted: Wed Aug 10, 2016 6:44 am
by Former Citizens of the Nimbus System
[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!

PostPosted: Wed Aug 10, 2016 8:13 am
by Trotterdam
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.

PostPosted: Wed Aug 10, 2016 11:37 am
by Imperium Anglorum
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.

PostPosted: Wed Aug 10, 2016 2:50 pm
by Almonaster Nuevo
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.

PostPosted: Wed Aug 10, 2016 6:22 pm
by Enfaru
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.

PostPosted: Thu Dec 29, 2016 5:20 am
by Aclion
[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.

PostPosted: Tue Jan 09, 2018 3:31 pm
by New Legland
[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

Any New Update

PostPosted: Fri Jun 26, 2020 10:52 pm
by Ikheria
Hello, anyway, this macro in factbook ([data:leader]) don't work, so it stil in development or stoped?

PostPosted: Sat Jun 27, 2020 12:03 am
by Merni
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.