#How to prohibit the use of the

1 messages · Page 1 of 1 (latest)

thick rover
#

When you say "prohibit the use" - isn't this just about making the method private? maybe I'm misunderstanding something

#

private means that the method will only be invocable from within the class that it's implemented

stark wren
#

hey

#

when I hold the object in my hand and look at the rack and press the button, the method works.

#

I want to prohibit this action

#

@thick rover

thick rover
#

okay, so it doesn't sound like a matter of syntax - it sounds like you want the action to be prohibited from a game logic standpoint?

#

As in, you want the player to be prohibitted from performing that action within the game?

stark wren
#

yes, if the player has an object in his hand

thick rover
#

what's the difference between isCarrying and hasCarriedItem?

#

is it possible that you have two variables for the same thing, and you've set one of them to true, but you're expecting the other one to be true?

stark wren
#

maybe I'm just confused myself.

thick rover
#

because, otherwise, I think that's all there is to it - if the user being able to carry something is conditional, set that condition in a variable and check if that condition is met when the user is trying to check something

#

(and you can check that within the function, or check it before you let the function be called - I don't know that one of those implementations is better than the other

stark wren
thick rover
#

if you find yourself in a situation like this, it's good to check if the condition you're expecting to be true is actually true, with a Debug.Log statement

stark wren
#

i delete hasCarriedItem

#

it didn't work in any way.

thick rover
#

because now you don't have a condition preventing the user from performing the action!

stark wren
#

I didn't have it before, but now I need to write a condition that prohibits it.

thick rover
#

you previously had something like:

if (hasCarriedItem){
...
}
stark wren
#

I checked it out, it wasn't even working.

thick rover
stark wren
#

about what?

thick rover
#

I linked it

stark wren
#

If it's a pipe, it works fine, but you have to turn it off when you're holding the object.

#

I did what I wanted to do, thanks for trying to help me.