What are the legal ways to set booleans in OpenStep plists?

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

What are the legal ways to set booleans in OpenStep plists?

Post by Commander McLane »

For instance the frangible key. Which are the legal ways to set it to false?

Code: Select all

1)        frangible = no;
2)        frangible = NO;
3)        frangible = false;
4)        frangible = 0;
should all be the same, but apparently they're not. If 1) is used, subentities keep getting shot off. 2) is what PlistEdit Pro creates when converting <false/> from XML, and I always thought it was working. I have seen 3) a lot in plists, and 4) should also be possible.

And the same would appear to

Code: Select all

5)        frangible = yes;
6)        frangible = YES;
7)        frangible = true;
8)        frangible = 1;
On the other hand, 5) is used as the standard in Oolite's built-in shipdata, for instance for auto-ai. So why would 5) work, but 1) would not?

Therefore the general question: What is correct syntax? What is recommended?
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: What are the legal ways to set booleans in OpenStep plis

Post by Eric Walch »

Commander McLane wrote:
Therefore the general question: What is correct syntax? What is recommended?
I don't kow, but this is the code used to read in a boolean from an open-step plist:

Code: Select all

static BOOL BooleanFromString(NSString *string, BOOL defaultValue)
{
	if (NSOrderedSame == [string caseInsensitiveCompare:@"yes"] ||
		NSOrderedSame == [string caseInsensitiveCompare:@"true"] ||
		NSOrderedSame == [string caseInsensitiveCompare:@"on"] ||
		[string doubleValue] != 0.0)	// Floating point is used so values like @"0.1" are treated as nonzero.
	{
		return YES;
	}
	else if (NSOrderedSame == [string caseInsensitiveCompare:@"no"] ||
			 NSOrderedSame == [string caseInsensitiveCompare:@"false"] ||
			 NSOrderedSame == [string caseInsensitiveCompare:@"off"] ||
			 IsZeroString(string))
	{
		return NO;
	}
	return defaultValue;
}
So, from the code, case should not matter. And when using numbers, any value other than zero is true.
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Re: What are the legal ways to set booleans in OpenStep plis

Post by Switeck »

For escape pods, more than 1 is possible...so presumably 1 and up = true even for other things?
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: What are the legal ways to set booleans in OpenStep plis

Post by Eric Walch »

Switeck wrote:
For escape pods, more than 1 is possible...so presumably 1 and up = true even for other things?
Escape pods are a special case. It starts as a fuzzy boolean to see if it can launch an escape pod. On launching that main pod, the key is examined a second time for values >= 2 and now extra pods are created if defined.

My above example was only for the boolean part. "frangible" is defined as boolean. Most keys are defined as fuzzy_boolean. Those fuzzy_boolean start with checking for numbers en change it into a random value based on the number. Only when it is not a number, it defaults to above boolean check.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: What are the legal ways to set booleans in OpenStep plis

Post by Commander McLane »

So there's also on and off as possibilities.

This means that

Code: Select all

        frangible = no;
should work as expected. Yet it doesn't. I had a turret subentity of a player FdL 3G shot off (or exploding for other reasons) right in front of my eyes. I don't see how this could happen.

Here's the relevant shipdata:

Code: Select all

    "3G-turret" =     {
        accuracy = "4.4";
        "ai_type" = "nullAI.plist";
        "energy_recharge_rate" = 1;
        "laser_color" = purpleColor;
        "max_energy" = 25;
        "max_flight_pitch" = 1;
        "max_flight_roll" = 1;
        "max_flight_yaw" = 1;
        model = "3G_turret.dat";
        name = "3G Turret";
        roles = "3G-turret ballturret";
        "setup_actions" =         (
            initialiseTurret
        );
        smooth = true;
        thrust = 1;
        "weapon_energy" = 12;
    };

    "ferdelance3-player" =     {
        "aft_eject_position" = "0.0 3.0 -38.0";
        "cloak_passive" = true;
        "custom_views" =         (
                        <snip>
        );
        "energy_recharge_rate" = "4.9";
        exhaust =         (
            "0.0 -5 -39.0 3.9 3.9 17.0"
        );
        "forward_weapon_type" = "WEAPON_BEAM_LASER";
        frangible = no;
        fuel = 50;
        "hyperspace_motor_spin_time" = 9;
        "laser_color" = redColor;
        materials =         {
            "ferdelance_3G.png" =             {
                "ambient_color" =                 (
                    "1/2",
                    0,
                    "1/2",
                    1
                );
                "emission_map" = "Ferdelance_3G_em-map.png";
                shininess = 20;
                "specular_color" =                 (
                    "0.3",
                    "0.3",
                    "0.3",
                    "0.1"
                );
            };
        };
        "max_cargo" = 22;
        "max_energy" = 320;
        "max_flight_pitch" = "1.40";
        "max_flight_roll" = "3.70";
        "max_flight_speed" = 510;
        "max_flight_yaw" = "1.50";
        "max_missiles" = 5;
        "missile_launch_position" = "0.0 -10.5 16.5";
        model = "ferdelance3G.dat";
        name = "Fer-de-Lance 3G";
        roles = player;
        "scoop_position" = "0.0 -8.0 -14";
        thrust = 59;
        "view_position_aft" = "0.0 5.0 -32.5";
        "view_position_forward" = "0.0 0.0 9.0";
        "view_position_port" = "-16.875 2.0 3.5";
        "view_position_starboard" = "16.875 2.0 3.5";
        "weapon_position_aft" = "0.0 5.0 -32.5";
        "weapon_position_forward" = "0.0 0.0 9.0";
        "weapon_position_port" = "-16.875 2.0 3.5";
        "weapon_position_starboard" = "16.875 2.0 3.5";
    };

    "ferdelance3-playerPlusModel" =     {
        "energy_recharge_rate" = "5.1";
        exhaust =         (
            "0.0 -6.0 -40.0 4.0 3.9 17.0"
        );
        "forward_weapon_type" = "WEAPON_MILITARY_LASER";
        frangible = no;
        "like_ship" = "ferdelance3-player";
        materials =         {
            "ferdelance_3G+.png" =             {
                "ambient_color" =                 (
                    "1/2",
                    0,
                    "1/2",
                    1
                );
                "emission_map" = "Ferdelance_3G+_em-map.png";
                shininess = 1;
                "specular_color" =                 (
                    "0.3",
                    "0.3",
                    "0.3",
                    "0.1"
                );
            };
        };
        "max_cargo" = 36;
        "max_energy" = 512;
        "max_flight_pitch" = "1.35";
        "max_flight_roll" = "3.50";
        "max_flight_speed" = 505;
        "max_flight_yaw" = "1.45";
        "max_missiles" = 6;
        "missile_launch_position" = "0.0 -10.5 16.5";
        model = "ferdelance3G+.dat";
        name = "Fer-de-Lance 3G+";
        roles = player;
        "scoop_position" = "0.0 -8.0 -20";
        thrust = 57;
        "view_position_forward" = "0.0 -10.85 46.0";
        "weapon_position_forward" = "0.0 -10.85 46.0";
    };

    "ferdelance3-playerPlusModelWithTurrets" =     {
        "energy_recharge_rate" = "5.05";
        frangible = no;
        "like_ship" = "ferdelance3-playerPlusModel";
        "max_flight_speed" = 504;
        model = "ferdelance3G+.dat";
        name = "Fer-de-Lance 3G+(t)";
        subentities =         (
            "3G-turret -17 -4.0 10.5 0.906141 0.180249 0.375336 0.0746615",
            "3G-turret 17 -4.0 10.5 -0.906141 -0.180249 0.375336 0.0746615"
        );
        thrust = 56;
    };
About the only possibility that's left is that for some reason turrets get treated differently from normal subentities. For instance I had no problems with the nacelles of my IC. When I set the ship's frangibility to false, they never explode.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6634
Joined: Wed Feb 28, 2007 7:54 am

Re: What are the legal ways to set booleans in OpenStep plis

Post by another_commander »

Just to clarify a bit, the fuzzy boolean is essentially an expression of the probability of a boolean value being true. So, if a fuzzy boolean key in a shipdata.plist has a value of e.g. 0.85, it means that it has 85% chance of being true.

As for the ways to express true and false in openstep, all of them should really work and do the same thing.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: What are the legal ways to set booleans in OpenStep plis

Post by Eric Walch »

Commander McLane wrote:
should work as expected. Yet it doesn't. I had a turret subentity of a player FdL 3G shot off (or exploding for other reasons) right in front of my eyes. I don't see how this could happen.
Shipdata should be correct, but you know that already. Something else is probably wrong. No idea what, but you can target the ship and make an entity dump of the ship when you see it again. The frangibility is listed in such a dump. At least you know than if the code sees it as true or false.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: What are the legal ways to set booleans in OpenStep plis

Post by Commander McLane »

Eric Walch wrote:
Commander McLane wrote:
should work as expected. Yet it doesn't. I had a turret subentity of a player FdL 3G shot off (or exploding for other reasons) right in front of my eyes. I don't see how this could happen.
Shipdata should be correct, but you know that already. Something else is probably wrong. No idea what, but you can target the ship and make an entity dump of the ship when you see it again. The frangibility is listed in such a dump. At least you know than if the code sees it as true or false.
It's a player ship. Made the player state dump:

Code: Select all

15:56:23.884 [dumpState]: State for <PlayerEntity 0x1030f6a00>{"Fer-de-Lance 3G+(t)" position: (20235.2, 98291.8, 584972) scanClass: CLASS_PLAYER status: STATUS_IN_FLIGHT}:
  15:56:23.884 [dumpState.entity]: Universal ID: 100
  15:56:23.884 [dumpState.entity]: Scan class: CLASS_PLAYER
  15:56:23.884 [dumpState.entity]: Status: STATUS_IN_FLIGHT
  15:56:23.884 [dumpState.entity]: Position: (20235.2, 98291.8, 584972)
  15:56:23.884 [dumpState.entity]: Orientation: (-0.0328232 + 0.614916i + 0.435483j + 0.656625k)
  15:56:23.884 [dumpState.entity]: Distance travelled: 3058.06
  15:56:23.884 [dumpState.entity]: Energy: 512 of 512
  15:56:23.884 [dumpState.entity]: Mass: 69072.2
  15:56:23.884 [dumpState.entity]: Owner: none
  15:56:23.884 [dumpState.entity]: Flags: isShip, isPlayer, isSunlit
  15:56:23.884 [dumpState.shipEntity]: Type: ferdelance3-playerPlusModelWithTurrets
  15:56:23.884 [dumpState.shipEntity]: Name: Fer-de-Lance 3G+(t)
  15:56:23.884 [dumpState.shipEntity]: Display Name: Fer-de-Lance 3G+(t)
  15:56:23.884 [dumpState.shipEntity]: Roles: <OORoleSet 0x100eb8950>{player}
  15:56:23.884 [dumpState.shipEntity]: Primary role: player
  15:56:23.885 [dumpState.shipEntity]: Script: <OOJSScript 0x117820000>{"oolite-default-player-script" version 1.75.2}
  15:56:23.885 [dumpState.shipEntity]: Subentity count: 3
  15:56:23.885 [dumpState.shipEntity]: Behaviour: BEHAVIOUR_IDLE
  15:56:23.885 [dumpState.shipEntity]: Destination: (0, 0, 0)
  15:56:23.885 [dumpState.shipEntity]: Other destination: (0, 0, 0)
  15:56:23.885 [dumpState.shipEntity]: Waypoint count: 0
  15:56:23.885 [dumpState.shipEntity]: Desired speed: 252
  15:56:23.885 [dumpState.shipEntity]: Thrust: 56
  15:56:23.885 [dumpState.shipEntity]: Fuel: 70
  15:56:23.885 [dumpState.shipEntity]: Fuel accumulator: 0
  15:56:23.885 [dumpState.shipEntity]: Missile count: 6
  15:56:23.885 [dumpState.shipEntity.ai]: AI:
    15:56:23.885 [dumpState.ai]: State machine name: oolite-player-AI.plist
    15:56:23.885 [dumpState.ai]: Current state: GLOBAL
    15:56:23.885 [dumpState.ai]: Next think time: 52.3978
    15:56:23.885 [dumpState.ai]: Next think interval: 0.125
  15:56:23.885 [dumpState.shipEntity]: Jink position: (0, 0, 0)
  15:56:23.885 [dumpState.shipEntity]: Frustration: 0
  15:56:23.885 [dumpState.shipEntity]: Success factor: 0
  15:56:23.885 [dumpState.shipEntity]: Shots fired: 0
  15:56:23.886 [dumpState.shipEntity]: Time since shot: 112.49
  15:56:23.886 [dumpState.shipEntity]: Spawn time: 0 (51.1578 seconds ago)
  15:56:23.886 [dumpState.shipEntity]: Hull temperature: 60
  15:56:23.886 [dumpState.shipEntity]: Heat insulation: 2
  15:56:23.886 [dumpState.shipEntity]: Flags: canFragment
  15:56:23.886 [dumpState.playerEntity]: Script time: 51.1578
  15:56:23.886 [dumpState.playerEntity]: Script time check: 60
  15:56:23.886 [dumpState.playerEntity]: Script time interval: 10
  15:56:23.886 [dumpState.playerEntity]: Roll/pitch/yaw delta: 7, 2.7, 2.9
  15:56:23.886 [dumpState.playerEntity]: Shield: 384 fore, 384 aft
  15:56:23.886 [dumpState.playerEntity]: Alert level: 32, flags: 0x2
  15:56:23.886 [dumpState.playerEntity]: Missile status: 0
  15:56:23.886 [dumpState.playerEntity]: Energy unit: ENERGY_UNIT_NAVAL
  15:56:23.886 [dumpState.playerEntity]: Fuel leak rate: 0
  15:56:23.886 [dumpState.playerEntity]: Trumble count: 0
  15:56:23.886 [dumpState.playerEntity]: Flags: pollControls, keyboardPitchOverride
No isFrangible flag set. So it shouldn't be frangible. Yet I saw one turret destroyed once (admittedly in a previous game, but with no changes to the code in-between).
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: What are the legal ways to set booleans in OpenStep plis

Post by Eric Walch »

Commander McLane wrote:
No isFrangible flag set. So it shouldn't be frangible. Yet I saw one turret destroyed once (admittedly in a previous game, but with no changes to the code in-between).
At least it means that the boolean is set correctly, or you would have seen:

Code: Select all

15:56:23.886 [dumpState.shipEntity]: Flags: isFrangible, canFragment
When it is still shot off, the error is somewhere else, out of reach of the plist. bug?
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: What are the legal ways to set booleans in OpenStep plis

Post by Commander McLane »

Well, yes, it's obviously a bug. But I am completely at loss as to what kind of bug it is.

My best guess yet is that for some reason (and perhaps only under some circumstances) the code is ignoring the frangible = no setting for turrets.
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Re: What are the legal ways to set booleans in OpenStep plis

Post by Kaks »

you might have some js somewhere removing subentities if the ship's total power is below a certain value. Unlikely, but a possibility nonetheless...
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
Post Reply