Page 107 of 118

Re: Scripters cove

Posted: Thu Jul 21, 2022 10:12 pm
by Old Murgh
phkb wrote: Thu Jul 21, 2022 10:07 pm
You'd need to use (1, 1). But in that case, there is no need to call the function at all, because it would only ever return 1.
Thank you.

Re: Scripters cove

Posted: Thu Jul 21, 2022 10:14 pm
by phkb
Old Murgh wrote: Thu Jul 21, 2022 9:57 pm
// spawns 1 - 3 ships with role scrub
The random function would return a number between and 1 and 2, not 1 and 3.

Re: Scripters cove

Posted: Thu Jul 21, 2022 10:19 pm
by Old Murgh
phkb wrote: Thu Jul 21, 2022 10:14 pm
Old Murgh wrote: Thu Jul 21, 2022 9:57 pm
// spawns 1 - 3 ships with role scrub
The random function would return a number between and 1 and 2, not 1 and 3.
Thanks for pointing out. Probably an old comment not kept up with a change.

Re: Scripters cove

Posted: Thu Jul 21, 2022 11:07 pm
by phkb
Slartibartfast wrote: Thu Jul 21, 2022 1:53 pm
--> equipment.plist / TL99

hmmm

a "condition-script " as solution
for me that seems to be more a "workaround"


==> for the next time i stay with "99"

and :wink:
( linux/bash)

Code: Select all

grep -v deprecated Latest.log > Last.log
TL99 was used to restrict access to equipment, if, for example, you wanted to hide the equipment generally, and then programmatically give the equipment to the player. But there are limits: using TL99 means there is no where in the galaxy you can go to fix it if it's damaged, and you wouldn't be able to easily repair it. TL99 also means it will *never* appear on the F3 screen, and the only way to get it is programmatically.

A condition script gives you full control over the equipment item, allowing you to accurately define it's TL, so it can fit into the standard repair mechanisms, while still limiting if and when the equipment item is offered for sale. You could limit by station type, or government, or economy, or anything else.

So, not really a "workaround". A condition_script gives you full control, and better integration with the core game mechanics.

Re: Scripters cove

Posted: Fri Jul 22, 2022 5:25 am
by another_commander
What phkb said. In fact, TL 99 has always been a hack and the condition script is the proper way to do it. But, as long as the hack is still present, one can use whatever feels easier and simpler for them.

Re: Scripters cove

Posted: Fri Jul 22, 2022 10:49 am
by Slartibartfast
Hello

O.K.

i understand
the condition script is the "Bentley"

but i only need a backpack

Code: Select all

(99,0,"Remaining Module-Rackspace","EQ_RACKSPACE","Rackspace bla bla bla",
		{
			"available_to_all" = yes;
			"requires_equipment" = "EQ_Q_BASE_SYSTEM";
			"requires_cargo_space" = 0;
			"display_color" = "blueColor";  //  only for testing 
			"visible" = yes; 
			"can_carry_multiple" = yes;
			"damage_probability" = 0;
			"installation_time" = 0;
			"can_carry_multiple" = yes;
			"portable_between_ships" = no;
		}
!! its a placeholder - in two ways
------- programming / easy to handle
------ gameplay - its a part of the base_system and holds place for modules

matthias

Re: Scripters cove

Posted: Fri Jul 22, 2022 12:41 pm
by montana05
Slartibartfast wrote: Fri Jul 22, 2022 10:49 am
Hello

O.K.

i understand
the condition script is the "Bentley"

but i only need a backpack

Not exactly, as 3 persons tried to tell you, a condition script is standard while TL 99 is a hack.

Re: Scripters cove

Posted: Fri Jul 22, 2022 8:32 pm
by Slartibartfast
hi

Code: Select all

a condition script is standard while TL 99 is a hack.
yes yes -- i already understood

but no matter....

--------------------
i have tried to find an example with the same properties, that i need, in different oxp/oxz
---> no success

btw.
i have problems to understand the information in some wiki pages and
the "names" of a some functions etc.
f.x. "allowAwardEquipment" -- for me it sounds like " allow to award equipment"
--- therefore -i thought - "this must be a condition for ships / not for equipment"

please
can someone post a fitting example ( i wanna do it right )

thx
matthias

Re: Scripters cove

Posted: Fri Jul 22, 2022 10:09 pm
by phkb
Slartibartfast wrote: Fri Jul 22, 2022 8:32 pm
can someone post a fitting example ( i wanna do it right )
In it's most simplest form, using a condition script would look like this:
equipment.plist

Code: Select all

(
	(
		5, 1000, "Remaining Module-Rackspace","EQ_RACKSPACE","Rackspace bla bla bla",
		{
			"available_to_all" = yes;
			"condition_script" = "myequipment_conditions.js";
			"requires_equipment" = "EQ_Q_BASE_SYSTEM";
			"requires_cargo_space" = 0;
			"display_color" = "blueColor";  //  only for testing 
			"visible" = yes; 
			"can_carry_multiple" = yes;
			"damage_probability" = 0;
			"installation_time" = 0;
			"can_carry_multiple" = yes;
			"portable_between_ships" = no;
		}
	),
)
Then, create a file called "myequipment_conditions.js" in the "Scripts" folder

Code: Select all

"use strict";
this.name = "MyEquipment_Conditions";

this.allowAwardEquipment = function (equipment, ship, context) {
	if (context == "scripted") return true;
	return false;
}
And that's it. Your equipment won't be offered for sale anywhere, but it can be awarded programmatically.
Slartibartfast wrote: Fri Jul 22, 2022 8:32 pm
"allowAwardEquipment" -- for me it sounds like " allow to award equipment"
I think the name comes from the function you execute to give equipment to a ship: ship.awardEquipment. So, what "allowAwardEquipment" is saying is "Allow the 'awardEquipment' function".

Re: Scripters cove

Posted: Sat Jul 23, 2022 12:03 am
by Slartibartfast
thx


==> code
i`ll try now

----------------------------------------

Code: Select all

I think the name comes from the function you execute to give equipment to a ship: ship.awardEquipment. So, what "allowAwardEquipment" is saying is "Allow the 'awardEquipment' function"
such explanations i miss in the wiki // maybe for experienced developers this is not necessary
-- - but that would help (and did not frustrate newbies like me. )

Re: Scripters cove

Posted: Sat Jul 23, 2022 2:01 am
by Slartibartfast
Hi

this seems to work: :D

Code: Select all

//  test
"use strict";
this.name = "QVE_Rackspace_Conditions";

var context = "scripted";   //  added

this.allowAwardEquipment = function (equipment, ship, context) {
	if (context == "scripted") return true;
	return false;
}
but i did not understand the description in the wiki so far :(

good night
Slartibartfast

Re: Scripters cove

Posted: Sat Jul 23, 2022 2:27 am
by Switeck
I'm having problems getting the desired escorts for a Boa 2...

Which one of these should work:

"escort_role" = "navy-asp";
"escort-role" = "navy-asp";
"escort-ships" = "navy-asp";
"escort-ship" = "navy-asp";
"escort_ship" = "navy-asp";
"escort_ships" = "navy-asp";

Re: Scripters cove

Posted: Sat Jul 23, 2022 4:34 am
by montana05
Switeck wrote: Sat Jul 23, 2022 2:27 am
I'm having problems getting the desired escorts for a Boa 2...

Which one of these should work:

"escort_role" = "navy-asp";
"escort-role" = "navy-asp";
"escort-ships" = "navy-asp";
"escort-ship" = "navy-asp";
"escort_ship" = "navy-asp";
"escort_ships" = "navy-asp";
For simple escorts you can use

escort_role (the role of the ship) or
escort_ship (the key of the ship).

Combining it with escorts and a number might be useful.

escort_roles offers you a variable number of escorts, you can assign only 1 ship (role) with min and max so that in more dangerous systems more escorts will be assigned.

Re: Scripters cove

Posted: Sat Jul 23, 2022 7:18 am
by phkb
Slartibartfast wrote: Sat Jul 23, 2022 2:01 am

Code: Select all

var context = "scripted";   //  added
That line is unnecessary. "context" is passed into the function by the core code when it's checking the equipment item. If you were encountering situations that made that line of code necessary, then something else is happening, and we'd need a bit of context to help out.
Slartibartfast wrote: Sat Jul 23, 2022 2:01 am
but i did not understand the description in the wiki so far
I've updated the wiki a bit to hopefully explain things a bit more. It's a bit tricky: as you say earlier, I find it easy to understand, but I'm a programmer. It's hard to know where exactly to add descriptions, without writing an OXP for every function! (Although, perhaps, in fairness, an OXP for every function is what is needed for non-programmers to get their heads around it).

Re: Scripters cove

Posted: Sat Jul 23, 2022 8:56 am
by Switeck
montana05 wrote: Sat Jul 23, 2022 4:34 am
Switeck wrote: Sat Jul 23, 2022 2:27 am
I'm having problems getting the desired escorts for a Boa 2...
For simple escorts you can use

escort_role (the role of the ship) or
escort_ship (the key of the ship).

Combining it with escorts and a number might be useful.

escort_roles offers you a variable number of escorts, you can assign only 1 ship (role) with min and max so that in more dangerous systems more escorts will be assigned.
Neither
escort_role (the role of the ship) nor
escort_ship (the key of the ship)
...seem to work.

Where there is supposed to be 1 escort ship-type, I'm seeing Geckos, Mambas, Sidewinders, Cobra 1's and 3's, etc!

I am using a separate line of:
escorts = 4;
...To define how many escorts to have.

The ships I'm trying to make escorts exist, as I can spawn them separately using this line:

Code: Select all

system.addGroup("navy-asp", 4, [0,0,0], 30E3);