Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I detect if the player doesnt have enough Materials to lock?

Asked by 8 years ago

Okay, so, before I provide you the code let me provide an explanation. I want you to close your eyes and imagine a scenario. Say the player need's, I don't know, Two screws and a screwdriver to lock a board in place. The player already has a Screwdriver and a screw, but can't lock in place. Now, say the script for this to work is called A, the script for collecting things is called A. So, he has this stuff, takes the board, places it, and uses the Lock tool. You know. that thing that locks things in place so nobody can touch it. Alright, he think's he locked it, but did he really? He didn't have the screw needed for the function to work. Now, I was wondering how would I place this script into the collide tool, so he would not be able to lock it in place, you know, to prevent a bug. So, what exactly should I put in the lock tool?

Here is what I assumed I needed to do:

The code "~=" I believe is the code needed to detect if something is not there, So I assume the code would work like this if a made of script representing what was needed actually for the lock to work was called B.

If (A ~= B) then

So, what I assume this script means if Script A is not what Script B needs then.. Etc etc. But I'm not entirely sure what to put in then or what else to put after that, so here's what else I tried.

What I want to happen next is for nothing to happen, nothing at all. Which leads me to wonder if there is a way for nothing to happen at all. So, what I assumed I could do is make B false, but the problem is I know that B is false already by the script. So I'm a bit confused what other code I can do because I'm just starting on a project. So, I'm putting in the code I assume will work with my knowledge. Now, I don't know if this will work but, heres what I think would be a good idea.

I think adding Not is a good idea but I'm not sure. Because I know Not would mean something would not happen, as the word represents. So, I assume if I used Not to represent the Lock tool script not working, then it will help. So, I suppose I'll call the Lock tool script C, just to help.

That's all I have, I'm sorry if that's not enough so I might have to edit if Needed. You might jog my memory! Please answer!

1 answer

Log in to vote
2
Answered by 8 years ago

Say

a = 10 and b = 8 we would use inequality symbols

if a > b then 
    print("A is greated then B") 
end

= greater than < = less than = = greater than or equal to <= = less than or equal to == equal

0
Thanks! legoson7 70 — 8y
Ad

Answer this question