Jump to content

How to get science experiments use resources ? And restrict their execution to duna?


Recommended Posts

Hi fellow KSP players and enhanchers :-)

I recently got into modding, to replace some textures. Things grew and i now work on my own science experiment.

However i now have some questions:

1. How do i make the experiment use resources by execution (press of the button) like elctrical charge, or others, and how to detect if enough of this resource is there, if not dont execute the exeriment. For now nothing has worked i tried. (like putting RESOURCES into the Sciene Module)

2. How can i restrict a experiment that it only is carried out for eg. on Dunas surface in all Duna Biomes ? Like how to know that the landed surface is duna?

3. Is it possible to detect in what part the sciene part is attached ? Like, the part is attached a a Propulsion part or Structural Part?

Thanks for your help!

ManuxKerb

Edited by ManuxKerb
need help!
Link to comment
Share on other sites

You can do all of these things, but it will require a new part module.

You can find the bit about using resources here: https://github.com/DMagic1/Orbital-Science/blob/master/Source/Part%20Modules/DMModuleScienceAnimate.cs#L214-L224, it's just a matter of activating that when your experiment gets turned on.

The others are also pretty simple, but require dedicated code. There are a few solar observation experiments that only allow for data collection while in orbit around the sun, those should give you an idea of how to handle being restricted to a certain planet/situation.

Link to comment
Share on other sites

You can do all of these things, but it will require a new part module.

You can find the bit about using resources here: https://github.com/DMagic1/Orbital-Science/blob/master/Source/Part%20Modules/DMModuleScienceAnimate.cs#L214-L224, it's just a matter of activating that when your experiment gets turned on.

The others are also pretty simple, but require dedicated code. There are a few solar observation experiments that only allow for data collection while in orbit around the sun, those should give you an idea of how to handle being restricted to a certain planet/situation.

Hello dmagic,

Thanks for answering. I already have a science part. What do you mean with part module? Do you mean like a sub in the module?

I will try to use your animate module when I get back home.

Does it work with Karbonite as a Ressource? I want to make a science part that uses karbonite as a resource.

Do I need to code in c# for the restriction to one planet? I never did that before Or can it be achieved only in the science part?

I assume that I would need to code in c# for the structural part detection right?

Also i saw in your DMModuleScienceAnimateGeneric there is a planetaryMask = 524287. Could you provide a bit more insight how the bitmask represents every planet ?

I have no animation for my part. So i tried it without it, but i get an exception:

[LOG 21:45:48.488] ScienceAlert, Experiment ProbeAlive22@KerbinSrfLanded just became available! Total potential science onboard currently: 0 (Cap is 151.2, threshold is Unresearched, current sci is 0, expected next report value: 0.63)

[EXC 21:46:57.625] MissingFieldException: Field '.CelestialBody.BiomeMap' not found.

DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric.makeScience ()

DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric.runExperiment ()

DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric+<WaitForAnimation>d__3.MoveNext ()

[ERR 21:48:15.526] ScienceAlert, Failed to invoke "DeployExperiment" using GetType(), falling back to base type after encountering exception System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object

at DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric.canConduct () [0x00000] in <filename unknown>:0

at DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric.DeployExperiment () [0x00000] in <filename unknown>:0

at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)

at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0

--- End of inner exception stack trace ---

at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0

at System.MonoType.InvokeMember (System.String name, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object target, System.Object[] args, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParameters) [0x00000] in <filename unknown>:0

at System.Type.InvokeMember (System.String name, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object target, System.Object[] args) [0x00000] in <filename unknown>:0

at ScienceAlert.Experiments.Observers.ExperimentObserver.Deploy () [0x00000] in <filename unknown>:0

[LOG 21:48:15.526] [Experiments]: Setting FX Modules to 1...

[LOG 21:48:15.526] [Experiments]: FX Modules set: 1

[EXC 21:48:27.252] NullReferenceException: Object reference not set to an instance of an object

DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric.canConduct ()

DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric.DeployExperiment ()

BaseEvent.Invoke ()

UIPartActionButton.OnClick ()

[EXC 21:48:31.133] NullReferenceException: Object reference not set to an instance of an object

DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric.canConduct ()

DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric.DeployExperiment ()

BaseEvent.Invoke ()

UIPartActionButton.OnClick ()

[EXC 21:48:38.474] MissingFieldException: Field '.CelestialBody.BiomeMap' not found.

DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric.makeScience ()

DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric.runExperiment ()

DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric+<WaitForAnimation>d__3.MoveNext ()

I tried to copy from Real Simple Science, then there is no error, but then the "science collect" box does not appear :-( So something seems to be wrong there as well and makes it useless...

Thanks again

Edited by ManuxKerb
Link to comment
Share on other sites

Hello

I wanted to post an update.

I found a solution to the restriction to one planet thing, but my c# skills are non existent so i will test this before i post the solution here.

I fixed the Nullpointer Exeption by adding the binomes and sit. things into the module but it did not work. See below

As for the resource use of the experiment, i was not able to implement that. As it seems that your plugin needs a animation to work correctly. As i don't have one, (i think an empty one who does nothing would be sufficent tho ??) and i don't plan to create one it would be good to get some more help here. It is just a simple part like the thermometer.

As stated above i tried to use the example from Real Simple Sciene and it worked in that way that it is indeed using el. Charge, but as the original after using the charge it does not display the science Information window. So you can't collect the science and it is kind of useless...

Thanks

ManuxKerb

Edited by ManuxKerb
Link to comment
Share on other sites

Hello guys,

As it turns out, i propably used an old DMModuleScienceAnimateGeneric.dll (from dec 2014) and the source in github might have fixed the problem with the animation. However i stuck at compiling it. As i dont use Vidual Studio (Linux :-)) the project file is of no help...

As i dont even know the compile order i tried this one:

kspComp Properties/AssemblyInfo.cs (worked)

kspComp /r: Properties/AssemblyInfo.dll DMAsteroidScienceGen.cs (worked)

kspComp /r: Properties/AssemblyInfo.dll /r:MAsteroidScienceGen.dll DMPlanetaryIndicesGen.cs

DMPlanetaryIndicesGen.cs(112,34): error CS0103: The name `DMAsteroidScienceGen' does not exist in the current context

Compilation failed: 1 error(s), 0 warnings

So i dont know how to fix this. Any ideas from the coders around here ?

Many thanks!

ManuxKerb

Edited by ManuxKerb
Link to comment
Share on other sites

There's no need to recompile the code as it is, there is already an [thread=72466]updated version available[/thread].

If you want to make changes to that and your still having problems compiling it then I'll need to see your code.

Also, check this post for some instructions on resource usage with and without animations.

Edited by DMagic
Link to comment
Share on other sites

Hello Dmagic.

Thanks for helping :-)

Ok i will try the updated version. As decribed, i did not code any c# code for the science part who uses only energy. I did only build a part.cfg file for my part and it worked that it would drain resources but did not show the science collect window afterward. I guess it is waiting for the animation.

If it does not work, i will post my part file here. :-)

Greetings

Link to comment
Share on other sites

Hello Dmagic.

I tried it with the new dll. Same result. Energy is drained but there is no science window popping up to collect the science.

Here is my code:

PART

{

name = sensorBeep

module = Part

author = MKerb

mesh = model.mu

texture = sensorBeep256.png

scale = 1

rescaleFactor = 1.0

node_stack_bottom = 0.0, -0.6, 0.0, 0.0, 1.0, 0.0, 0

node_stack_top = 0.0, 0.6, 0.0, 0.0, 1.0, 0.0, 0

TechRequired = advScienceTech

entryCost = 14000

cost = 4500

category = Science

subcategory = 0

title = A.B.S. device

manufacturer = DMagic Orbital Science

description = This orbital sensor deploys a large L-band microwave detector comprised of 82 individual antenna elements. It can be used to study the water content of the upper soil layers and the salinity levels of large water features. Can only be used in low orbit.

attachRules = 1,0,1,1,0

// --- standard part parameters ---

mass = 0.05

dragModelType = default

maximum_drag = 0.2

minimum_drag = 0.2

angularDrag = 2

crashTolerance = 7

maxTemp = 3000

MODULE

{

name = DMModuleScienceAnimateGeneric

customFailMessage = Can't be testet right now, some temp. glitch.

animSpeed = 1

experimentAnimation = false

experimentWaitForAnimation = false

waitForAnimationTime = 1

keepDeployedMode = 2

startEventGUIName = Deploy Array

showStartEvent = false

endEventGUIName = Retract Array

showEndEvent = false

showEditorEvents = true

showToggleEvent = false

toggleEventGUIName = Toggle Array

experimentID = ProbeAlive22

sitMask = 63

bioMask = 63

experimentLimit = 1

xmitDataScalar = 1

experimentActionName = Test ALIVE device

deployingMessage = Beep Beep TT ...

resourceExperiment = ElectricCharge

resourceExpCost = 10

useStaging = False

useActionGroups = True

hideUIwhenUnavailable = True

rerunnable = True

dataIsCollectable = True

collectActionName = Collect Data

interactionRange = 1.2

externalDeploy = True

asteroidReports = True

asteroidTypeDependent = True

xmitDataScalar = 0.94

}

}

the model.mu is just the model from the stock gravimax.

SensorBeep256.png is just another texture.

The DMagic Science Animate.dll is in the DMagic Science Animate/ folder of the gamedata.

Also i noted, that the last modified date of the new dll is still June 2014.

thanks for looking into this :-)

Have a nice easter

Link to comment
Share on other sites

Don't copy the config from a DMOS part, the modules are different and have different fields. Use the template provided in the DM Module Science Animate thread.

If the dll says that it hasn't been modified since 2014 then you still have the old version. Completely delete it and download the latest version from the GitHub release.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...