|
adamandkate Wanderer
Joined: 14 Oct 2009 Posts: 57
|
Posted: Tue Dec 15, 2009 5:06 pm
trying to improve a script held together by ducttape. |
hey. im trying to cut down the below script into something more manageable. anyone got any ideas. ive tried putting everything into a variable then using #forall but cant seem to get it to do what i want more.
any ideas?
thanks guys
Code: |
goods
#var checkingsiriena 0
#var checkingsata 0
#var checkingfurglewort 0
#var checkingkelventari 0
#var checkingharfy 0
#var checkingattanar 0
#var checkingolvar 0
#var checkingaldaka 0
#var checkingfebfendu 0
#var checkingatigax 0
#var checkingbreldiar 0
#var checkingkathkusa 0
#var checkingwitan 0
#var checkingwirren 0
#var checkingmadabril 0
#var checkingmegillos 0
#var checkingYavethalion 0
#var checkingtyrlar 0
#var checkinglestagii 0
#var checkingiorthir 0
#var checkingdargwirith 0
#var checkingharfy 0
#var checkingdarsurion 0
#var checkingathillias 0
#var checkinggylvir 0
#var checkingmalloran 0
#var checkingEchianta 0
#var checkingarkasu 0
#var checkingcourgia 0
#var checkingdenallo 0
#var checkingollso 0
#var checkingquarri 0
#var checkingucklice 0
#var checkingadelsh 0
#var checkingalethe 0
#var weneedherbs {}
#var urgentneedherbs {}
#WAIT 5000
#if (@checkingsiriena < 50 and != 0) {#addi weneedherbs siriena} {#say all good}
#if (@checkingsata < 50 and != 0) {#addi weneedherbs sata} {#say all good}
#if (@checkingfurglewort < 50 and != 0) {#addi weneedherbs furglewort} {#say all good}
#if (@checkingkelventari < 50 and != 0) {#addi weneedherbs kelventari} {#say all good}
#if (@checkingattanar < 50 and != 0) {#addi weneedherbs attanar} {#say all good}
#if (@checkingolvar < 50 and != 0) {#addi weneedherbs olvar} {#say all good}
#if (@checkingaldaka < 50 and != 0) {#addi weneedherbs aldaka} {#say all good}
#if (@checkingfebfendu < 50 and != 0) {#addi weneedherbs febfendu} {#say all good}
#if (@checkingatigax < 50 and != 0) {#addi weneedherbs atigax} {#say all good}
#if (@checkingbreldiar < 50 and != 0) {#addi weneedherbs breldiar} {#say all good}
#if (@checkingkathkusa < 50 and != 0) {#addi weneedherbs kathkusa} {#say all good}
#if (@checkingwitan < 50 and != 0) {#addi weneedherbs witan} {#say all good}
#if (@checkingwirren < 50 and != 0) {#addi weneedherbs wirren} {#say all good}
#if (@checkingmadabril < 50 and != 0) {#addi weneedherbs madabril} {#say all good}
#if (@checkingmegillos < 50 and != 0) {#addi weneedherbs megillos} {#say all good}
#if (@checkingYavethalion < 50 and != 0) {#addi weneedherbs Yavethalion} {#say all good}
#if (@checkingtyrlar < 50 and != 0) {#addi weneedherbs tyrlar} {#say all good}
#if (@checkinglestagii < 50 and != 0) {#addi weneedherbs lestagii} {#say all good}
#if (@checkingiorthir < 50 and != 0) {#addi weneedherbs iorthir} {#say all good}
#if (@checkingdargwirith < 50 and != 0) {#addi weneedherbs dargwirith} {#say all good}
#if (@checkingharfy < 50 and != 0) {#addi weneedherbs harfy} {#say all good}
#if (@checkingdarsurion < 50 and != 0) {#addi weneedherbs darsurion} {#say all good}
#if (@checkingathillias < 50 and != 0) {#addi weneedherbs athillias} {#say all good}
#if (@checkingarkasu < 50 and != 0) {#addi weneedherbs arkasu} {#say all good}
#if (@checkinggylvir < 50 and != 0) {#addi weneedherbs gylvir} {#say all good}
#if (@checkingEchianta < 50 and != 0) {#addi weneedherbs Echianta} {#say all good}
#if (@checkingcourgia < 50 and != 0) {#addi weneedherbs courgia} {#say all good}
#if (@checkingdenallo < 50 and != 0) {#addi weneedherbs denallo} {#say all good}
#if (@checkingollso < 50 and != 0) {#addi weneedherbs ollso } {#say all good}
#if (@checkingquarri < 50 and != 0) {#addi weneedherbs quarri} {#say all good}
#if (@checkingmalloran < 50 and != 0) {#addi weneedherbs malloran} {#say all good}
#if (@checkingucklice < 50 and != 0) {#addi weneedherbs ucklice} {#say all good}
#if (@checkingadelsh < 50 and != 0) {#addi weneedherbs adelsh} {#say all good}
#if (@checkingalethe < 50 and != 0) {#addi weneedherbs alethe} {#say all good}
#if (@checkingsiriena = 0) {#addi urgentneedherbs siriena} {#say all good}
#if (@checkingsata = 0) {#addi urgentneedherbs sata} {#say all good}
#if (@checkingfurglewort = 0) {#addi urgentneedherbs furglewort} {#say all good}
#if (@checkingkelventari = 0) {#addi urgentneedherbs kelventari} {#say all good}
#if (@checkingattanar = 0) {#addi urgentneedherbs attanar} {#say all good}
#if (@checkingolvar = 0) {#addi urgentneedherbs olvar} {#say all good}
#if (@checkingaldaka = 0) {#addi urgentneedherbs aldaka} {#say all good}
#if (@checkingfebfendu = 0) {#addi urgentneedherbs febfendu} {#say all good}
#if (@checkingatigax = 0) {#addi urgentneedherbs atigax} {#say all good}
#if (@checkingbreldiar = 0) {#addi urgentneedherbs breldiar} {#say all good}
#if (@checkingkathkusa = 0) {#addi urgentneedherbs kathkusa} {#say all good}
#if (@checkingwitan = 0) {#addi urgentneedherbs witan} {#say all good}
#if (@checkingwirren = 0) {#addi urgentneedherbs wirren} {#say all good}
#if (@checkingmadabril = 0) {#addi urgentneedherbs madabril} {#say all good}
#if (@checkingmegillos = 0) {#addi urgentneedherbs megillos} {#say all good}
#if (@checkingYavethalion = 0) {#addi urgentneedherbs Yavethalion} {#say all good}
#if (@checkingtyrlar = 0) {#addi urgentneedherbs tyrlar} {#say all good}
#if (@checkinglestagii = 0) {#addi urgentneedherbs lestagii} {#say all good}
#if (@checkingiorthir = 0) {#addi urgentneedherbs iorthir} {#say all good}
#if (@checkingdargwirith = 0) {#addi urgentneedherbs dargwirith} {#say all good}
#if (@checkingharfy = 0) {#addi urgentneedherbs harfy} {#say all good}
#if (@checkingdarsurion = 0) {#addi urgentneedherbs darsurion} {#say all good}
#if (@checkingathillias = 0) {#addi urgentneedherbs athillias} {#say all good}
#if (@checkingarkasu = 0) {#addi urgentneedherbs arkasu} {#say all good}
#if (@checkinggylvir = 0) {#addi urgentneedherbs gylvir} {#say all good}
#if (@checkingEchianta = 0) {#addi urgentneedherbs Echianta} {#say all good}
#if (@checkingcourgia = 0) {#addi urgentneedherbs courgia} {#say all good}
#if (@checkingdenallo = 0) {#addi urgentneedherbs denallo} {#say all good}
#if (@checkingollso = 0) {#addi urgentneedherbs ollso } {#say all good}
#if (@checkingquarri = 0) {#addi urgentneedherbs quarri} {#say all good}
#if (@checkingmalloran = 0) {#addi urgentneedherbs malloran} {#say all good}
#if (@checkingucklice = 0) {#addi urgentneedherbs ucklice} {#say all good}
#if (@checkingadelsh = 0) {#addi urgentneedherbs adelsh} {#say all good}
#if (@checkingalethe = 0) {#addi urgentneedherbs alethe} {#say all good}
#wait 2000
say We need restocking, at centre of thak square please. The following hold stock less then 50 @weneedherbs
say We URGENTLY need the following at centre of thak square please as stock have reached ZERO. @urgentneedherbs |
|
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Tue Dec 15, 2009 6:16 pm |
Code: |
#local $normal $urgent
#loopdb @myherbs {
#switch ((%val > 0) and (%val < 50)) {#additem $normal %key}
(%val = 0) {#additem $urgent %key}
}
#say %concat("We need more of these herbs (< 50): ",$normal,%cr,"We are out of these herbs: $urgent")
|
@myherbs is a datarecord variable, where each key field is the name of an herb and each value is the amount you have. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
adamandkate Wanderer
Joined: 14 Oct 2009 Posts: 57
|
Posted: Tue Dec 15, 2009 7:06 pm wow |
that is AMAZING. thankyou so much. made a tweak to it did more of what i wanted and fixed the last line.
im new with databases. so this is really quite exciting to me... is there a way to add another collumn in a database. so obviously right now i have the herbname=herb number
what i would like to have is a third collumn which contains the specific number to have for each herb (currently set to 50 for all). so i could set something like #switch ((%val > 0) and (%val < %val2))
Code: |
#local $normal $urgent
#loopdb @myherbs {
#switch ((%val > 0) and (%val < 50)) {#additem $normal %key}
(%val = 0) {#additem $urgent %key} {#say null;#addkey myherbs %key 0}
}
#say %concat("We need more of these herbs (< 50): ",$normal,%cr,"We are out of these herbs:" ,$urgent,)
|
does that make sence? thanks again |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Tue Dec 15, 2009 8:01 pm |
How many herbs are you dealing with? I'm not sure an actual database would be necessary, and database is not the same as datarecord variable. What I would do is to store a stringlist in the value of each key in @MyHerbs, which you can then parse out and use as needed:
#local $normal $urgent $restock $inventory
#loopdb @myherbs {
#call %match(%val,"(%d)|(%d)",$restock,$inventory)
#switch (($inventory > 0) and (inventory < $restock)) {#additem $normal %key}
($inventory = 0) {#additem $urgent %key}
}
#say %concat("We are low on these herbs: ",$normal,%cr,"We are out of these herbs:" ,$urgent)
If you really want to use a database, we'll have to do things a bit differently. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
|
|