Thanks. That feels much easier to get my head around.phkb wrote: ↑Fri Jul 08, 2022 10:50 pmMy suggestion isBecause it removes unnecessary calculations, while still being clear what percentage is being checked, in this case a 10% chance. To make it 50% just change 0.1 to 0.5.Code: Select all
if (Math.random() < 0.1)
Scripters cove
Moderators: winston, another_commander
Re: Scripters cove
I was young, I was naïve. Jonny Cuba made me do it!
- Slartibartfast
- Deadly
- Posts: 175
- Joined: Mon Jan 21, 2008 3:54 pm
Re: Scripters cove
Hello
again i have some simple questions
===> equipment.plist / "canCarryMultiple"
F.x. from "FuelTweaks.oxz": --> "Quirium Fuel Storage Unit"
- - (Is it possible to / How can i) get the number of installed pieces in a script?
- - Is it possible the set a maximum of pieces for a a ship? ( maybe in shipdata.plist )
matthias
again i have some simple questions
===> equipment.plist / "canCarryMultiple"
F.x. from "FuelTweaks.oxz": --> "Quirium Fuel Storage Unit"
- - (Is it possible to / How can i) get the number of installed pieces in a script?
- - Is it possible the set a maximum of pieces for a a ship? ( maybe in shipdata.plist )
matthias
Oolite 1.91 / Imp. Trader ( slighly modified ) on Lubuntu 22.04 LTS on AMD64 2x 3800+ ,
ATI Radeon R7240 XFS / Samsung TV 40" 1080p
C-Media CMI8738 / Yamaha RX-V575 / DIY-Speaker
Logitech Attack3 & standard german keyboard
ATI Radeon R7240 XFS / Samsung TV 40" 1080p
C-Media CMI8738 / Yamaha RX-V575 / DIY-Speaker
Logitech Attack3 & standard german keyboard
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Scripters cove
This should get you going:Slartibartfast wrote: ↑Fri Jul 15, 2022 6:50 pm- - (Is it possible to / How can i) get the number of installed pieces in a script?
Code: Select all
var data = player.ship.equipmentStatus("EQ_FUEL_STORAGE", true);
log(this.name, "Number of EQ_FUEL_STORAGE units OK: " + data["EQUIPMENT_OK"]);
log(this.name, "Number of EQ_FUEL_STORAGE units Damaged: " + data["EQUIPMENT_DAMAGED"]);
Only via script I'm afraid.Slartibartfast wrote: ↑Fri Jul 15, 2022 6:50 pm- - Is it possible the set a maximum of pieces for a a ship? ( maybe in shipdata.plist )
Code: Select all
this.playerBoughtEquipment = function(equipmentKey, paid) {
if (equipmentKey == "EQ_FUEL_STORAGE") {
var data = player.ship.equipmentStatus("EQ_FUEL_STORAGE", true);
// make the limit 10 units
if (data["EQUIPMENT_OK"] + data["EQUIPMENT_DAMAGED"] > 10) {
// remove the item
player.ship.removeEquipment("EQ_FUEL_STORAGE");
// refund the player
player.credits += paid;
}
}
}
- Slartibartfast
- Deadly
- Posts: 175
- Joined: Mon Jan 21, 2008 3:54 pm
Re: Scripters cove
Hello Admiral
Thank you!
--- works great
only one small correction
in the second script snip i had to replace
player.credits += paid;
---with
player.credits += (paid / 10);
else i have a moneymaking machine.
cheers
Slartibartfast
Thank you!
--- works great
only one small correction
in the second script snip i had to replace
player.credits += paid;
---with
player.credits += (paid / 10);
else i have a moneymaking machine.
cheers
Slartibartfast
Oolite 1.91 / Imp. Trader ( slighly modified ) on Lubuntu 22.04 LTS on AMD64 2x 3800+ ,
ATI Radeon R7240 XFS / Samsung TV 40" 1080p
C-Media CMI8738 / Yamaha RX-V575 / DIY-Speaker
Logitech Attack3 & standard german keyboard
ATI Radeon R7240 XFS / Samsung TV 40" 1080p
C-Media CMI8738 / Yamaha RX-V575 / DIY-Speaker
Logitech Attack3 & standard german keyboard
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Scripters cove
Right! I should update the doco to reflect this. *makes mental note*Slartibartfast wrote: ↑Sat Jul 16, 2022 2:30 pmonly one small correction
in the second script snip i had to replace
player.credits += paid;
---with
player.credits += (paid / 10);
- Slartibartfast
- Deadly
- Posts: 175
- Joined: Mon Jan 21, 2008 3:54 pm
Re: Scripters cove
hi
==> equipment.plist
from: https://wiki.alioth.net/index.php/Equipment.plist
What should i use instead of "99" to make EQ not buyable?
I have not found any info -- neither in the wiki, nor in the forum.
Matthias
==> equipment.plist
from: https://wiki.alioth.net/index.php/Equipment.plist
but in my logs this appears: --- veryveryveryvery often1) The first entry is an integer that determines the technical level from which the equipment can be bought. A level of 99 has a special meaning. Only this value can be changed by script. Please note that the number displayed on the system data screen is one higher than the system's tech level, so to make equipment available at a displayed TL:10 and above in game, enter 9 here
Code: Select all
[oxp-standards.deprecated]: TL99 is deprecated for EQ_.......
I have not found any info -- neither in the wiki, nor in the forum.
Matthias
Oolite 1.91 / Imp. Trader ( slighly modified ) on Lubuntu 22.04 LTS on AMD64 2x 3800+ ,
ATI Radeon R7240 XFS / Samsung TV 40" 1080p
C-Media CMI8738 / Yamaha RX-V575 / DIY-Speaker
Logitech Attack3 & standard german keyboard
ATI Radeon R7240 XFS / Samsung TV 40" 1080p
C-Media CMI8738 / Yamaha RX-V575 / DIY-Speaker
Logitech Attack3 & standard german keyboard
- Slartibartfast
- Deadly
- Posts: 175
- Joined: Mon Jan 21, 2008 3:54 pm
Re: Scripters cove
next question about equipment.plist
to make "requires (equipment_a AND equipment_b)"
i have made this
does anybody now a better way?
cheers
to make "requires (equipment_a AND equipment_b)"
i have made this
Code: Select all
"requires_equipment" = "EQ_A";
"requires_any_equipment" = ("EQ_B");
cheers
Oolite 1.91 / Imp. Trader ( slighly modified ) on Lubuntu 22.04 LTS on AMD64 2x 3800+ ,
ATI Radeon R7240 XFS / Samsung TV 40" 1080p
C-Media CMI8738 / Yamaha RX-V575 / DIY-Speaker
Logitech Attack3 & standard german keyboard
ATI Radeon R7240 XFS / Samsung TV 40" 1080p
C-Media CMI8738 / Yamaha RX-V575 / DIY-Speaker
Logitech Attack3 & standard german keyboard
- montana05
- ---- E L I T E ----
- Posts: 1166
- Joined: Mon May 30, 2016 3:54 am
- Location: lurking in The Devils Triangle (G1)
Re: Scripters cove
Good evening Matthias,Slartibartfast wrote: ↑Thu Jul 21, 2022 10:27 amWhat should i use instead of "99" to make EQ not buyable?
I have not found any info -- neither in the wiki, nor in the forum.
Matthias
did you have a closer look at
"available_to_all" =
"available_to_NPCs" =
"available_to_player" =
?
Scars remind us where we've been. They don't have to dictate where we're going.
- montana05
- ---- E L I T E ----
- Posts: 1166
- Joined: Mon May 30, 2016 3:54 am
- Location: lurking in The Devils Triangle (G1)
Re: Scripters cove
requires_equipment, requires_any_equipment, incompatible_with_equipment can be a single string or an array of strings.Slartibartfast wrote: ↑Thu Jul 21, 2022 10:59 amnext question about equipment.plist
to make "requires (equipment_a AND equipment_b)"
i have made thisdoes anybody now a better way?Code: Select all
"requires_equipment" = "EQ_A"; "requires_any_equipment" = ("EQ_B");
cheers
For both issues, you can also use a condition script.
Scars remind us where we've been. They don't have to dictate where we're going.
- Slartibartfast
- Deadly
- Posts: 175
- Joined: Mon Jan 21, 2008 3:54 pm
Re: Scripters cove
Hi montana
when i set
"available_to_all" = no
i can´t install that via script/player.ship.awardEquipment
with "99" and "= yes" it works as i want
when i set
"available_to_all" = no
i can´t install that via script/player.ship.awardEquipment
with "99" and "= yes" it works as i want
Oolite 1.91 / Imp. Trader ( slighly modified ) on Lubuntu 22.04 LTS on AMD64 2x 3800+ ,
ATI Radeon R7240 XFS / Samsung TV 40" 1080p
C-Media CMI8738 / Yamaha RX-V575 / DIY-Speaker
Logitech Attack3 & standard german keyboard
ATI Radeon R7240 XFS / Samsung TV 40" 1080p
C-Media CMI8738 / Yamaha RX-V575 / DIY-Speaker
Logitech Attack3 & standard german keyboard
- montana05
- ---- E L I T E ----
- Posts: 1166
- Joined: Mon May 30, 2016 3:54 am
- Location: lurking in The Devils Triangle (G1)
Re: Scripters cove
I had a similar issue in the past, just can't remember in which OXP. As much as I recall, I used a condition script at the end. I am currently relaxing with a bottle of sake on the beach, so no access to my database. I can have a look tomorrow morning and, hopefully, provide you with a solution.Slartibartfast wrote: ↑Thu Jul 21, 2022 12:50 pmHi montana
when i set
"available_to_all" = no
i can´t install that via script/player.ship.awardEquipment
with "99" and "= yes" it works as i want
EDIT:
For now, please have a look at this: https://wiki.alioth.net/index.php/Oolit ... on_scripts. this.allowAwardEquipment = function(eqKey, ship, context) is probably what you are looking for.
Last edited by montana05 on Thu Jul 21, 2022 1:14 pm, edited 2 times in total.
Scars remind us where we've been. They don't have to dictate where we're going.
- Slartibartfast
- Deadly
- Posts: 175
- Joined: Mon Jan 21, 2008 3:54 pm
Re: Scripters cove
==> equipment.plist / requires
ok this works fine
maybe the wiki should be updated
like this:
"requires_equipment" = ("EQ_FUEL_SCOOPS, "EQ_OTHER"); // array of strings - add as much as you want
ok this works fine
Code: Select all
"requires_equipment" = ("EQ_A","EQ_B");
like this:
"requires_equipment" = ("EQ_FUEL_SCOOPS, "EQ_OTHER"); // array of strings - add as much as you want
Oolite 1.91 / Imp. Trader ( slighly modified ) on Lubuntu 22.04 LTS on AMD64 2x 3800+ ,
ATI Radeon R7240 XFS / Samsung TV 40" 1080p
C-Media CMI8738 / Yamaha RX-V575 / DIY-Speaker
Logitech Attack3 & standard german keyboard
ATI Radeon R7240 XFS / Samsung TV 40" 1080p
C-Media CMI8738 / Yamaha RX-V575 / DIY-Speaker
Logitech Attack3 & standard german keyboard
- Slartibartfast
- Deadly
- Posts: 175
- Joined: Mon Jan 21, 2008 3:54 pm
Re: Scripters cove
--> 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
( linux/bash)
hmmm
a "condition-script " as solution
for me that seems to be more a "workaround"
==> for the next time i stay with "99"
and
( linux/bash)
Code: Select all
grep -v deprecated Latest.log > Last.log
Oolite 1.91 / Imp. Trader ( slighly modified ) on Lubuntu 22.04 LTS on AMD64 2x 3800+ ,
ATI Radeon R7240 XFS / Samsung TV 40" 1080p
C-Media CMI8738 / Yamaha RX-V575 / DIY-Speaker
Logitech Attack3 & standard german keyboard
ATI Radeon R7240 XFS / Samsung TV 40" 1080p
C-Media CMI8738 / Yamaha RX-V575 / DIY-Speaker
Logitech Attack3 & standard german keyboard
Re: Scripters cove
My finger has slipped somewhere. I thought I had a handle on this as a template butphkb wrote: ↑Fri Jul 08, 2022 10:50 pmMy suggestion isBecause it removes unnecessary calculations, while still being clear what percentage is being checked, in this case a 10% chance. To make it 50% just change 0.1 to 0.5.Code: Select all
if (Math.random() < 0.1)
Code: Select all
//add magmiss to system
this.systemWillPopulate = function ()
{
if (Math.random() < 0.2) // sets a 20% chance
{
system.setPopulator("magmiss",
{
callback: function(pos)
{
system.addShips("magmiss", worldScripts["magmiss_populator"].$getRndInteger(1), pos); // spawns 1 ship with role magmiss
}.bind(this),
location: "LANE_WP",
locationSeed: 0
// 0 = completely random position on the lane, otherwise use a specific seed number to have them in the same position each time
});
}
}
this.$getRndInteger = function(min, max)
{
return (Math.floor(Math.random() * (max - min + 1) ) + min);
};
Code: Select all
23:39:23.975 [script.javaScript.exception.ooliteDefined]: ***** JavaScript exception (magmiss_populator b1): Error: System.addShips: Invalid arguments (NaN) -- expected number (positive count no greater than 64).
Does this have to do with me thinking I could alter this line
Code: Select all
system.addShips("scrub", worldScripts["scrub_populator"].$getRndInteger(1, 2), pos); // spawns 1 - 3 ships with role scrub
I was young, I was naïve. Jonny Cuba made me do it!
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Scripters cove
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.