Darkcyde,
So far I am enjoying your personality you have created. I have one question though... The fueling script, is it broken in the script? Or is this another example of the API being screwed up since 2.3? Mine attempts to tell me about my fueling but has no values to go off of.
{_ MissionStoreCheckGalaxy}
{_ Check what systems you have missions in}
{if state.eddi_context_missions_initialised != "yes":
{F("MissionStoreInitialise")}
}
{_ For VoiceAttack, convert TXT token into number value, as EDDI plugin can't export DEC to State variables}
{set missionstotal to cast(state.eddi_context_missions_accepted, "n")}
{if missionstotal > 0 && missionstotal != null:
{set mission_system_array to split(state.eddi_context_mission_destinationsystem, "+=")}
You have {missionstotal} mission{if missionstotal > 1:s} to complete.
{if missionstotal = 1:
It is {Occasionally(2,"located")} in
{if mission_system_array[0] = "":
an unknown
|else:
the {mission_system_array[0]}
}
{Occasionally(2,"star")} system.
|else:
{set systems to []}
{set systems_count to []}
{for system in mission_system_array:
{if system != "":
{if find(systems, system) > -1:
{set here to find(systems, system)}
{set number to systems_count[here] + 1}
{set systems_count to cat(slice(systems_count,0,here), [number], slice(systems_count,here+1))}
|else:
{set systems to cat(systems, [system])}
{set systems_count to cat(systems_count, [1])}
}
}
}
{if len(systems) = 1:
They are all {Occasionally(2,"located")} in
{if systems[0] = "":
an unknown
|else:
the {systems[0]}
}
{Occasionally(2,"star")} system.
|else:
There
{if systems[0] = 1: is
|else: are
}
{set cur to 0}
{while cur < len(systems):
{systems_count[cur]}
{if systems[cur] = "":
in an unknown system
|else:
{OneOf("at","in")} {systems[cur]}
}
{Pause(500)}
{set cur to cur + 1}
{if cur = len(systems)-1: and
|elif cur < len(systems):,
}
}
}.
}
|else:
You {Occasionally(2,"currently")} have no missions at {OneOf("the moment","this time")}.
}
Darkcyde, I took a look at your personality and really liked the mission system you created. My own profile is very customized as well. Our styles are similar, but I'm a information junkie, I have EDDI telling me everything that is available.
I'd like to keep my profile, but integrate your mission stuff into mine. Looking through your profile I see lots of calls and such. What is needed from your profile to add to my profile to get the mission info working?
Thank you for the awesome work. I like to tinker, but I don't have the mind of a programmer and I always get lost in the code. Coddle/C is like speaking a foreign language to me LOL. In my opinion, voice attack programming is much easier.
{if event.stellarclass = "O":
{set aLow to 16880}
{set bLow to 3.56}
{set cLow to -0.0000562}
{set aHigh to 26940}
{set bHigh to 5.68}
{set cHigh to -0.0000897}
Habittable from {Humanise(aLow+(bLow*event.luminosity)+(cLow*event.luminosity*event.luminosity))} to {Humanise(aHigh+(bHigh*event.luminosity)+(cHigh*event.luminosity*event.luminosity))} lightseconds.
|elif event.stellarclass = "B":
{set aLow to 3760}
{set bLow to 12.98}
{set cLow to -0.0019}
{set aHigh to 6000}
{set bHigh to 20.7}
{set cHigh to -0.00303}
Habittable from {Humanise(aLow+(bLow*event.luminosity)+(cLow*event.luminosity*event.luminosity))} to {Humanise(aHigh+(bHigh*event.luminosity)+(cHigh*event.luminosity*event.luminosity))} lightseconds.
|elif event.stellarclass = "A":
{set aLow to 768}
{set bLow to 76.8}
{set cLow to -0.539}
{set aHigh to 1226}
{set bHigh to 122.5}
{set cHigh to -0.86}
Habittable from {Humanise(aLow+(bLow*event.luminosity)+(cLow*event.luminosity*event.luminosity))} to {Humanise(aHigh+(bHigh*event.luminosity)+(cHigh*event.luminosity*event.luminosity))} lightseconds.
|elif event.stellarclass = "F":
{set aLow to 323.5}
{set bLow to 186.1}
{set cLow to -8.02}
{set aHigh to 516}
{set bHigh to 296.9}
{set cHigh to -12.79}
Habittable from {Humanise(aLow+(bLow*event.luminosity)+(cLow*event.luminosity*event.luminosity))} to {Humanise(aHigh+(bHigh*event.luminosity)+(cHigh*event.luminosity*event.luminosity))} lightseconds.
|elif event.stellarclass = "G":
{set aLow to 165.2}
{set bLow to 369.3}
{set cLow to -65.2}
{set aHigh to 263.6}
{set bHigh to 589.5}
{set cHigh to -104.2}
Habittable from {Humanise(aLow+(bLow*event.luminosity)+(cLow*event.luminosity*event.luminosity))} to {Humanise(aHigh+(bHigh*event.luminosity)+(cHigh*event.luminosity*event.luminosity))} lightseconds.
|elif event.stellarclass = "K":
{set aLow to 71.9}
{set bLow to 830}
{set cLow to -701}
{set aHigh to 114.8}
{set bHigh to 1324}
{set cHigh to -1119}
Habittable from {Humanise(aLow+(bLow*event.luminosity)+(cLow*event.luminosity*event.luminosity))} to {Humanise(aHigh+(bHigh*event.luminosity)+(cHigh*event.luminosity*event.luminosity))} lightseconds.
|elif event.stellarclass = "M":
{set aLow to 13.7}
{set bLow to 2.88}
{set cLow to -0.0185}
{set aHigh to 21.8}
{set bHigh to 4.59}
{set cHigh to -0.029}
Habittable from {Humanise(aLow+(bLow*event.luminosity)+(cLow*event.luminosity*event.luminosity))} to {Humanise(aHigh+(bHigh*event.luminosity)+(cHigh*event.luminosity*event.luminosity))} lightseconds.
}
I made a script for "Star scanned".
I tells you the habbitable zone around the scanned star. I used the values from https://www.reddit.com/r/eliteexplo...bitable_zone_spreadsheet_find_terraformables/ and calculated the quadratic function for min and max habbitable zone in ls, depending on the type and luminosity of the scanned star.
Set decimal [test_dec] value to 3.14159
Set Text [State variable] to 'test_dec'
Execute external plugin, 'EDDI 2.3.0-b8' --> Plugin Context = "setstate" & Text Variables = "State variable"
Set Text [Script] to 'Test'
Execute external plugin, 'EDDI 2.3.0-b8' --> Plugin Context = "speech" & Text Variables = "Script"
The test variable is {state.test_dec}.
{set dist to -1}
{if state.from_system && state.to_system:
{if state.from_system = "":
Origin system not designated.
|elif state.to_system = "":
Destination system not designated.
|else:
{set fs to SystemDetails(state.from_system)}
{set ts to SystemDetails(state.to_system)}
{if !fs.name:
Your origin is not in the Pilot's Federation star charts.
|elif !ts.name:
Your destination is not in the Pilot's Federation star charts.
|else:
{set dist to round(Distance(fs.x, fs.y, fs.z, ts.x, ts.y, ts.z),1)}
}
}
}
{SetState('distance', dist)}
Please note that only text variables are passed to EDDI external plugin calls, whether it's the name of a Voice Attack variable or the name of a speech responder script (for example).
{set pow_x to pow(dest.x - curr.x, 2)}
{set pow_y to pow(dest.y - curr.y, 2)}
{set pow_z to pow(dest.z - curr.z, 2)}
{set distance to round(pow((pow_x + pow_y + pow_z), 0.5), 2)}
{set distance to round(Distance(curr.x, curr.y, curr.z, dest.x, dest.y, dest.z), 2)}
Hi Hoodathunk,
Yeah, this is exactly what I meant. The numbers get sent to EDDI as a text variable, not a number value. Sorry if I didn't explain myself properly.
I found that EDDI wouldn't use them properly as a number until I converted them back from a string, into a number. So 3.14 instead of "3.14". EDDI handles these differently, and that's where I was having problems until I realised what was happening. I've just put type conversions in my scripts where necessary now and it's all working as expected.
The test variable is {state.test_dec}.
The test variable squared is {state.test_dec * state.test_dec}.
Using my previous example, you can modify it as such and see 'test_dec' is indeed being treated as a decimal value.
Code:The test variable is {state.test_dec}. The test variable squared is {state.test_dec * state.test_dec}.
{set textnum to "2"}
{set decnum to 2}
Multiplied: {textnum * decnum}. This results in 4 because a mathmatical function has been performed and EDDI auto-converts textnum to a number.
{if textnum > 3:
Textnum shouldn't do anything here, but it does because textnum is not a decimal number, it's a string with a null decimal value.
}
What you have to realise it that EDDI uses those variables differently in different conditions. Your calculation is valid only because EDDI auto-converts the text string to a number when using it for a calculation. I used this exact method originally to get the decimal value before I found the cast() method. I simply did {set variable to variable+0}.
You can see what I mean by trying this test code:
Code:{set textnum to "2"} {set decnum to 2} Multiplied: {textnum * decnum}. This results in 4 because a mathmatical function has been performed and EDDI auto-converts textnum to a number. {if textnum > 3: Textnum shouldn't do anything here, but it does because textnum is not a decimal number, it's a string with a null decimal value. }
However, the above test WILL work if you put the number 3 in quotes to also make it a string, "3". This is why I was having a problem to begin with. You can't do a compare on the variable as a decimal number, only as a string or convert it first.
I've even tried it with 'if textnum > 3000000000000' (that's 3 trillion) and it still speaks that line. Also, during my testing, I've found that using 10 or 1000000000 as numbers to check against, or "10" or "100000000000" as a string to check with, they all make EDDI speak that line.
Try using '= 2' (as a number) and that will not speak the line, because textnum does not have a decimal value of 2. Also, try "-2" for textnum (multiplied = -4) and check {if textnum < "-1": again it will not speak the line. While numerically -2 is less than -1, as a string it is greater.
The number being passed to EDDi via the plug-in is always as a character or string and is treated as such within EDDI under most conditions. EDDI will auto-convert it for mathematical functions, but not for comparing. In these cases 3.14 is not the same as the "3.14" that the plugin passes to EDDI. This is most noteable for compares because the character/string has a null decimal value.
As a final double-check of what I have tested, and have said above, I tested the number variable of 'eddi_context_missions_accepted' that had been loaded from my mission system into EDDI using the plugin. I used {type(state.eddi_context_missions_accepted)} which reports the variable type, and exactly as predicted, EDDI returns "string" as the variable type, not "number", even though it was "7".
------------------------------------------------------------------------
EDIT: Please accept my apologies. Having done all the testing above, and running your suggestion to test decimal numbers again (this time with the type check), I think I may have found the reason why our coding is giving different results.
It appears that the problem actually comes from the saving and/or loading of the decimal number to/from the file, rather than the passing to EDDI. I'm going to believe this is down to my total lack of VA knowledge. Maybe you can look it over and see if & where I may have made a mistake?
As far as my limited VA knowledge is, I believe I have tried to save the decimal value to the file 'EDDI_Missions_Accepted.txt' as a number (using my Update Mission Store function in VA), but it looks like it's just the number as an ASCII character (so "7" as ASCII 55) rather than a decimal 7. When I've loaded this back up (using the System Startup function in VA), I load it as a text variable into 'eddi_context_missions_accepted', and then set a DEC version of 'eddi_context_missions_accepted' to be a conversion of the TXT token. This then seems to be sent to EDDI via the plugin as a string, so I'm guessing that it's actually passing the first TXT version and not the second DEC version. Would this be correct? And if so, how do I fix that? Can I delete the TXT version? Or is there a way to load it directly into the DEC version of the variable?
EDIT 2: After a bit of messing around in VA, I seem to have fixed it by setting the TXT version of eddi_context_missions_accepted to 'Not Set', after converting it to DEC. If there is a better way around this, please let me know.
So, Darkcyde... When is your next update that I can get my greedy little fingers on? This proxy-coding you are doing makes my brain hurt...
EDIT: Please accept my apologies. Having done all the testing above, and running your suggestion to test decimal numbers again (this time with the type check), I think I may have found the reason why our coding is giving different results.
It appears that the problem actually comes from the saving and/or loading of the decimal number to/from the file, rather than the passing to EDDI. I'm going to believe this is down to my total lack of VA knowledge. Maybe you can look it over and see if & where I may have made a mistake?
As far as my limited VA knowledge is, I believe I have tried to save the decimal value to the file 'EDDI_Missions_Accepted.txt' as a number (using my Update Mission Store function in VA), but it looks like it's just the number as an ASCII character (so "7" as ASCII 55) rather than a decimal 7. When I've loaded this back up (using the System Startup function in VA), I load it as a text variable into 'eddi_context_missions_accepted', and then set a DEC version of 'eddi_context_missions_accepted' to be a conversion of the TXT token. This then seems to be sent to EDDI via the plugin as a string, so I'm guessing that it's actually passing the first TXT version and not the second DEC version. Would this be correct? And if so, how do I fix that? Can I delete the TXT version? Or is there a way to load it directly into the DEC version of the variable?
EDIT 2: After a bit of messing around in VA, I seem to have fixed it by setting the TXT version of eddi_context_missions_accepted to 'Not Set', after converting it to DEC. If there is a better way around this, please let me know.
No worries, mate. We're all figuring this out together.
Your 'EDIT 2' comment gets to the core of what's going on. Voice Attack allows multiple data types for any given variable name, so you can have a Boolean, integer, decimal, text, etc variables with distinct values and the same name. EDDI's 'setstate' doesn't know how to resolve this since you just pass it a name and apparently it just goes with the TXT data type. You setting the the TXT version of 'eddi_context_missions_accepted' to 'Not Set', allows 'setstate' to pick the DEC version that you actually want. If you're intent on maintaining your variable naming convention, I personally don't think there's any cleaner version than what you're doing, so just roll with it
Been studying your scripts in detail. You're using Cottle to its very limits... very good stuff.
Incidentally, what does the variable 'roundtrip' do? I see you 'adding' and 'deleting' it, but I don't see it defined or being used.
Thanks!
{_ MissionStoreFindRoute}
{_ Plot a NNA route for the defined systems in the mission store}
{if state.eddi_context_missions_initialised != "yes":
{F("MissionStoreInitialise")}
}
{_ For VoiceAttack, convert TXT token into number value, as EDDI plugin can't export DEC to State variables}
{set missionstotal to cast(state.eddi_context_missions_accepted, "n")}
{if missionstotal > 0 && missionstotal != null:
{set mission_system_array to split(state.eddi_context_mission_destinationsystem, "+=")}
You have {missionstotal} mission{if missionstotal > 1:s} to complete.
{_ Get all systems that have a destination}
{set systems to []}
{set system_count to 0}
{for system in mission_system_array:
{if system != "":
{if find(systems, system) = -1:
{set systems to cat(systems, [system])}
{set system_count to system_count + 1}
}
}
}
{set starting_system to state.eddi_context_system_system}
{set curr to SystemDetails(starting_system)}
{set route_systems to []}
{set route_count to 0}
{set total_distance to 0}
{if len(systems) = 0:
No missions with a designated system.
|elif len(systems) = 1:
{set dest to SystemDetails(systems[0])}
{set total_distance to round(Distance(curr.x, curr.y, curr.z, dest.x, dest.y, dest.z),2)}
|else:
{set cur to 0}
{set nearest_distance to 10000}
{_ Repeat until all systems have been visited}
{while route_count < system_count:
{_ Find nearest, skip if system already visited}
{if find(route_systems, systems[cur]) = -1:
{set dest to SystemDetails(systems[cur])}
{set distance to round(Distance(curr.x, curr.y, curr.z, dest.x, dest.y, dest.z),2)}
{if distance < nearest_distance:
{set nearest_distance to distance}
{set nearest_name to dest.name}
}
}
{set cur to cur + 1}
{_ Once nearest found, 'visit it' and then find the next nearest}
{if cur = system_count:
{set route_systems to cat(route_systems, [nearest_name])}
{set curr to SystemDetails(nearest_name)}
{set route_count to route_count + 1}
{set total_distance to total_distance + nearest_distance}
{set nearest_distance to 10000}
{set cur to 0}
}
}
{_ Add 'starting system' to complete route list & total distance traveled, then save it}
{set dest to SystemDetails(starting_system)}
{set distance to round(Distance(curr.x, curr.y, curr.z, dest.x, dest.y, dest.z),2)}
{set total_distance to total_distance + distance}
{set route_systems to cat(route_systems, [starting_system])}
{set mission_route to join(route_systems, "+=")}
{SetState('eddi_context_mission_route', mission_route)}
}
|else:
You {Occasionally(2, "currently")} have no missions at {OneOf("the moment","this time")}.
}