Модуль:Chemistry Lookup: различия между версиями
ss14>Moony Нет описания правки |
Morty (обсуждение | вклад) м Защитил страницу Модуль:Chemistry Lookup: Скрипты ([Редактирование=Разрешено только администраторам] (бессрочно) [Переименование=Разрешено только администраторам] (бессрочно)) |
||
| (не показаны 3 промежуточные версии этого же участника) | |||
| Строка 4: | Строка 4: | ||
p.chem = prototypes.chem | p.chem = prototypes.chem | ||
p.react = prototypes.react | p.react = prototypes.react | ||
p.groupDirection = prototypes.groupDirection | |||
function p.readscalar(frame) | function p.readscalar(frame) | ||
| Строка 77: | Строка 78: | ||
function p.buildreaction(frame, react) | function p.buildreaction(frame, react) | ||
local data = p.react[react] | local data = p.react[react] | ||
local dest = "Chemistry" | |||
local args = {} | local args = {} | ||
local i = 0 | local i = 0 | ||
for k,v in pairs(data.reactants) do | for k,v in pairs(data.reactants) do | ||
i = i + 1 | i = i + 1 | ||
args["component-" .. i] = frame:expandTemplate{ title = "Chem Recipe Component", args = { reagent = k, amount = v.amount }} | local dest = "Chemistry" | ||
if (p.groupDirection[p.chem[k].group] ~= nil) then | |||
dest = p.groupDirection[p.chem[k].group] | |||
end | |||
args["component-" .. i] = frame:expandTemplate{ title = "Chem Recipe Component", args = { reagent = k, amount = v.amount, dest = dest }} | |||
end | end | ||
i = 0 | i = 0 | ||
for k,v in pairs(data.products) do | for k,v in pairs(data.products) do | ||
i = i + 1 | i = i + 1 | ||
args["result-" .. i] = frame:expandTemplate{ title = "Chem Recipe Component", args = { reagent = k, amount = v }} | local dest = "Chemistry" | ||
if (p.groupDirection[p.chem[k].group] ~= nil) then | |||
dest = p.groupDirection[p.chem[k].group] | |||
end | |||
args["result-" .. i] = frame:expandTemplate{ title = "Chem Recipe Component", args = { reagent = k, amount = v, dest = dest }} | |||
end | end | ||
| Строка 154: | Строка 164: | ||
local out = "" | local out = "" | ||
for k, v in pairs(met) do | for k, v in pairs(met) do | ||
out = out .. "<b>" .. k .. "</b> (" .. v.rate .. " | out = out .. "<b>" .. k .. "</b> (" .. v.rate .. " единиц в секунду)\n" .. p.geneffectlist(v.effects, frame, v.rate) | ||
end | end | ||
return out | return out | ||
| Строка 179: | Строка 189: | ||
elseif w.id == "SmokeAreaReactionEffect" then | elseif w.id == "SmokeAreaReactionEffect" then | ||
out = out .. ":" .. p.gensmokeareareactioneffect(w, frame) .. "\n" | out = out .. ":" .. p.gensmokeareareactioneffect(w, frame) .. "\n" | ||
elseif w.id == "ModifyBleedAmount" then | |||
out = out .. ":" .. p.genmodifybleedamount(w, frame) .. "\n" | |||
end | end | ||
end | end | ||
| Строка 188: | Строка 200: | ||
conds = p.genconds(r.conditions, frame) | conds = p.genconds(r.conditions, frame) | ||
end | end | ||
return frame:expandTemplate{ title = "SmokeAreaReactionEffect", args = { when = conds }} | return frame:expandTemplate{ title = "SmokeAreaReactionEffect", args = { when = conds, prob = r.probability }} | ||
end | end | ||
| Строка 195: | Строка 207: | ||
conds = p.genconds(r.conditions, frame) | conds = p.genconds(r.conditions, frame) | ||
end | end | ||
return frame:expandTemplate{ title = "FoamAreaReactionEffect", args = { when = conds }} | return frame:expandTemplate{ title = "FoamAreaReactionEffect", args = { when = conds, prob = r.probability }} | ||
end | end | ||
| Строка 202: | Строка 214: | ||
conds = p.genconds(r.conditions, frame) | conds = p.genconds(r.conditions, frame) | ||
end | end | ||
return frame:expandTemplate{ title = "ExplosionReactionEffect", args = { when = conds }} | return frame:expandTemplate{ title = "ExplosionReactionEffect", args = { when = conds, prob = r.probability }} | ||
end | end | ||
| Строка 209: | Строка 221: | ||
conds = p.genconds(r.conditions, frame) | conds = p.genconds(r.conditions, frame) | ||
end | end | ||
return frame:expandTemplate{ title = "GenericStatusEffect", args = { key = r.Key, type = r.Type, time = r.Time, refresh = r.Refresh, when = conds }} | return frame:expandTemplate{ title = "GenericStatusEffect", args = { key = r.Key, type = r.Type, time = r.Time, refresh = r.Refresh, when = conds, prob = r.probability }} | ||
end | end | ||
| Строка 216: | Строка 228: | ||
conds = p.genconds(r.conditions, frame) | conds = p.genconds(r.conditions, frame) | ||
end | end | ||
return frame:expandTemplate{ title = "AdjustTemperature", args = { amount = r.Amount, when = conds }} | return frame:expandTemplate{ title = "AdjustTemperature", args = { amount = r.Amount, when = conds, prob = r.probability }} | ||
end | end | ||
| Строка 223: | Строка 235: | ||
conds = p.genconds(r.conditions, frame) | conds = p.genconds(r.conditions, frame) | ||
end | end | ||
return frame:expandTemplate{ title = "FlammableReaction", args = { multiplier = r.Multiplier, when = conds }} | return frame:expandTemplate{ title = "FlammableReaction", args = { multiplier = r.Multiplier, when = conds, prob = r.probability }} | ||
end | end | ||
| Строка 230: | Строка 242: | ||
conds = p.genconds(r.conditions, frame) | conds = p.genconds(r.conditions, frame) | ||
end | end | ||
return frame:expandTemplate{ title = "FlammableReaction", args = { multiplier = r.Multiplier, when = conds }} | return frame:expandTemplate{ title = "FlammableReaction", args = { multiplier = r.Multiplier, when = conds, prob = r.probability }} | ||
end | end | ||
| Строка 237: | Строка 249: | ||
conds = p.genconds(r.conditions, frame) | conds = p.genconds(r.conditions, frame) | ||
end | end | ||
return frame:expandTemplate{ title = "AdjustReagent", args = { amount = r.Amount, reagent = r.Reagent, when = conds }} | return frame:expandTemplate{ title = "AdjustReagent", args = { amount = r.Amount, reagent = r.Reagent, when = conds, prob = r.probability }} | ||
end | |||
function p.genmodifybleedamount(r, frame) | |||
if r.conditions ~= nil then | |||
conds = p.genconds(r.conditions, frame) | |||
end | |||
return frame:expandTemplate{ title = "ModifyBleedAmount", args = { amount = r.Amount, when = conds, prob = r.probability }} | |||
end | end | ||
| Строка 270: | Строка 289: | ||
conds = p.genconds(h.conditions, frame) | conds = p.genconds(h.conditions, frame) | ||
end | end | ||
return frame:expandTemplate{ title = "HealthChange", args = { heals = heals, deals = deals, when = conds }} | return frame:expandTemplate{ title = "HealthChange", args = { heals = heals, deals = deals, when = conds, prob = h.probability }} | ||
end | end | ||
| Строка 327: | Строка 346: | ||
for _ in pairs(T) do count = count + 1 end | for _ in pairs(T) do count = count + 1 end | ||
return count | return count | ||
end | |||
function has_value(tab, val) | |||
for index, value in ipairs(tab) do | |||
if value[1] == val then | |||
return true | |||
end | |||
end | |||
return false | |||
end | |||
function strsplit(inputstr, seperator) | |||
if seperator == nil then | |||
seperator = "," | |||
end | |||
local t={} | |||
for str in string.gmatch(inputstr, "([^"..seperator.."]+)") do | |||
table.insert(t, str) | |||
end | |||
return t | |||
end | end | ||
return p | return p | ||