NationStates Jolt Archive


Writing Scripts

Tuesday Heights
28-07-2004, 19:19
If anyone could direct me to where I can learn, or download software, to write my own scripts to use on NS, I'd appreciate it... or if anyone feels like sharing some with me, I'd be eternally grateful.
Juxtapositions
28-07-2004, 19:42
What are you looking for? I may have it already.
Enerica
28-07-2004, 20:06
I could give you something for getting xml info...if I'm feeling nice :D

Like ^^ he said, whatchoo lookin' for Tuesday?
Tuesday Heights
28-07-2004, 20:15
I'm not quite sure what I'm looking for, because the only coding I know anything about is basic HTML and some very rudiementary JavaScript that would make web programmers laugh...

but I suppose I'm looking for a few things to use within the site:

- Perhaps, something to keep track of all the endorsements of a particular nation in any particular region.
- I don't know if it's possible, but is their a way a script can tell the IP address behind a particular nation/poster (I don't even know if that's legal...).

I'm not quite sure what types of scripts people actually use here, so, if you'd rather telegram me or IM me personally about it, feel free.
Enerica
28-07-2004, 20:17
For the first one, I could make you that, give me a bit....
*about 20 minutes ish*

For the second one I think it would be legal, but I can't image how to do it.
Tuesday Heights
28-07-2004, 20:21
You're my hero, Enercia!

What other things do people use scripts on NS for?

Is their a way one could be written to track everywhere a particular nation has been since creation? Or is information like that lost once it moves?
Myrth
28-07-2004, 20:24
A script can't pull any more info than you could yourself, manually.
Tuesday Heights
28-07-2004, 20:26
A script can't pull any more info than you could yourself, manually.

So, that's a no to the IP script, right? :(
Enerica
28-07-2004, 20:34
Well I have this


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<HTML>
<HEAD>
<TITLE>Calculate</TITLE>
****** NAME="GENERATOR" CONTENT="MAX's HTML Beauty++ 2004">
<script>
<!--

function delegate(){

var nationname = document.f.nation.value

var site = "http://nationstates.net/cgi-bin/nationdata.cgi/nation="+nationname

var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")

xmlDoc.async = "false";
xmlDoc.load(site);

var populat = xmlDoc.getElementsByTagName('POPULATION').item(0).text
var region = xmlDoc.getElementsByTagName('REGION').item(0).text
var flag = xmlDoc.getElementsByTagName('FLAG').item(0).text
var fullname = xmlDoc.getElementsByTagName('FULLNAME').item(0).text
var un = xmlDoc.getElementsByTagName('UNSTATUS').item(0).text

if(un.toLowerCase() == "un delegate"){
var site2 = "http://nationstates.net/cgi-bin/regiondata.cgi/region="+region

var xmlDoc2 = new ActiveXObject("Microsoft.XMLDOM")

xmlDoc2.async = "false";
xmlDoc2.load(site2);
var delegatevotes = xmlDoc2.getElementsByTagName('DELEGATEVOTES').item(0).text - 1

document.write("<center><img src = '"+flag+"'><br /><b>"+fullname+"</b></center>")
document.write("<left><b>Delegate Votes</b>: "+ delegatevotes)
}
else{
document.write("<font color = 'red'>Nation is not the UN delegate</font>")
}
}
//-->
</script>
</HEAD>

<BODY>

<form name = "f">
<input type = "text" name = "nation">
<input type = "button" onclick = "delegate()" value = "Calculate">

</BODY>
</HTML>


Just save it as a html. However it will only give you the delegates endorsements, there doesn't appear to be anymore information in the xmls.

http://213.208.119.243/cgi-bin/nationdata.cgi/nation=enerica

http://213.208.119.243/cgi-bin/regiondata.cgi/region=america
Tuesday Heights
28-07-2004, 20:36
All right, cool - like I said - you're my hero!

I really need to learn how to do this!
Enerica
28-07-2004, 20:36
A script can't pull any more info than you could yourself, manually.
Max added to the xml feed once when someone asked didn't he? Could he add an individual nations endorsement pweeeeeease :)

Could you say no to that smilie?
Enerica
28-07-2004, 20:38
All right, cool - like I said - you're my hero!

I really need to learn how to do this!
I only recently learned, when I found out more about xml, after learning that ns had a way to gather data, and I thought it could help my gdp calculator.

By the Way, if you intend to use that on the internet instead of just on your pc, you may have trouble finding a host with which it will work. And I hope you use IE, or you'll have to get someone who can do it with php.
Tuesday Heights
28-07-2004, 20:54
All right, I'm going to see what happens with it.
Tuesday Heights
29-07-2004, 00:58
Maybe I'm not doing something right... but I can't get it to work... :headbang:
Enerica
29-07-2004, 09:18
Argh! It won't let me upload html files.

Hmm, you pasted it into notepad etc.

Then saved it as a .html file?

Opened it in IE.

?

Do you have an updated IE?
Heftig
29-07-2004, 10:21
Doesn't work for me eiter...
Did all you said...local and on a server...hmmm...

The only result I get sometimes is "Nation is not the UN delegate"

And about the XML feed: Try getting information form the region "10000 Islands"... That somehow doesn't work at all, not even using the %20 characters
Cork South Central
29-07-2004, 10:36
it only works for me if i put in a nation.
jscript error if i put in a region

if i put in a un delegate, it come back with the number of endorsements, their flag and full nation state name
Tuesday Heights
29-07-2004, 11:28
I saved it like you said: notepad to HTML file. It loads fine, it just doesn't let me search at all.
Naleth
29-07-2004, 12:35
I've dont some scripting for NS in java (ok it was modifying existing scripts, but heavily modifying). They do a couple of the things you asked about (mostly endorsement related stuff) and a couple other things you didn't ask for.

Not scripts I plan to release, though.

They were based on Safalra's scripts (http://forums2.jolt.co.uk/showthread.php?t=313056) from a few months ago, which are available publically. But they don't do anything with endorsements (except collect the Delegate's endorsement-given list). And you'll need a java runtime environment installed to use them (although its quite possible you already have it).
Enerica
29-07-2004, 17:59
Oh, not sure.

It's to be used to enter a delegate name, try mine.

Click the button as opposed to just pressing enter.

Then cross fingers.
Enerica
29-07-2004, 18:02
I'll have to make it a bit clearer to let people know what to do, at least it worked on someones :D

I'll have to try and make a better one at a later date.
Tuesday Heights
30-07-2004, 02:00
I don't know what I'm doing wrong, but it just doesn't work for me; thanks for trying though! I really, really do appreciate it!

Thanks, Naleth, for the link! Much appreciated as well!
Enerica
30-07-2004, 12:21
oooo Just a though, do you have Javascript turned on. I forgot to add something for that.
Juxtapositions
30-07-2004, 13:56
Did you want something like this?
http://24.35.16.62/unnation.php?Nation=tuesday_heights

(Change the nation name at the end for a different nation, use underscores for spaces)
Tuesday Heights
30-07-2004, 18:25
Did you want something like this?
http://24.35.16.62/unnation.php?Nation=tuesday_heights

(Change the nation name at the end for a different nation, use underscores for spaces)

Oh, yes, that works nicely for now... is their any way to list who is endorsing the nation in question though?

I don't mean to pester everyone, I just really don't know how to do any of this, and I'd love to learn if I had the time; I'm very appreciative of your help guys. :-)
Juxtapositions
30-07-2004, 18:54
Oh, yes, that works nicely for now... is their any way to list who is endorsing the nation in question though?

I don't mean to pester everyone, I just really don't know how to do any of this, and I'd love to learn if I had the time; I'm very appreciative of your help guys. :-)
Yes, however in order to build the suspense You'll have to wait for about 8 hours.

Also because I have to get home to be able to make the changes.

What kind of format do you want that nation list in? (table, big ol' list, links, Purple with greens spots....)
Tuesday Heights
30-07-2004, 18:56
Yes, however in order to build the suspense You'll have to wait for about 8 hours.

Also because I have to get home to be able to make the changes.

What kind of format do you want that nation list in? (table, big ol' list, links, Purple with greens spots....)

A table would be links would be swell, if you can. Thanks, Jux! I'll never forget it!
Otm Shanks
30-07-2004, 19:02
I've dont some scripting for NS in java (ok it was modifying existing scripts, but heavily modifying). They do a couple of the things you asked about (mostly endorsement related stuff) and a couple other things you didn't ask for.

Not scripts I plan to release, though.

They were based on Safalra's scripts (http://forums2.jolt.co.uk/showthread.php?t=313056) from a few months ago, which are available publically. But they don't do anything with endorsements (except collect the Delegate's endorsement-given list). And you'll need a java runtime environment installed to use them (although its quite possible you already have it).

Is anyone else getting Java errors trying to run Safalra's scripts?
Enerica
30-07-2004, 19:27
Yes, however in order to build the suspense You'll have to wait for about 8 hours.

Also because I have to get home to be able to make the changes.

What kind of format do you want that nation list in? (table, big ol' list, links, Purple with greens spots....)
Can you actually gather that information, is there an output I don't know about :eek: :eek: :eek:
Juxtapositions
30-07-2004, 19:48
Can you actually gather that information, is there an output I don't know about :eek: :eek: :eek:

No matter how I answer this question I'm going to sound like a smart ass.

No, you look at it every day. The nations page has all that information.
Enerica
30-07-2004, 19:55
No matter how I answer this question I'm going to sound like a smart ass.

No, you look at it every day. The nations page has all that information.

:D Yep you sound like a smart ass. j/k

I meant a way to gather it through a script, I suppose there must be, but probably not in the languages I want to use.
Juxtapositions
30-07-2004, 20:07
I use PHP and I'm gathering that's not the language you want to use.

It looks like you're using java. It should be a simple matter of opening the URL for the nation and then gathering the data.

I could see where JavaScript would allow you to do it too using the XMLHTTP class. Advantage there is that you wouldn't need a java interpreter.
Amicus curiae
30-07-2004, 23:40
Is anyone else getting Java errors trying to run Safalra's scripts?

I can run the script.
However, i am getting the errors when i try to save the information after running the script.
:headbang:
Tuesday Heights
31-07-2004, 04:55
I can run the script.
However, i am getting the errors when i try to save the information after running the script.

Yeah, I get the errors, too; hence, why I don't use it.
Juxtapositions
01-08-2004, 06:12
Sorry that took longer than 8 hours. I got busy with other stuff. It's ready now.
Tuesday Heights
01-08-2004, 16:05
Sorry that took longer than 8 hours. I got busy with other stuff. It's ready now.

Awesome, Jux! Thanks for that!
Juxtapositions
01-08-2004, 19:37
Awesome, Jux! Thanks for that!

You're welcome. Glad to be of help.