From 6e74465110c79e022a1b3bc4496b2d165c94d496 Mon Sep 17 00:00:00 2001 From: LorrMaster Date: Thu, 28 Nov 2019 16:01:17 -0500 Subject: [PATCH 1/5] Add files via upload --- code/obj/item/office_supplies.dm | 337 +++++++++++++++++++++++++++++++ 1 file changed, 337 insertions(+) create mode 100644 code/obj/item/office_supplies.dm diff --git a/code/obj/item/office_supplies.dm b/code/obj/item/office_supplies.dm new file mode 100644 index 00000000..2892be2d --- /dev/null +++ b/code/obj/item/office_supplies.dm @@ -0,0 +1,337 @@ +/obj/item/slide_rule + name = "slide rule" + icon = 'icons/obj/slide_rule.dmi' + inhand_image_icon = 'icons/mob/inhand/hand_sliderule.dmi' + icon_state = "sliderule" + var/icon_base = "sliderule" + var/image/slide_image + + var/mathx = 0 + var/mathy = 0 + var/ans = 0 + var/emagged = 0 + var/brokenRuler = 0 + var/iconNum = 1 + var/desc_1 = "Can be used to quickly solve a suprisingly large number of mathmatical calculations.
" + var/desc_2 = "The slide rule has not been used yet." + var/save_1 = "" + var/save_2 = "" + var/save_3 = "" + var/save_4 = "" + var/save_5 = "" + + New() + ..() + src.overlays = null + slide_image = image(src.icon, "[src.icon_base][iconNum]") + src.overlays += src.slide_image + desc_2 = "[src] has not been used yet." + + get_desc() + . += desc_1 + + attack_self(mob/user as mob) + src.browserMenu(user) + return + + proc/browserMenu(mob/user as mob) + if(brokenRuler > 0.5) + user << browse("Slide RuleThe slide rule has an existential crisis
", "window=slide_rule") + onclose(user, "slide_rule") + else + var/dat = "" + dat += "Addition | " + dat += "Subtraction | " + dat += "Multipilcation | " + dat += "Division
" + + dat += "Exponent | " + dat += "Square Root | " + dat += "Nth Root
" + + dat += "Logarithm | " + dat += "Log BaseX | " + dat += "Natural Log

" + + dat += "Sine | " + dat += "Cosine | " + dat += "Tangent
" + + dat += "Arcsine | " + dat += "Arccosine | " + dat += "Arctangent
" + + if(src.emagged == 1) + dat += "
Random Integer | " + dat += "Random Number
" + + dat += "
Previous Calculations:
" + dat += "[(save_5 == "") ? "" : "[save_5]
"]" + dat += "[(save_4 == "") ? "" : "[save_4]
"]" + dat += "[(save_3 == "") ? "" : "[save_3]
"]" + dat += "[(save_2 == "") ? "" : "[save_2]
"]" + dat += "[(save_1 == "") ? "" : "[save_1]
"]" + + user << browse("Slide RuleChoose an operation:

[dat]", "window=slide_rule") + onclose(user, "slide_rule") + + proc/set_x(var/header) + var/temp = copytext(html_encode(input(usr, header, "Slide Rule", "") as null|text), 1, 32) + if(temp == "pi" || temp == "Pi" || temp == "PI") + mathx = 3.14159 + else if(temp == "ans" || temp == "Ans" || temp == "ANS" || temp == "answer" || temp == "Answer" || temp == "ANSWER") + mathx = ans + else if(temp == "e" || temp == "E") + mathx = 2.71828 + else + mathx = text2num(temp) + if(mathx == null) + mathx = 0 + + proc/set_y(var/header) + var/temp = copytext(html_encode(input(usr, header, "Slide Rule", "") as null|text), 1, 32) + + if(temp == "pi" || temp == "Pi" || temp == "PI") + mathy = 3.14159 + else if(temp == "ans" || temp == "Ans" || temp == "ANS" || temp == "answer" || temp == "Answer" || temp == "ANSWER") + mathy = ans + else + mathy = text2num(temp) + if(mathy == null) + mathy = 0 + + proc/saveEquation(var/equ, mob/user as mob) + usr.machine = src + save_5 = save_4 + save_4 = save_3 + save_3 = save_2 + save_2 = save_1 + save_1 = equ + + iconNum = iconNum + 1 + if(iconNum > 5) + iconNum = 1 + src.overlays = null + slide_image = image(src.icon, "[src.icon_base][iconNum]") + src.overlays += src.slide_image + + boutput(user, "[desc_2]") + src.browserMenu(user) + + proc/selfDestruct() + usr.machine = src + brokenRuler = 1 + src.browserMenu(usr) + + var/datum/effects/system/spark_spread/s = unpool(/datum/effects/system/spark_spread) + s.set_up(7, 2, src) + s.start() + playsound(src.loc, "sound/effects/Explosion1.ogg", 35, 1) + src.visible_message("The [src] explodes!") + usr.drop_item() + qdel(src) + + /obj/item/slide_rule/emag_act(var/mob/user, var/obj/item/card/emag/E) + if (!src.emagged) + src.emagged = 1 + src.browserMenu(user) + if(user) + boutput(user, "You slide the card along [src].") + return 1 + return 0 + + /obj/item/slide_rule/demag(var/mob/user) + if (!src.emagged) + return 0 + if (user) + boutput(user, "You slide the card along [src]. It returns to normal.") + src.emagged = 0 + src.browserMenu(user) + return 1 + + Topic(href, href_list) + usr.machine = src + if(brokenRuler == 1 || !isturf(usr.loc)) return + if (!in_range(src, usr)) return + + // Algebra + if (href_list["add"]) + set_x("Number to add?") + set_y("Add [mathx] by?") + ans = mathx+mathy + desc_2 = "[mathx]+[mathy] = [ans]" + saveEquation("[desc_2]", usr) + return + if (href_list["subtract"]) + set_x("Number to add?") + set_y("Subtract [mathx] by?") + ans = mathx-mathy + desc_2 = "[mathx]-[mathy] = [ans]" + saveEquation("[desc_2]", usr) + return + if (href_list["multiply"]) + set_x("Number to multiply?") + set_y("Multiply [mathx] by?") + ans = mathx*mathy + desc_2 = "[mathx]*[mathy] = [ans]" + saveEquation("[desc_2]", usr) + return + if (href_list["divide"]) + set_x("Number to divide?") + set_y("Divide [mathx] by?") + if(mathy == 0) + selfDestruct() + else + ans = mathx/mathy + desc_2 = "[mathx]/[mathy] = [ans]" + saveEquation("[desc_2]", usr) + return + if (href_list["exponent"]) + set_x("Value to find exponent of?") + set_y("Exponent of [mathx]?") + ans = mathx**mathy + desc_2 = "[mathx]^[mathy] = [ans]" + saveEquation("[desc_2]", usr) + return + if (href_list["squareroot"]) + set_x("Value to find square root of?") + mathy = 0.5 + if(mathx < 0) + mathx = abs(mathx) + ans = mathx**mathy + desc_2 = "sqrt(-[mathx]) = [ans]i" + saveEquation("[desc_2]", usr) + else + ans = mathx**mathy + desc_2 = "sqrt([mathx]) = [ans]" + saveEquation("[desc_2]", usr) + return + if (href_list["xroot"]) + set_x("Root value?") + set_y("Find the [mathx]-root of?") + if(mathx == 0) + boutput(usr, "Error") + else + if(mathy < 0) + mathy = abs(mathy) + ans = mathy**(1/mathx) + desc_2 = "-[mathy]^(1/[mathx]) = [ans]i" + saveEquation("[desc_2]", usr) + else + ans = mathy**(1/mathx) + desc_2 = "[mathy]^(1/[mathx]) = [ans]" + saveEquation("[desc_2]", usr) + return + + //Triginometry + if (href_list["sin"]) + set_x("Sin(x) of?") + mathy = 0 + ans = sin(mathx) + desc_2 = "sin([mathx]) = [ans]" + saveEquation("[desc_2]", usr) + return + if (href_list["cos"]) + set_x("Cos(x) of?") + mathy = 0 + ans = cos(mathx) + desc_2 = "cos([mathx]) = [ans]" + saveEquation("[desc_2]", usr) + return + if (href_list["tan"]) + set_x("Tan(x) of?") + mathy = 0 + ans = sin(mathx)/cos(mathx) + desc_2 = "tan([mathx]) = [ans]" + saveEquation("[desc_2]", usr) + return + if (href_list["arcsin"]) + set_x("Arcsin(x) of?") + mathy = 0 + if(mathx > 1) + mathx = 1 + if(mathx < -1) + mathx = -1 + ans = arcsin(mathx) + desc_2 = "arcsin([mathx]) = [ans]" + saveEquation("[desc_2]", usr) + return + if (href_list["arccos"]) + set_x("Arccos(x) of?") + mathy = 0 + if(mathx > 1) + mathx = 1 + if(mathx < -1) + mathx = -1 + ans = arccos(mathx) + desc_2 = "arccos([mathx]) = [ans]" + saveEquation("[desc_2]", usr) + return + if (href_list["arctan"]) + set_x("Arctan(x) of?") + mathy = 0 + if(mathx > 1) + mathx = 1 + if(mathx < -1) + mathx = -1 + ans = arcsin(mathx/sqrt(1+mathx*mathx)) + desc_2 = "arctan([mathx]) = [ans]" + saveEquation("[desc_2]", usr) + return + + // Logarithms + if (href_list["log"]) + set_x("Log(x) of?") + mathy = 0 + if(mathx <= 0) + boutput(usr, "Error") + else + ans = log(mathx) + desc_2 = "log([mathx]) = [ans]" + saveEquation("[desc_2]", usr) + return + if (href_list["logbasex"]) + set_x("Base of log?") + set_y("Base[mathx] log(x)?") + if(mathx<=0 || mathy<=0) + boutput(usr, "Error") + else + ans = log(mathx, mathy) + desc_2 = "Log[mathx]([mathy]) = [ans]" + saveEquation("[desc_2]", usr) + return + if (href_list["ln"]) + set_y("Base of log?") + mathx = 2.71828 + if(mathy <= 0) + boutput(usr, "Error") + else + ans = log(mathx, mathy) + desc_2 = "ln([mathy]) = [ans]" + saveEquation("[desc_2]", usr) + return + + // Emag + if (href_list["randomInt"]) + set_x("Upper bound of random integer?") + set_y("Lower bound of random integer?") + if(mathy>mathx) + var/temp = mathx + mathx = mathy + mathy = temp + ans = rand(mathy, mathx) + desc_2 = "randomInt([mathx], [mathy]) = [ans]" + saveEquation("[desc_2]", usr) + return + if (href_list["randomDec"]) + set_x("Upper bound of random number?") + set_y("Lower bound of random number?") + if(mathy>mathx) + var/temp = mathx + mathx = mathy + mathy = temp + ans = (rand()*(mathx-mathy)) + mathy + desc_2 = "randomNum([mathx], [mathy]) = [ans]" + saveEquation("[desc_2]", usr) + return + return \ No newline at end of file From e9c3edd12d74b3e21d54be8b797a46c3c45949ff Mon Sep 17 00:00:00 2001 From: LorrMaster Date: Thu, 28 Nov 2019 16:02:34 -0500 Subject: [PATCH 2/5] Add files via upload --- icons/obj/slide_rule.dmi | Bin 0 -> 462 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 icons/obj/slide_rule.dmi diff --git a/icons/obj/slide_rule.dmi b/icons/obj/slide_rule.dmi new file mode 100644 index 0000000000000000000000000000000000000000..9bc7634db13ee53e86df964d2e9d6720d1bb751f GIT binary patch literal 462 zcmV;<0WtoGP)i#7GbOdCG$++miHkEOv#1y-XvoExR+N~V3Sna^ zH6dQ9G4V=`h*xSzyi!~$l@(n5T)-g)0LwvI){nd?Z2$lO%t=H+R7iF6XU_gPO z0EQ5wAZ{)bgOLH4!Hguxtjxfm0F#Gsq4KUus$i(Xz>o$}0HmBCVkM{wAo3m^9bf^V zhM5ozGogw)I$BT_%!E5>(E>1o3&}}bS}0BeagpSAZ@}<0_ilXLQ7{Td!6+D+0HuyV zsSX4&7+?UbBNQMkCTMj4;~SW`fPpit{s0yG$Q448DzrvW!{HcEv5#CKOoggf)x_%u zU>$*Q61X~m@fR$CILV6(MFUD5fl?jp#$b$sQ7{ky0BV#dV;qMZ761SM07*qoM6N<$ Ef?Ec!1poj5 literal 0 HcmV?d00001 From e05cc6697bb45f0c9f2da082e2f222d5c1830a84 Mon Sep 17 00:00:00 2001 From: LorrMaster Date: Thu, 28 Nov 2019 16:03:57 -0500 Subject: [PATCH 3/5] Add files via upload --- icons/obj/hand_sliderule.dmi | Bin 0 -> 397 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 icons/obj/hand_sliderule.dmi diff --git a/icons/obj/hand_sliderule.dmi b/icons/obj/hand_sliderule.dmi new file mode 100644 index 0000000000000000000000000000000000000000..b06ce62955509d02ce1db76667f0622597ed6218 GIT binary patch literal 397 zcmV;80doF{P)V=-0C=2J zR&a84_w-Y6@%7{?OD!tS%+FJ>RWQ*r;NmRLOex6#a*U0*I5Sc+(=$pSoZ^zil2jm5 zsW>MyCAFwDCsj8{iHkEOv#1!Pm5Vd2C^0t`#5TmH)(4kbWd&D17qCMBHjF7bY15T6 z00022NklC9n4$cJ=LdXZebnvWb z%|JxWuGdQ&P${a{FM<;)-GMMLRa{covNb7pZ=0f1(CrB!KOt&YY0waFn*ZyOCrc9p rAVdP)Lxc?*=AH|FcsYchcH{*ote*t@U{%)n00000NkvXXu0mjfU%Q Date: Thu, 28 Nov 2019 16:05:08 -0500 Subject: [PATCH 4/5] Delete hand_sliderule.dmi --- icons/obj/hand_sliderule.dmi | Bin 397 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 icons/obj/hand_sliderule.dmi diff --git a/icons/obj/hand_sliderule.dmi b/icons/obj/hand_sliderule.dmi deleted file mode 100644 index b06ce62955509d02ce1db76667f0622597ed6218..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 397 zcmV;80doF{P)V=-0C=2J zR&a84_w-Y6@%7{?OD!tS%+FJ>RWQ*r;NmRLOex6#a*U0*I5Sc+(=$pSoZ^zil2jm5 zsW>MyCAFwDCsj8{iHkEOv#1!Pm5Vd2C^0t`#5TmH)(4kbWd&D17qCMBHjF7bY15T6 z00022NklC9n4$cJ=LdXZebnvWb z%|JxWuGdQ&P${a{FM<;)-GMMLRa{covNb7pZ=0f1(CrB!KOt&YY0waFn*ZyOCrc9p rAVdP)Lxc?*=AH|FcsYchcH{*ote*t@U{%)n00000NkvXXu0mjfU%Q Date: Thu, 28 Nov 2019 16:05:39 -0500 Subject: [PATCH 5/5] Add files via upload --- icons/mob/inhand/hand_sliderule.dmi | Bin 0 -> 397 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 icons/mob/inhand/hand_sliderule.dmi diff --git a/icons/mob/inhand/hand_sliderule.dmi b/icons/mob/inhand/hand_sliderule.dmi new file mode 100644 index 0000000000000000000000000000000000000000..b06ce62955509d02ce1db76667f0622597ed6218 GIT binary patch literal 397 zcmV;80doF{P)V=-0C=2J zR&a84_w-Y6@%7{?OD!tS%+FJ>RWQ*r;NmRLOex6#a*U0*I5Sc+(=$pSoZ^zil2jm5 zsW>MyCAFwDCsj8{iHkEOv#1!Pm5Vd2C^0t`#5TmH)(4kbWd&D17qCMBHjF7bY15T6 z00022NklC9n4$cJ=LdXZebnvWb z%|JxWuGdQ&P${a{FM<;)-GMMLRa{covNb7pZ=0f1(CrB!KOt&YY0waFn*ZyOCrc9p rAVdP)Lxc?*=AH|FcsYchcH{*ote*t@U{%)n00000NkvXXu0mjfU%Q