Page 55 of 118
Re: Scripters cove
Posted: Tue Nov 20, 2012 3:28 pm
by Commander McLane
Not sure whether equipment.plist supports this.
Anyway, if it does, the square brackets should contain the descriptions.plist key, just like in all other substitution cases.
Edit: a quick test shows that it doesn't seem to be supported.
Re: Scripters cove
Posted: Tue Nov 20, 2012 3:41 pm
by cim
And even if it did work, there'd be no guarantee that the equipment would have a consistent name from one view to the next, since entries from descriptions.plist arrays are picked randomly each time.
Re: Scripters cove
Posted: Tue Nov 20, 2012 3:51 pm
by superbatprime
*sigh*
Thanks guys, sheesh I always want to do the thing that can't be done.
At least I've learned enough stuff to get this far.
Okay I'll change tactics.
What if I have all variations of the equipment listed in the equipment plist as separate entries, can I get Oolite to randomly display only one item from the list in the equipment market?
So it would be like this in the equipment plist.
Code: Select all
(
(
0,
5000,
"my item serial #001",
"EQ_MY_ITEM",
"mildly humorous description of the item",
{
"available_to_all" = YES;
"portable_between_ships" = yes;
}
)
)
(
(
0,
5000,
"my item serial #002",
"EQ_MY_ITEM",
"mildly humorous description of the item",
{
"available_to_all" = YES;
"portable_between_ships" = yes;
}
)
)
(I'm sure there are brackets to clean up there but you get the gist).
Can I then get the game to select one at random?
Re: Scripters cove
Posted: Tue Nov 20, 2012 4:06 pm
by cim
If you give them TL:99, you can then set mission variables from script to set one, and only one, in each system - on shipWillExitWitchspace
, probably - to have the real tech level. (In the next version you will be able to do this much more neatly with a "condition script", but this is the easiest way for now)
If you make them all incompatible with each other, that will make this a little easier, too.
Re: Scripters cove
Posted: Tue Nov 20, 2012 4:11 pm
by Commander McLane
The currently best way of selecting which equipment gets offered is through its tech level. That's also the only way I can think of off the top of my head that'll allow you to make sure that every time one (and only one) of several similar items is offered.
First, all your items need a distinct identifier. There may not be two items EQ_MY_ITEM. Thus, you have to name them EQ_MY_ITEM_1, EQ_MY_ITEM_2, and so on.
Second, you have to give all your items a tech level of 99. This is a special tech level, which can be changed to any number you want on the fly (this is expressly not possible for any other tech level).
Then, you need to redefine it in your world script, based on a random selection. If you want a new random each time the player visits the F3-screen,
guiScreenWillChange
is the event you're looking for:
Code: Select all
this.guiScreenWillChange = function(to, from)
{
if(!player.ship.docked) return; // a safety measure, because you could've been launched in the meantime
if(to === "GUI_SCREEN_EQUIP_SHIP")
{
var choice = Math.ceil(Math.random() * 5) // replace with the number of items
switch(choice)
{
case 1:
EquipmentInfo.infoForKey("EQ_MY_ITEM_1").effectiveTechLevel = 0; // item available
EquipmentInfo.infoForKey("EQ_MY_ITEM_2").effectiveTechLevel = null; // reset TL to 99, not available
EquipmentInfo.infoForKey("EQ_MY_ITEM_3").effectiveTechLevel = null;
EquipmentInfo.infoForKey("EQ_MY_ITEM_4").effectiveTechLevel = null;
EquipmentInfo.infoForKey("EQ_MY_ITEM_5").effectiveTechLevel = null;
break;
case 2:
EquipmentInfo.infoForKey("EQ_MY_ITEM_1").effectiveTechLevel = null;
EquipmentInfo.infoForKey("EQ_MY_ITEM_2").effectiveTechLevel = 0;
EquipmentInfo.infoForKey("EQ_MY_ITEM_3").effectiveTechLevel = null;
EquipmentInfo.infoForKey("EQ_MY_ITEM_4").effectiveTechLevel = null;
EquipmentInfo.infoForKey("EQ_MY_ITEM_5").effectiveTechLevel = null;
break;
case 3:
EquipmentInfo.infoForKey("EQ_MY_ITEM_1").effectiveTechLevel = null;
EquipmentInfo.infoForKey("EQ_MY_ITEM_2").effectiveTechLevel = null;
EquipmentInfo.infoForKey("EQ_MY_ITEM_3").effectiveTechLevel = 0;
EquipmentInfo.infoForKey("EQ_MY_ITEM_4").effectiveTechLevel = null;
EquipmentInfo.infoForKey("EQ_MY_ITEM_5").effectiveTechLevel = null;
break;
case 4:
EquipmentInfo.infoForKey("EQ_MY_ITEM_1").effectiveTechLevel = null;
EquipmentInfo.infoForKey("EQ_MY_ITEM_2").effectiveTechLevel = null;
EquipmentInfo.infoForKey("EQ_MY_ITEM_3").effectiveTechLevel = null;
EquipmentInfo.infoForKey("EQ_MY_ITEM_4").effectiveTechLevel = 0;
EquipmentInfo.infoForKey("EQ_MY_ITEM_5").effectiveTechLevel = null;
break;
case 5:
EquipmentInfo.infoForKey("EQ_MY_ITEM_1").effectiveTechLevel = null;
EquipmentInfo.infoForKey("EQ_MY_ITEM_2").effectiveTechLevel = null;
EquipmentInfo.infoForKey("EQ_MY_ITEM_3").effectiveTechLevel = null;
EquipmentInfo.infoForKey("EQ_MY_ITEM_4").effectiveTechLevel = null;
EquipmentInfo.infoForKey("EQ_MY_ITEM_5").effectiveTechLevel = 0;
}
}
}
A shorter way, making use of JS's ability to transform your random choice number into a string, and manipulate strings directly, would be:
Code: Select all
this.guiScreenWillChange = function(to, from)
{
if(!player.ship.docked) return; // a safety measure, because you could've been launched in the meantime
if(to === "GUI_SCREEN_EQUIP_SHIP")
{
var choice = Math.ceil(Math.random() * 5) // replace with the number of items
EquipmentInfo.infoForKey("EQ_MY_ITEM_1").effectiveTechLevel = null; // reset
EquipmentInfo.infoForKey("EQ_MY_ITEM_2").effectiveTechLevel = null; // all
EquipmentInfo.infoForKey("EQ_MY_ITEM_3").effectiveTechLevel = null; // items
EquipmentInfo.infoForKey("EQ_MY_ITEM_4").effectiveTechLevel = null; // to
EquipmentInfo.infoForKey("EQ_MY_ITEM_5").effectiveTechLevel = null; // TL 99
EquipmentInfo.infoForKey("EQ_MY_ITEM_" + choice.toString()).effectiveTechLevel = 0; // set only one to 0
}
}
"EQ_MY_ITEM_" + choice.toString()
obviously resolves to EQ_MY_ITEM_1, EQ_MY_ITEM_2, EQ_MY_ITEM_3, EQ_MY_ITEM_4, or EQ_MY_ITEM_5.
Re: Scripters cove
Posted: Tue Nov 20, 2012 6:18 pm
by Thargoid
Another way is to set a condition in each piece of equipment requiring a mission variable to be a certain value or range of values if you wish some overlap (a different value for each item variant), and then use a script to pseudo-randomly set that variable to one of the values in the range of your equipment on start-up and witchspace exit.
That works in the current release version, and as Cim says will only get easier when 1.77 comes out.
Re: Scripters cove
Posted: Tue Nov 20, 2012 6:55 pm
by superbatprime
Gentlemen thank you, that is doing what it should be doing now and more importantly I understand how it's doing it.
Re: Scripters cove
Posted: Tue Nov 20, 2012 7:26 pm
by Thargoid
If you want an example, look into the mission equipment in Aquatics.
Re: Scripters cove
Posted: Thu Nov 29, 2012 9:40 am
by Rese249er
Is it possible to display all for weapon temperatures at once? I've a HUD design in mind incorporating all four in a cross-display with the number for the view displayed next to the temperature, as well as a few more concepts to integrate that I may need help with in the future.
Re: Scripters cove
Posted: Fri Nov 30, 2012 1:50 am
by Commander McLane
Rese249er wrote:Is it possible to display all for weapon temperatures at once?
I don't think so.
Re: Scripters cove
Posted: Fri Nov 30, 2012 3:32 am
by Rese249er
*snaps fingers* Back to the drawing board.
Re: Scripters cove
Posted: Mon Dec 03, 2012 3:27 pm
by Wildeblood
An arithmetic question. I need a procedure that will take a number between 0 and 36000 (actually 4000 to 40000, but I think I can manage adding and subtracting 4000) and output a number between 0 and 3996000 (4000000-4000), such that there's no distortion at the bottom of the range, but a 100x exaggeration at the top of the range. So 4000 -> 4000, but 40000 -> 4000000, or 0 -> 0, but 36000 -> 3996000. I think this is called a geometric progression, but being the victim of a state school education, my mathematical ability is limited to basic addition and subtraction.
Re: Scripters cove
Posted: Mon Dec 03, 2012 4:26 pm
by spara
Wildeblood wrote:An arithmetic question. I need a procedure that will take a number between 0 and 36000 (actually 4000 to 40000, but I think I can manage adding and subtracting 4000) and output a number between 0 and 3996000 (4000000-4000), such that there's no distortion at the bottom of the range, but a 100x exaggeration at the top of the range. So 4000 -> 4000, but 40000 -> 4000000, or 0 -> 0, but 36000 -> 3996000. I think this is called a geometric progression, but being the victim of a state school education, my mathematical ability is limited to basic addition and subtraction.
Is this what you are looking for: f(x)=x*100^((x-4000)/36000), where 4000 <= x <= 40000 ?
Re: Scripters cove
Posted: Mon Dec 03, 2012 4:39 pm
by Wildeblood
spara wrote:Is this what you are looking for: f(x)=x*100^((x-4000)/36000), where 4000 <= x <= 40000 ?
I think it is. Thank you.
Re: Scripters cove
Posted: Tue Dec 04, 2012 8:28 am
by Rese249er
Through experimenting with a hud.plist for the next version of HoloNumHUD, I discovered that only one scanner will be drawn at a time. Is it feasible to remove this restriction? I've an idea that a separate scanner of zero height could be drawn over the crosshairs to aid aiming by 'instruments' in addition to the typical scanner (or a square-boundary scanner.)