Jump to content

RequestResource not working for some resources


Recommended Posts

I have the following statement:

usedInputResource[i] = converter.part.RequestResource(converter.inputList[i].rr.ResourceName, inputResource[i], ResourceFlowMode.STAGE_PRIORITY_FLOW, true);

There are two resources which this isn't working for,  one of which is Ore 

I added a test statement (2 tests), each of which looked like this:

var r = converter.part.RequestResource("Ore", 10, ResourceFlowMode.STAGE_PRIORITY_FLOW, true);


var r = converter.part.RequestResource("Ore", 10, true);

and in both cases, 0 was returned to r.

The vessel has an ore tank which is full (1500).

As part of the test, I added an ISRU and an empty tank, and that was able to work properly.

Additional information:

Community Tech Tree is installed.

The other resource which isn't working is LiquidOxygen, defined in the mod, def follows:

RESOURCE_DEFINITION
{
	name = LiquidOxygen
	displayName = Liquid Oxygen
	abbreviation = LqdOxy
	density = 0.001141
	unitCost = 0.04564
	hsp = 918 // specific heat capacity (kJ/tonne-K as units) // recalc, mols are for O2 on wiki
	vsp = 213000 // heat of vapourization (KJ/tonne as units)
	flowMode = ALL_VESSEL
	transfer = DIRECT
	isTweakable = true
	isVisible = true
}

The following are the definitions of the resource which is working:

RESOURCE_DEFINITION
{
	name = Sludge
	displayName = Sludge
	density = 0.0045
	unitCost = 40
	flowMode = ALL_VESSEL
	transfer = DIRECT
	volume = 1
	isTweakable = true
}

The last resource which is working is ElectricCharge

The part itself doesn't have any holding capacity for any of the resources.

 

Any idea what  might be wrong here?

 

Thanks in advance

Edited by linuxgurugamer
Link to comment
Share on other sites

Do you really need to do a simulation (ie, the last bool arg set to true) instead of just consuming the resource ?

Can't say for sure but the whole "simulation" thing is likely to be quite buggy.
It's unused by the stock codebase, aside from the stock delta-v calcs which has also has a bunch of issues with resources having uncommon flow modes.

if you need to do conversion/recipe stuff, I would suggest using the stock converter module stuff as a base.

Edit : actually, to be more useful, since what you're trying to do is get the amount of a resource available, I would suggest using the "Part. GetConnectedResourceTotals()" methods, or easier, to use the public methods of a "ResourceBroker" instance (you can use a single static instance). That's what BaseConverter and derivatives are using. Not the simulation thing.

Edited by Gotmachine
Link to comment
Share on other sites

1 hour ago, Gotmachine said:

Do you really need to do a simulation (ie, the last bool arg set to true) instead of just consuming the resource ?

Can't say for sure but the whole "simulation" thing is likely to be quite buggy.
It's unused by the stock codebase, aside from the stock delta-v calcs which has also has a bunch of issues with resources having uncommon flow modes.

if you need to do conversion/recipe stuff, I would suggest using the stock converter module stuff as a base.

Edit : actually, to be more useful, since what you're trying to do is get the amount of a resource available, I would suggest using the "Part. GetConnectedResourceTotals()" methods, or easier, to use the public methods of a "ResourceBroker" instance (you can use a single static instance). That's what BaseConverter and derivatives are using. Not the simulation thing.

Yes, a sim is needed, but the GetConnectedResourceTotals will also do what I need, thanks for that

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...