-
Notifications
You must be signed in to change notification settings - Fork 2
Fixed and simplified #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Gurkoel
wants to merge
19
commits into
mluzarow:master
Choose a base branch
from
Gurkoel:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
014165d
Update MethHelper.lua
Gurkoel 9a752ca
Update README.md
Gurkoel 1215033
Add files via upload
Gurkoel abc5573
Add files via upload
Gurkoel fba50e1
Add files via upload
Gurkoel 3ce32a5
Add files via upload
Gurkoel 452fb8c
Fixed a Few bugs and added a Menu
Gurkoel 5cfe624
Merge pull request #1 from Gurkoel/Menu
Gurkoel b714ae1
simplyfied code
Gurkoel 91bc123
Fixen and simplified
Gurkoel e81c42b
further simplyfied code, investigating into 8bag bug
Gurkoel 867227d
Found a solution for 8 bag error, its being tested if a dialog is mis…
Gurkoel 8310f01
Testing in progression ...
Gurkoel 58e3083
test
Gurkoel 8e8c2e2
Merge branch 'Testing' of https://github.com/Gurkoel/MethHelper into …
Gurkoel 37d3d2e
8-bag bug fixed
Gurkoel 7ac250d
Merge pull request #2 from Gurkoel/Testing
Gurkoel 4905106
Merge branch 'master' into master
Gurkoel 4a9ada6
Update MethHelper.lua
Gurkoel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,6 +87,9 @@ ingredient_dialog['Play_loc_mex_cook_03'] = 'Muriatic Acid' | |
| ingredient_dialog['Play_loc_mex_cook_04'] = 'Caustic Soda' | ||
| ingredient_dialog['Play_loc_mex_cook_05'] = 'Hydrogen Chloride' | ||
| -- Round about hacky way to trigger by both ingredients and recipe state dialogue | ||
|
|
||
| local batchFinishedDialog = {"pln_rat_stage1_28","pln_rt1_28","Play_loc_mex_cook_17","Play_loc_mex_cook_13"} | ||
|
|
||
| ingredient_dialog[RatsFinishedID] = true | ||
| ingredient_dialog[RatsAddedID] = true | ||
| ingredient_dialog[CookoffFinishedID] = true | ||
|
|
@@ -103,8 +106,64 @@ currentRecipeList['Muriatic Acid'] = false | |
| currentRecipeList['Caustic Soda'] = false | ||
| currentRecipeList['Hydrogen Chloride'] = false | ||
|
|
||
| IngredientCount = 0 | ||
| OldIngredientCount = 0 | ||
|
|
||
| local lastAdded = false | ||
| local IngredientCount = 0 | ||
| local OldIngredientCount = 0 | ||
|
|
||
| function sendMethMessage(number, id) | ||
| if number == 1 then | ||
| if MethHelper._data.silent_toggle == true or MethHelper._data.silent_toggle == 'on' then | ||
| managers.chat:_receive_message(1, '[SilentMethMagic]', 'Ingredient added!', Color.green) | ||
| else | ||
| managers.chat:send_message(1, '[SilentMethMagic]', 'Ingredient added!', Color.green) | ||
| end | ||
| elseif number == 2 then | ||
| if MethHelper._data.silent_toggle == true or MethHelper._data.silent_toggle == 'on' then | ||
| managers.chat:_receive_message(1, '[SilentMethMagic]', '[' .. countAddedIngredients(currentRecipeList) .. '/3] [' .. ingredient_dialog[id] .. ']', Color.green) | ||
| else | ||
| managers.chat:send_message(1, '[SilentMethMagic]', '[' .. countAddedIngredients(currentRecipeList) .. '/3] [' .. ingredient_dialog[id] .. ']', Color.green) | ||
| end | ||
| elseif number == 3 then | ||
| if MethHelper._data.silent_toggle == true or MethHelper._data.silent_toggle == 'on' then | ||
| managers.chat:_receive_message(1, '[SilentMethMagic]', 'Total bags: [' .. totalBags .. ']', Color.green) | ||
| else | ||
| managers.chat:send_message(1, '[SilentMethMagic]', 'Total bags: [' .. totalBags .. ']', Color.green) | ||
| end | ||
| elseif number == 4 then | ||
| if MethHelper._data.silent_toggle == true or MethHelper._data.silent_toggle == 'on' then | ||
| managers.chat:_receive_message(1, '[SilentMethMagic]', 'No finished dialouge caught, Bag-count is being guessed by now', Color.red) | ||
| else | ||
| managers.chat:send_message(1, '[SilentMethMagic]', 'No finished dialouge caught, Bag-count is being guessed by now', Color.red) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| function isMethFinished(id) | ||
| for i, v in pairs(batchFinishedDialog) do | ||
| if v == id then | ||
| return true | ||
| end | ||
| end | ||
| end | ||
|
|
||
| function isIngredient(id) | ||
| for i,v in pairs(ingredient_dialog) do | ||
| if v == 'Muriatic Acid' or v == 'Caustic Soda' or v == 'Hydrogen Chloride' then | ||
| return true | ||
| end | ||
| end | ||
| end | ||
|
|
||
|
|
||
| function getTotalIngredients(Table) | ||
| local ingredients = 0 | ||
| for k, v in pairs(Table) do | ||
| ingredients = ingredients + 1 | ||
| end | ||
| return ingredients | ||
| end | ||
|
|
||
|
|
||
| function countAddedIngredients(Table) | ||
| local count = 0 | ||
|
|
@@ -123,60 +182,54 @@ function DialogManager:queue_dialog(id, ...) | |
| -- If dialogue code is found in dict | ||
| if ingredient_dialog[id] and MethHelper._data.active_toggle == true or MethHelper._data.active_toggle == 'on' then | ||
| -- If "batch finished" dialogue is played | ||
| if id == CookoffFinishedID or id == RatsFinishedID or id == BorderCrystalFinsishedID or id == BorderCrystalFinsishedID2 then | ||
| -- If "ingredient added" dialogue is played | ||
| if isMethFinished(id) == true then | ||
| -- If "BAg finished" dialogue is played | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bonus capital letter. |
||
| OldIngredientCount = 0 | ||
| totalBags = totalBags + 1 | ||
| -- Reset recipe state | ||
| currentRecipeList['Muriatic Acid'] = false | ||
| currentRecipeList['Caustic Soda'] = false | ||
| currentRecipeList['Hydrogen Chloride'] = false | ||
| lastAdded = false | ||
| -- check menu options | ||
| if MethHelper._data.silent_toggle == true or MethHelper._data.silent_toggle == 'on' then | ||
| managers.chat:_receive_message(1, '[SilentMethMagic]', 'Total bags: [' .. totalBags .. ']', Color.green) | ||
| else | ||
| managers.chat:send_message(1, '[SilentMethMagic]', 'Total bags: [' .. totalBags .. ']', Color.green) | ||
| end | ||
| sendMethMessage(3, id) -- Total bags ... | ||
| elseif | ||
| (id == CookoffAddedID or id == RatsAddedID or id == BorderCrystalAddedID) and ((currentRecipeList['Muriatic Acid'] == true and currentRecipeList['Caustic Soda'] == true and currentRecipeList['Hydrogen Chloride'] == true) == false) and | ||
| ((currentRecipeList['Muriatic Acid'] == false and currentRecipeList['Caustic Soda'] == false and currentRecipeList['Hydrogen Chloride'] == false) == false) | ||
| then | ||
| IngredientCount = countAddedIngredients(currentRecipeList) | ||
| if IngredientCount > OldIngredientCount then | ||
| OldIngredientCount = IngredientCount | ||
| if MethHelper._data.silent_toggle == true or MethHelper._data.silent_toggle == 'on' then | ||
| managers.chat:_receive_message(1, '[SilentMethMagic]', 'Ingredient added!', Color.green) | ||
| else | ||
| managers.chat:send_message(1, '[SilentMethMagic]', 'Ingredient added!', Color.green) | ||
| end | ||
| end | ||
| elseif (id == CookoffAddedID or id == RatsAddedID or id == BorderCrystalAddedID) and countAddedIngredients(currentRecipeList) == 3 then | ||
| -- Else ID is for ingredient | ||
| -- Dialouge is a Meth-related dialouge and it's neither 0 nor a higher than 3 | ||
| (id == CookoffAddedID or id == RatsAddedID or id == BorderCrystalAddedID) and countAddedIngredients(currentRecipeList) > 0 and countAddedIngredients(currentRecipeList) <= getTotalIngredients(currentRecipeList) then | ||
| IngredientCount = countAddedIngredients(currentRecipeList) | ||
| if IngredientCount > OldIngredientCount then | ||
| OldIngredientCount = IngredientCount | ||
| if MethHelper._data.silent_toggle == true or MethHelper._data.silent_toggle == 'on' then | ||
| managers.chat:_receive_message(1, '[SilentMethMagic]', 'Ingredient added!', Color.green) | ||
| sendMethMessage(1, id) -- Ingredient Added | ||
| if IngredientCount == getTotalIngredients(currentRecipeList) then | ||
| lastAdded = true | ||
| else | ||
| managers.chat:send_message(1, '[SilentMethMagic]', 'Ingredient added!', Color.green) | ||
| lastAdded = false | ||
| end | ||
| end | ||
| --check if Bag finished dialog wasn't played this happens i.E in cook off after bag 8! | ||
| elseif isIngredient(id) and lastAdded == true and countAddedIngredients(currentRecipeList) == getTotalIngredients(currentRecipeList) then | ||
| sendMethMessage(4, id) --something went wrong warn player about bag count | ||
| OldIngredientCount = 0 | ||
| totalBags = totalBags + 1 | ||
| -- Reset recipe state because finished dialouge will not be played anymore | ||
| currentRecipeList['Muriatic Acid'] = false | ||
| currentRecipeList['Caustic Soda'] = false | ||
| currentRecipeList['Hydrogen Chloride'] = false | ||
| lastAdded = false | ||
| sendMethMessage(3, id) -- guessed total bags | ||
| sendMethMessage(2, id) -- needed Ingredient | ||
| else | ||
| -- Check to make sure that the ingredient is not already being echoed | ||
| if currentRecipeList[ingredient_dialog[id]] == false then | ||
| -- Flip the flag | ||
| currentRecipeList[ingredient_dialog[id]] = true | ||
|
|
||
| -- Print text | ||
| if MethHelper._data.silent_toggle == true or MethHelper._data.silent_toggle == 'on' then | ||
| managers.chat:_receive_message(1, '[SilentMethMagic]', '[' .. countAddedIngredients(currentRecipeList) .. '/3] [' .. ingredient_dialog[id] .. ']', Color.green) | ||
| else | ||
| managers.chat:send_message(1, '[SilentMethMagic]', '[' .. countAddedIngredients(currentRecipeList) .. '/3] [' .. ingredient_dialog[id] .. ']', Color.green) | ||
| end | ||
| sendMethMessage(2, id) --Ingredient is .... | ||
| end | ||
| end | ||
| end | ||
| -- for event mapping | ||
|
|
||
| -- log("DialogManager: said " .. tostring(id)) | ||
| -- managers.chat:send_message(ChatManager.GAME, managers.network.account:username() or "Offline", id) | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we clean this up slightly so it has less repetition?
(I feel like thats easier to understand)