Oolite Bulletins

For information and discussion about Oolite.
It is currently Thu Nov 23, 2017 11:07 am

All times are UTC




Post new topic  Reply to topic  [ 1403 posts ]  Go to page 1 2 3 4 594 Next
Author Message
 Post subject: Scripters cove
PostPosted: Sun Mar 11, 2007 6:18 pm 
Offline
Dangerous Subversive Element
Dangerous Subversive Element
User avatar

Joined: Tue Jun 07, 2005 7:32 pm
Posts: 1876
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
This thread will hopefully become a usefull resourse for scripting

offering interesting methods,

basic (modular) scripts,

and cooperative assistance by the cOomunity for scriptcoders just starting out or experienced ones with a difficult problem.

_________________
Riding the Rocket!


Top
   
PostPosted: Sun Mar 11, 2007 6:22 pm 
Offline
Dangerous Subversive Element
Dangerous Subversive Element
User avatar

Joined: Tue Jun 07, 2005 7:32 pm
Posts: 1876
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
The following method should disable legalStatus in anarchy systems, but restore it in lawfull systems.
It contains several comments. (/*) which can be taken out.
Code:
{
	"temporary_legal_cutout_script" = (
		{
			conditions = (
				"status_string equal STATUS_EXITING_WITCHSPACE",
				"mission_legalStatus_backup equal UNDEFINED"
			);
			do = ();
			else = (
				"setLegalStatus: [mission_legalStatus_backup]",
				"reset: mission_legalStatus_backup"
			);
		},
		{
			conditions = (
				"systemGovernment_string equal Anarchy"
			);
/* conditions could be replaced by anything, example: a set of planet_numbers representing Your_private_Corporate_Emporium. */
			do = (
				{
					conditions = (
						"status_string equal STATUS_EXITING_WITCHSPACE"
					);
					do = (
						"set: mission_legalStatus_backup [legalStatus_number]",
						"setLegalStatus: 0"
					);
				},
/* Can also set credit_number for instance, "Your money is no good in this system Commander". */
				{
					conditions = (
						"status_string equal STATUS_IN_FLIGHT",
						"legalStatus_number morethan 0"
					);
					do = (
						"setLegalStatus: 0"
					);
				}
			);
		}
	);
}

_________________
Riding the Rocket!


Last edited by Arexack_Heretic on Tue Mar 13, 2007 11:00 pm, edited 11 times in total.

Top
   
 Post subject:
PostPosted: Sun Mar 11, 2007 7:19 pm 
Offline
Grand High Clock-Tower Poobah
Grand High Clock-Tower Poobah
User avatar

Joined: Tue Sep 19, 2006 1:10 pm
Posts: 2312
Location: Anywhere I can sell Trumbles.....
Could someone Sticky this and the 'Things I wished I knew...' thread for ease of referencing, please?

Captain Hesperus


Top
   
 Post subject:
PostPosted: Sun Mar 11, 2007 8:05 pm 
Offline
Grand Admiral Emeritus
Grand Admiral Emeritus
User avatar

Joined: Sat Apr 02, 2005 2:43 pm
Posts: 6657
Location: Sweden
Quote:
Could someone Sticky this and the 'Things I wished I knew...' thread for ease of referencing, please?
Sure. You might want to ask Mr. Heretic to test his code, though. Sample code that doesn’t work can be frustrating. :-)

Then again, this whole subforum is supposed to be a “useful resource for scripting”. Perhaps the wiki would be a better place for sample code?

_________________
E-mail: jens@oolite.org


Top
   
 Post subject:
PostPosted: Sun Mar 11, 2007 10:05 pm 
Offline
Pirate
Pirate
User avatar

Joined: Mon Sep 27, 2004 10:21 pm
Posts: 731
Location: Port St. Mary, Isle of Man
If these tips aren't already in the Wiki, consider making a section for them in the wiki too.


Top
   
 Post subject:
PostPosted: Mon Mar 12, 2007 10:36 am 
Offline
Dangerous Subversive Element
Dangerous Subversive Element
User avatar

Joined: Tue Jun 07, 2005 7:32 pm
Posts: 1876
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
Quote:
You might want to ask Mr. Heretic to test his code, though. Sample code that doesn’t work can be frustrating. :-)
Indeed you should, because I haven't. :shock:
how did you recognise it?
Quote:
Then again, this whole subforum is supposed to be a “useful resource for scripting”. Perhaps the wiki would be a better place for sample code?
You are right about that, but before poluting the wiki with spam, it would be better perhaps to discuss stuff here.

Maybe I should append the first post to also state:
"to discuss the best ways and techniques for tackling plist-scripting challenges and propose wiki entries." ?

---

I intend this thread to also be an "ask-the-experts" kind of feature.

---

So what will be the first challenge?

Code the most elegant way to have planets and moons simulate orbitting eachother in a single system?

Code to check what type of ship Player_entity is driving, without resorting to crude methods like adding a custom piece of EQ to each individual ship.?

_________________
Riding the Rocket!


Top
   
 Post subject:
PostPosted: Mon Mar 12, 2007 12:00 pm 
Offline
Grand Admiral Emeritus
Grand Admiral Emeritus
User avatar

Joined: Sat Apr 02, 2005 2:43 pm
Posts: 6657
Location: Sweden
Quote:
how did you recognise it?
I looked at and thought “hey, that’s not a valid plist.” It’s one of my amazing programmer superpowers. There are three quotation marks missing in the first conditions= line, for instance.

By the way, you can put comments in a plist using /* comment */ syntax (or <!-- comment --> for XML plists).

_________________
E-mail: jens@oolite.org


Top
   
 Post subject:
PostPosted: Mon Mar 12, 2007 12:22 pm 
Offline
Dangerous Subversive Element
Dangerous Subversive Element
User avatar

Joined: Tue Jun 07, 2005 7:32 pm
Posts: 1876
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
Ha! you are right, by Giles!
I wrote it on the train to Rotterdam, while nursing a hangover.
But that is no excuse for my poor re-typing it here. ;)

thanks for the plist-comment code, that is one of those things that needs to be added to the wiki. :D

<editing script now> :arrow:

_________________
Riding the Rocket!


Top
   
 Post subject:
PostPosted: Mon Mar 12, 2007 1:41 pm 
Offline
Grand Admiral Emeritus
Grand Admiral Emeritus
User avatar

Joined: Sat Apr 02, 2005 2:43 pm
Posts: 6657
Location: Sweden
You’ve got the /* and */ the wrong way around in the first comment. Still untested, then. ;-)

_________________
E-mail: jens@oolite.org


Top
   
 Post subject:
PostPosted: Mon Mar 12, 2007 1:44 pm 
Offline
Dangerous Subversive Element
Dangerous Subversive Element
User avatar

Joined: Tue Jun 07, 2005 7:32 pm
Posts: 1876
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
yes.
and: "drat!", edit-re-re-corrected back wrongly. :duh:

funny thing though that morethan and greaterthan are both accepted... logical arguments?
---
maybe agree to some format rules.
post only checked, working code in codeboxes.
WIP or unchecked suggestions in blue.
questions in red?

---
OK.
As a personal challenge, I'm going to try to script trader convoys.
The biggest challenge will be to do it elegantly. ;)

_________________
Riding the Rocket!


Top
   
 Post subject:
PostPosted: Tue Mar 13, 2007 12:23 pm 
Offline
Dangerous Subversive Element
Dangerous Subversive Element
User avatar

Joined: Tue Jun 07, 2005 7:32 pm
Posts: 1876
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
Quote:
I looked at and thought “hey, that’s not a valid plist.”
That is what oolite tells me too. :(
Unfortunately, I cannot find any more missing parentheses and such.

edit: Found the buggers.
I'm not used to coding in ASCII.
I used }, everywhere to close segments, whereas it is only needed if two condition-sets are in the same layer.
Only need to test it 'live' in an anarchy. It's a bit late though; have been beavering away at that Convoy I promised. I decided to use it as an introductionary script for the PPC-Alt2. (hunts nicely in packs!)
Unfortunately something gets busted someplace, it doesn't work with a simple test-script.

_________________
Riding the Rocket!


Last edited by Arexack_Heretic on Tue Mar 13, 2007 10:58 pm, edited 1 time in total.

Top
   
 Post subject:
PostPosted: Tue Mar 13, 2007 4:39 pm 
Offline
Grand Admiral Emeritus
Grand Admiral Emeritus
User avatar

Joined: Sat Apr 02, 2005 2:43 pm
Posts: 6657
Location: Sweden
As it stands, it validates according to OS X’s parser. There are a couple of trailing commas which might possibly cause problems, though. Change the end to:
Code:
      }
   );
);
}

_________________
E-mail: jens@oolite.org


Top
   
 Post subject:
PostPosted: Sat Mar 17, 2007 3:05 pm 
Offline
Dangerous Subversive Element
Dangerous Subversive Element
User avatar

Joined: Tue Jun 07, 2005 7:32 pm
Posts: 1876
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
actually the biggest challenge (in convoy!) is to get the method 'spawn' to work at all.

Isn't it supposed to generate the called ship randomly closeby it's caller?


If the new-entity is being spawned at coordinates from caller 0/0/0, as MacLane suggests, then I would propose to the code-monkeys an additional variable that sets the spawn distance from caller in a sphere...
"spawn: <role> <#> <min_radius> <max_radius>"
with 0 as defaultvalues (maybe name it spawnInRange?)

or perhaps more handy even:
"spawnPrecisely: <role> x y z W X Y Z"
spawning as a quaternion, orientation and origin relative to 'caller' number spawned always 1.
this emulates the script/shipdata method of 'hard'coding the spawninglocations and orientations of entities.

_________________
Riding the Rocket!


Top
   
 Post subject:
PostPosted: Sat Mar 17, 2007 5:36 pm 
Offline
Dangerous Subversive Element
Dangerous Subversive Element
User avatar

Joined: Tue Jun 07, 2005 7:32 pm
Posts: 1876
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
NSDictionary or plist:

are there utilities around (for WIN/DOS) that can validate or check these files automatically?

I'm getting Murghitis. :(

_________________
Riding the Rocket!


Top
   
 Post subject:
PostPosted: Sat Mar 17, 2007 11:44 pm 
Offline
Grand Admiral Emeritus
Grand Admiral Emeritus
User avatar

Joined: Sat Apr 02, 2005 2:43 pm
Posts: 6657
Location: Sweden
Quite probably not. The best bet would seem to be ProjectCenter, the primary GNUstep developer tool. The discuss-gnustep mailing list mentioned on their Getting Help page would be a good page to ask.

Apple’s implementation of property lists provides some validation support and is open source, so building a simple validator shouldn’t be too hard. I’ll look into getting a better definition of “shouldn’t be too hard” tomorrow. If it works out, it’ll be a command-line tool which tells you things like “error on line 47: expected ;" (only one error before bailing).

There are cases where property lists that work on OS X don’t work in GNUstep, but they’re relatively unusual. (We had this problem with logcontrol.plist.) As source for both is available under GPL-compatible languages, standardising on one of them for Oolite is possible in principle but fiddly in practice.

(If we used the OS X one, it could probably simply replace the standard parser, but it’s written in C and relies on a concept called “toll-free bridging” to provide ObjC objects efficiently; it may be possible to hack this into GNUstep, but it’d probably be problematic and would require someone with a good grasp of how the Objective-C runtime works – that’d be me – to work with it on Windows or Linux. To use the GNUstep version, we’d have to change all uses of the many plist-loading methods in Oolite, because the GNUstep one can’t deal with the binary format used for instance by the preference system… or port binary property lists to GNUstep. Actually, I thought of a third path, but I’ll have to look through the Apple implementation to see if it’s tractable.)

_________________
E-mail: jens@oolite.org


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 1403 posts ]  Go to page 1 2 3 4 594 Next

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 18 guests


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

Search for:
cron
Powered by phpBB® Forum Software © phpBB Limited