Help with compile error

Started by skullywag, September 07, 2014, 06:14:45 PM

Previous topic - Next topic

skullywag

Hi all,

getting back into some c# in a loooooong time and I cant fathom what im doing wrong here, im getting lots of messages on build like:

Error   1   'RimWorld.CompPowerTrader.PowerOn.get': cannot explicitly call operator or accessor   \Building_Generator.cs   16   35   RimWorld_MyMod

code in question is just:

public bool GotLogs
    {
        get
        {
            return this.powerComp.get_PowerOn() && this.HasLogsInHopper;
        }
    }


Ive got lots of others like this and they all seem to be in "verse", am i doing something dumb...I feel like i am.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

RawCode

perform some kind of debugging first.
coding is not about "write something and pray" you must carefully plan your actions in advance.

start from resolving types of references at play, what type of this.HasLogsInHopper ?

runtime type is class, struct, enum or property or method, they all have different use.

then resolve "return" of references at play, your HasLogsInHopper may return integer or object for some reason.

Unlike java, c# have different kind of types and different kind of references, you must take this in account when coding.

Haplo

You have copied the code right out of ILspy without any changes, right?
The problem is the get_ part. This is only from the compiler. Normally you don't write powerComp.get_PowerOn() just call powerComp.PowerOn

skullywag

yeah i realised that was the case, was using the wood tweaks mulcher code as a base to learn how to use resources from a hopper, what i totally forgot was removing the parenthesis so as to not call it as a method...derp! All good now, just got my first DLL mod out a simple stungun, has my own injury and damage defs and hit handing...now onto crazier stuff :)
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?