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: 1834
Founded: Jul 21, 2016
Civil Rights Lovefest

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 shorten to the pre-title or 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
GA Secretariat
 
Posts: 12655
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 56+ GA resolutions
Maintainer: GA Passed Resolutions
Developer: Communiqué and InfoEurope
GenSec (24 Dec 2021 –); posts not official unless so indicated
Delegate for Europe
Elsie Mortimer Wellesley
Ideological Bulwark 285, WALL delegate
Twice-commended toxic villainous globalist kittehs

User avatar
Trotterdam
Postmaster-General
 
Posts: 10541
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]
Executive Director
 
Posts: 16205
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: 1834
Founded: Jul 21, 2016
Civil Rights Lovefest

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 shorten to the pre-title or 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
Postmaster-General
 
Posts: 10541
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
Negotiator
 
Posts: 6828
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: 1834
Founded: Jul 21, 2016
Civil Rights Lovefest

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 shorten to the pre-title or 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: 763
Founded: Dec 13, 2015
Scandinavian Liberal Paradise

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 Neviersian Federation ✩ De Fédération Neviersien
In Neviersia, your hard-earned tax money funds countryball art, endless paperwork, "free" healthcare and gawd-awful humour. Even the countryballs need therapy. What's not to love?
GOV.NE | About Neviersia | Wikipedia | Politics | States & Territories | Cities
- Born and bred in good ol' Yorkshire.
- I know my nation is called Ivelboria but I was too lazy to make a new nation. :P
- Chronic workaholic who keeps making factbooks...
- NS stats not used.
- The stars on my flag can spin either way.. :P
Economic: 0.63 (2016), 1.0 (2019), -0.63 (2021), -1.88 (2022)
Social: 0.97 (2016), -2.97 (2019), -3.28 (2021), -0.72 (2022)

1/5/21: Started using the GIF flag. For 3/4 years before that I used this one.

Spoilerception? Here's how!

User avatar
Former Citizens of the Nimbus System
Ambassador
 
Posts: 1834
Founded: Jul 21, 2016
Civil Rights Lovefest

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 shorten to the pre-title or 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]
Executive Director
 
Posts: 16205
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
Postmaster-General
 
Posts: 10541
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: 2843
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.
AKA Weed

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
Postmaster of the Fleet
 
Posts: 21475
Founded: Jun 01, 2006
Civil Rights Lovefest

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 Confrederated Clans (and other Confrederated Bodys) of the Free Bears of Bears Armed
(includes The Ursine NorthLands) Demonym = Bear[s]; adjective = ‘Urrsish’.
Population = just under 20 million. Economy = only Thriving. Average Life expectancy = c.60 years. If the nation is classified as 'Anarchy' there still is a [strictly limited] national government... and those aren't "biker gangs", they're traditional cross-Clan 'Warrior Societies', generally respected rather than 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, 1474, 1521.

User avatar
Former Citizens of the Nimbus System
Ambassador
 
Posts: 1834
Founded: Jul 21, 2016
Civil Rights Lovefest

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 shorten to the pre-title or 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
Postmaster-General
 
Posts: 10541
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
GA Secretariat
 
Posts: 12655
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 56+ GA resolutions
Maintainer: GA Passed Resolutions
Developer: Communiqué and InfoEurope
GenSec (24 Dec 2021 –); posts not official unless so indicated
Delegate for Europe
Elsie Mortimer Wellesley
Ideological Bulwark 285, WALL delegate
Twice-commended toxic villainous globalist kittehs

User avatar
Almonaster Nuevo
Negotiator
 
Posts: 6828
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: 6249
Founded: Apr 12, 2016
Ex-Nation

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.
A popular Government, without popular information, or the means of acquiring it, is but a Prologue to a Farce or a Tragedy; or, perhaps both. - James Madison.

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
Chargé d'Affaires
 
Posts: 358
Founded: Sep 28, 2019
Left-wing Utopia

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 nation in Poland, Belarus, and Kaliningrad from result of mass emigration from Nusantara/Indonesia. Capital is Yeltsingrad/Warsaw.
Member of CSTO, CIS, EEU (since its founding), as well European Union (since 2000).
Member of GD, formerly Europeia
| OOC: a 14-year old Indonesian teenager
Remember, Ikherian Language is Indonesian, but writed in Cyrillic script!
Ikheria Federal News Agency: ISEA reviewing IGMMS proposal.|Ikheria Navy began patrolling Baltic Sea after NATO 'pranking' Russia there.

User avatar
Merni
Ambassador
 
Posts: 1800
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.
2024: the year of democracy. Vote!
The Labyrinth | Donate your free time, help make free ebooks | Admins: Please let us block WACC TGs!
RIP Residency 3.5.16-18.11.21, killed by simplistic calculation
Political Compass: Economic -9.5 (Left) / Social -3.85 (Liberal)
Wrote issue 1523, GA resolutions 532 and 659
meth
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!)

Next

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Aurora Islands, Baharan, Cricetomia, Gmt2001, Hipearia, IdontCare, Qingguo, Sun Topia, Tricklandia

Advertisement

Remove ads