Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local button
- local spinner = false -- upgrade wheel code
- if script:FindFirstChild("Inherit") and script.Parent:FindFirstChild("Spinner") then -- is wheel
- button = script.Parent.Spinner[script.Inherit.Value] -- state wheel part
- spinner = true -- set as spinner
- else
- button = script.Parent
- end
- local elib = require(game.ServerScriptService.Modules.Lib.Effects)
- local lib = require(game.ServerScriptService.Modules.EffectsFunctions)
- local saving = require(game.ServerScriptService.Modules.BaseSaving)
- local fld
- -- mod folder
- local mods = script.Parent.Parent:FindFirstChild("Modify") or Instance.new("Folder",script.Parent.Parent)
- mods.Name = "Modify"
- local val = mods:FindFirstChild("ValueMultiplier") or Instance.new("NumberValue",mods)
- val.Name = "ValueMultiplier"
- val.Value = -1
- local inc = mods:FindFirstChild("ValueMultiplier") or Instance.new("NumberValue",mods)
- inc.Name = "ValueIncrease"
- inc.Value = 0
- local pwr = mods:FindFirstChild("PowerCost") or Instance.new("NumberValue",mods)
- pwr.Name = "PowerCost"
- pwr.Value = 1
- local typ = mods:FindFirstChild("ModType") or Instance.new("StringValue",mods)
- typ.Name = "ModType"
- typ.Value = "Upgrader"
- function HookupTooltip()
- local f = fld:FindFirstChild("IGChange") or Instance.new("BindableFunction",fld)
- f.Name = "IGChange"
- f.OnInvoke = Tooltip
- end
- function Tooltip()
- local View = {
- {"Value","x","",val},
- {"Static","+","$",inc},
- {"Consumption","","x",pwr},
- }
- local s = "Automation Stats:" .. string.format'\n'
- for _,dat in pairs(View) do
- --print(dat[4].Name)
- s=s..(dat[1]..": "..dat[2]..tostring(dat[4].Value)..dat[3]..string.format"\n")
- end
- if (not s) or s=="" then
- if fld and fld.Name=="UnitOptions" and fld:FindFirstChild("IG_Tooltip") then
- fld.IG_Tooltip:Destroy()
- end
- return
- end
- if not fld then return end
- if fld.Name~="UnitOptions" then return end
- local v = fld:FindFirstChild("IG_Tooltip") or Instance.new("StringValue",fld)
- v.Name = "IG_Tooltip"
- v.Value = s
- return v
- end
- if spinner then -- if is spinner
- fld = script.Parent:WaitForChild(script.Inherit.Value) -- get separate folder (Inherit defined)
- else
- fld = button.Parent:WaitForChild("UnitOptions")
- end
- if fld:FindFirstChild("RequiresSun") then
- sun = fld.RequiresSun
- end
- if fld and fld:FindFirstChild("PowerConsumption") then
- local defv = fld.PowerConsumption.Value
- pwr.Changed:connect(function(val)
- fld.PowerConsumption.Value = defv*val
- end)
- end
- local deb = {}
- RNG = function(min,max) -- replacement to account for high numbers
- local n = min+(math.random()*(max-min))
- --print(n.. " Generated.")
- return n
- end
- local dodebug = false
- debugprint = function(...)
- if not dodebug then return end
- --print(...)
- end
- local orange = BrickColor.new("Deep orange")
- local black = BrickColor.new("Black")
- local sun_value = game.ReplicatedStorage.WorldSettings.SolarPower
- gravity = 150
- function short(n)
- return math.floor(n*100 + 0.5)/100
- end
- function doGravity(dir,part,f)
- dir=((dir.unit)*part:GetMass()*(gravity/1.5))
- f.Force = dir
- end
- function getOwner()
- if script.Parent.Parent:FindFirstChild("Owner") then
- if script.Parent.Parent.Owner.Value then
- return script.Parent.Parent.Owner.Value
- end
- end
- end
- local acteffects = {"do","darken"}
- function EntActivate(dvalue,basev,part)
- local chances = (math.log(dvalue.Value)/291)*100
- if chances<50 then -- around 1e64
- local e = Instance.new("Explosion",workspace)
- e.Position = part.Position
- else
- chances=chances-50
- chances=(chances/4)^.5
- local roll = math.random(1,1000)/10
- --print(short(chances).."% Chance to effect! (Roll: " ..short(roll).. "%)")
- if chances >= roll then
- local eff = acteffects[math.random(1,2)]
- if eff=='darken' then
- basev.Value = 1e127
- dvalue.Value = 1e127
- part.BrickColor = BrickColor.Black()
- part.Material = "Neon"
- game.ServerStorage.Darkness:Clone().Parent = part
- local pl = getOwner()
- if pl and workspace.Players[pl.Name].PlayerData.Difficulty.Value == "Extreme" then
- saving:SaveBadge(pl, "Drop Graduation")
- end
- elseif eff== 'do' then
- basev.Value = 1e127
- dvalue.Value = 1e127
- local pl = getOwner()
- if pl and workspace.Players[pl.Name].PlayerData.Difficulty.Value == "Extreme" then
- saving:SaveBadge(pl, "Drop Graduation")
- end
- end
- else
- local rng=math.random(1,5)
- if rng==1 then
- local e = Instance.new("Explosion",workspace)
- e.Position = part.Position
- lib.DissapearDrop(part,script)
- elseif rng==2 then
- local f = Instance.new("BodyForce",part)
- doGravity(Vector3.new(0,1,0),part,f)
- delay(3,function() if part and part.Parent then lib.DissapearDrop(part,script) end end)
- elseif rng>=3 then
- lib.DissapearDrop(part,script)
- end
- end
- end
- end
- function applyEffect(part, effectname, dvalue)
- -- Applies an effect to a drop
- if sun and sun.Value then
- if sun_value.Value <= 0.01 then
- return false, 4, black -- not enough sun
- end
- end
- deb[part] = true
- local eff = part:FindFirstChild("Effects") or Instance.new("Folder")
- eff.Name = "Effects"
- eff.Parent = part
- if elib[effectname] then -- check effect exists
- local effect = elib[effectname] -- get the effect
- local maxEffects = effect.maxEffects or 9e9 -- store max applications
- local maxApplies = effect.affects or -1 -- store max value applied to
- local minApplies = effect.minAffects or -1 -- store min value applied to
- local minBase = effect.minBase or -1 -- store min base value applied to
- local base = effect.base or -1 -- store exact base to be applied to
- local effv
- if not spinner then
- effv = eff:FindFirstChild("Effect"..effectname) -- look up existing effect
- else
- effv = eff:FindFirstChild("EffectSpinner"..script.Parent.Name) -- spinner model effect
- end
- local basev = part:FindFirstChild("BaseValue") -- look up unupgraded value
- if not basev then
- basev = basev or Instance.new("NumberValue",part) -- create new basevalue if it doesnt exist
- basev.Name = "BaseValue" -- give it the proper name
- basev.Value = dvalue.Value -- set base value
- end
- local entropic = basev and (basev.Value>=1e127) -- is this drop entropic?
- if dvalue and dvalue.Value>1e57 then
- if (not effect.extreme) and (not effect.entropic) then
- return false, 5, orange
- end
- if dvalue.Value>1e127 and (not effect.entropic) then
- return false, 6, black
- end
- end
- if minBase ~= -1 then
- if basev.Value < minBase then return false end
- end
- if base ~= -1 then
- if basev.Value ~= base then --[[print('incorrect base: '..basev.Value)]] return false end
- end
- if effv and effv.Value >= maxEffects then return false end -- if cant apply return false
- if maxApplies ~= -1 then -- if maxApplies is a valid number
- -- this line requires an ore to be at most said value
- if dvalue.Value > maxApplies then debugprint'too value' return false end -- if application is invalid return false
- end
- if minApplies ~= -1 then
- -- this line requires an ore be a value before it accepts an upgrade
- if dvalue.Value < minApplies then debugprint('too little value ' ..dvalue.Value.. ' < ' ..minApplies) return false end -- if application is invalid return false
- end
- local v = effv or Instance.new("IntValue",eff) -- create new effectvalue if it doesnt exist
- if not spinner then
- v.Name = "Effect"..effectname -- give it the proper name
- else
- v.Name = "EffectSpinner"..script.Parent.Name -- give it spinner name
- end
- v.Value = v.Value + 1 -- add 1 to its applications
- --print("EditType:".. effect.dropEdit[1],effect.dropEdit[2])
- if effect.dropEdit then
- -- declarations
- local editType = effect.dropEdit[1]
- local editFactor
- --print("effect.dropEdit[2]: " ..effect.dropEdit[2])
- --print("val.Value: " ..val.Value)
- if val.Value >= 0.1 then
- editFactor = effect.dropEdit[2] * val.Value
- else
- editFactor = effect.dropEdit[2]
- end
- --print("editFactor: " ..editFactor)
- local editExtra = effect.dropEdit[3] -- optional, for ceil random
- -- comparisons
- dvalue.Value=dvalue.Value+inc.Value -- mod support
- if editType == "addTo" then
- dvalue.Value = dvalue.Value + editFactor -- add (can be negative)
- --print(editFactor)
- dvalue.Value = math.max(1,dvalue.Value)
- --print(dvalue.Value)
- if not entropic then
- dvalue.Value = math.min(.99*1e127,dvalue.Value) -- maximum to entropic activation
- end
- --print(dvalue.Value)
- return true
- elseif editType == "multiplyTo" then
- dvalue.Value = dvalue.Value * editFactor -- multiply
- dvalue.Value = math.max(1,dvalue.Value)
- if not entropic then
- dvalue.Value = math.min(.99*1e127,dvalue.Value) -- maximum to entropic activation
- end
- return true
- elseif editType == "divideBy" then
- dvalue.Value = dvalue.Value / editFactor -- divide
- dvalue.Value = math.max(1,dvalue.Value)
- if not entropic then
- dvalue.Value = math.min(.99*1e127,dvalue.Value) -- maximum to entropic activation
- end
- return true
- elseif editType == "exponentiate" then
- dvalue.Value = dvalue.Value ^ editFactor -- apply power
- dvalue.Value = math.max(1,dvalue.Value)
- if not entropic then
- dvalue.Value = math.min(.99*1e127,dvalue.Value) -- maximum to entropic activation
- end
- return true
- elseif editType == "randomMult" then
- dvalue.Value = dvalue.Value * RNG(editFactor,editExtra) -- apply random
- dvalue.Value = math.max(1,dvalue.Value)
- if not entropic then
- dvalue.Value = math.min(.99*1e127,dvalue.Value) -- maximum to entropic activation
- end
- return true
- elseif editType == "ANOMALY" then
- -- entropic activation
- EntActivate(dvalue,basev,part)
- return true
- else
- return false,1 -- can't compare editType, return false
- end
- else
- return false,2 -- cant find dropEdit, return failed
- end
- return true,3 -- return success
- end
- return false,4 -- return failed
- end
- -- handle touch
- local color = button.BrickColor
- local x = print
- button.Touched:connect(function(hit)
- if deb[hit] then return end
- if not hit then return end
- if not hit.Parent then return end
- if not hit.Name == "DropperDrop" then return end
- local hitdeb = hit:FindFirstChild("deb")
- if not hitdeb then return end
- if hit:FindFirstChild("rdeb") then return end -- not able to upgrade cards no more lol
- if hitdeb.Value then return end
- local dvalue = hit:WaitForChild("DropData"):WaitForChild("DropValue")
- dvalue.Value = math.max(1,dvalue.Value)
- local success,problem,blink = applyEffect(hit, fld.UpgradeID.Value, dvalue)
- if not success then
- button.BrickColor = BrickColor.Red()
- if problem then x('e6? well, ' ..problem.. ' is the code to be.') end
- wait(3)
- if blink then
- button.BrickColor = blink
- else
- button.BrickColor = color
- end
- deb[hit] = nil
- return
- elseif fld:FindFirstChild("DropExtra") then
- local drp = fld["DropExtra"]
- if drp:FindFirstChild("NewParticle") and not hit:FindFirstChild("NewParticle") then
- drp['NewParticle']:Clone().Parent = hit
- hit.NewParticle.Enabled = true
- end
- if drp:FindFirstChild("Material") then
- hit.Material = drp.Material.Value
- end
- end
- --if not game.ReplicatedStorage.ProducingMore.Value then lib.DisappearDrop(hit) return -1 end
- wait(.1)
- if not button.BrickColor == color then button.BrickColor = color end
- deb[hit]=nil
- end)
- -- IG Tooltip
- Tooltip()
- HookupTooltip()
Advertisement
Add Comment
Please, Sign In to add comment