|
| 15 May 2017 04:08 PM |
Sorry for the poor subject title. But here is the issue; i have a conversation script that is used for both player-to-npc chat and getting/handing in quests from said npc's. It checks for 2 different variables depending on the quest. For "Talk to someone" quests, it checks if you have the quest. And for "Gather X amount of item" it checks your inventory (Folder) for an item and the quantity.
The problem im having is that i cant get the system to detect if you having the quest is true, but item false, vice versa, and if you have both. Can anyone see what i might be doing wrong with this segment of the code?(Note, it works perfectly fine with one or the other, but it doesnt detect 1-true-1-false or 2-true):
if currentoption:findFirstChild("NEEDITEM") and currentoption:findFirstChild("NEEDQUEST") == nil then local neededitem = player.Backpack.Inventory:findFirstChild(currentoption.NEEDITEM.Value)
if neededitem and neededitem.Value >= currentoption:findFirstChild("NEEDITEM").Count.Value then if currentoption:findFirstChild("NEEDQUEST") and currentoption:findFirstChild("NEEDITEM") == nil then local neededquest = player.Backpack.Quests:findFirstChild(currentoption.NEEDQUEST.Value) if neededquest then setupbutton(newbutton,currentoption,neededquest) buttons = buttons + 1 else
newbutton:Destroy() end end else setupbutton(newbutton,currentoption) buttons = buttons + 1 end end |
|
|
| Report Abuse |
|
|
|
| 15 May 2017 04:08 PM |
| ALSO NOTE, i didnt include or start a part for detecting both, since i cant make it detect one but not the other. If i cant do that, then i wont bother with detecting both. |
|
|
| Report Abuse |
|
|
DevJoas
|
  |
| Joined: 17 Dec 2014 |
| Total Posts: 627 |
|
|
| 15 May 2017 04:11 PM |
you mean or?
wiki.roblox.com/index.php?title=Boolean#Or |
|
|
| Report Abuse |
|
|
|
| 15 May 2017 04:17 PM |
Ehh not really.
Or says if one OR the other is true. But the segment for Items and the segment for Quest are just different enough that i seperated them.
What i need is for it to have if statements for 3 possible outcomes:
1: If the npc requires an item and no quest, then a statement that only checks for the item and makes sure there is no quest attached.
2: If the npc requires a quest but no item, then a statement that checks for the quest and makes sure there is no items attached.
and 3: If the statement needs an item for a quest, that a statement that checks for BOTH a quest and an item.
I'm not the best scripter and im sure that way of doing things isnt the most efficient, but im learning :) And thats more or less what i need, but if you can suggest a better method, im all ears for trying! |
|
|
| Report Abuse |
|
|
DevJoas
|
  |
| Joined: 17 Dec 2014 |
| Total Posts: 627 |
|
|
| 15 May 2017 04:29 PM |
| I'm sorry bit tired and not sure what you mean Going off to ### now, if tomorrow someone else hasn't helped you yet i'll take a look at your problem :p |
|
|
| Report Abuse |
|
|
DevJoas
|
  |
| Joined: 17 Dec 2014 |
| Total Posts: 627 |
|
|
| 15 May 2017 04:30 PM |
| the things you sleep in is apparently filtered out by roblox... |
|
|
| Report Abuse |
|
|
|
| 15 May 2017 04:38 PM |
Ahh alright man, have a good night! And i'll try to explain a little bit better :)
So in your average MMORPG, you can have quests that you get from an NPC that simply wants you to talk to another NPC.
As a starting point, the way this script works is you click an npc and it connects to a series of stringvalues in the explorer. The Name of the values are what your response buttons would say, while the Value of the stringvalues is what the NPC will respond with. When you reach a segment of the conversation, the script checks for a 2 special string values that dont actually appear as buttons. one is NEEDQUEST(This holds the name of the quest that you need to move on in that part of the conversation) and the other is NEEDITEM(this holds the name of the item that is required to move on in that part too). Within NEEDITEM is also an intvalue called Count, where the Value of Count is the number of an item you would need to proceed.
In that case for this script, i would want an if statement that checks if you have the quest, BUT skips the statement completely if the npc wants an item too. As well as vice versa, so if its simply a repeatable quest, you can go to them and the if statement will check if you have the item BUT skips the statement completely if they also want you to have a quest.
I want it like this so i can safely have the 3rd scenario:
the 3rd scenario is that if you go to a npc that requires certain items to complete a quest, then there needs to be an if statement that requires BOTH the items and the quest. So if you have the quest "Helping the Old Man" and he requests 10 Mushrooms, then that last statement would need to check that you have the "Helping the Old Man" quest, as well as 10 or more Mushrooms!
Does that kind of help explain it? :D |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 15 May 2017 06:38 PM |
I didn't read any of the replies so sorry if this is irrelevant as I only read the thread title:
"Issue detecting 1 true, 1 false OR 2 true" if (x ~= y) or (x and y) then
should work assuming x and y are booleans. If not cast them into a boolean via double-negation. x = not not X |
|
|
| Report Abuse |
|
|
|
| 15 May 2017 06:41 PM |
@cntkillme Yea, a little litteral on the title, i apologize about that :) I wasn't very good at describing it, but my brains been melting all day, i been multitasking all kinds of things across 2 rbx saves and 12 different scripts!
But i think i came up with a simpler way of questioning it...
How can i make: if currentoption:findFirstChild("NEEDITEM") and currentoption:findFirstChild("NEEDQUEST") == nil then
actually detect if there is a child called NEEDITEM, and NOT a child called NEEDQUEST? I thought having it check if NEEDQUEST was nil, but its not working. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 15 May 2017 06:47 PM |
I thought the same, but when i test it out, it makes the button appear.
For example, the NPC i been testing with wants both a quest AND an item, but i havnt included a section of code for both yet. But still, when i run this code and go through the conversation with BOTH an item and a quest, or just one of each, it proceeds with the conversation and rewards me. Thats not what it should be doing, it shouldn't be making a button since he wants both and both if statements present in the script say he can only have 1! |
|
|
| Report Abuse |
|
|
|
| 15 May 2017 07:39 PM |
Ended up getting it working, and its because i went 100% idiot :(
I made 2 mistakes, the first was that without me noticing, i accidentally moved something out of the proper place in the explorer tree.
The 2nd was that because i was trying to make sure it detected that the npc had one but not the other, while he actually had both, i never made the statement that detects both. As such, it defaulted to adding in the buttons and working as normal. Sorry about that guys! |
|
|
| Report Abuse |
|
|