 |
Fizgar Magician
Joined: 07 Feb 2002 Posts: 333 Location: Central Virginia
|
Posted: Mon Mar 29, 2010 3:19 am
[3.16a] Possible BUG: If then else elseif elseif |
First a question is it possible to do an IF THEN ELSE ELSEIF ELSEIF... type statement in zscript like you can in LUA (or atleast with the limited LUA experience I have it is possible might not have been using pure LUA it was from another game called gmod)? Currently I'm using this.
Code: |
#if (@wildertype =~ Function) {#if (@wildertype =~ Header) {#if (@wildertype =~ macro) {#if (@wildertype =~ Routine) {#var wildertype Function;#show FinishedDecompile} {#var wildertype Routine;#show ContinueDecompile}} {#var wildertype Macro;#show ContinueDecompile}} {#var wildertype Header;#show ContinueDecompile}}
|
I think the order is correct but I could be wrong. I deleted the triggers out of fustration last night and was planing to start from scratch but i figured i'd ask here and see if I was wasting my time. The goal of the trigger is this. When fired, if @wildertype = function, @wildertype should be changed to Header, then ContinueDecompile fires another trigger which repeats actions untill this trigger fires again. Then it will change @wildertype to Macro and then to Routine, then back to Function.
Now for the BUG part. when the above trigger fires it screws up MXP and links that were working fine are displayed as they are below.
it works every single time I try it. the mxp gets busted.
Code: |
<Drop 'Comlink module' 'Comlink module'>Comlink module</Drop>
<Drop 'Parser module' 'Parser module'>Parser module</Drop>
<Drop 'Devkit module' 'Devkit module'>Devkit module</Drop>
<Drop 'dropline' 'dropline [app]'>dropline [app]</Drop>
<Drop 'Compiler module' 'Compiler module'>Compiler module</Drop>
<Drop 'Function' 'Function [wilderspace]'>Function [wilderspace]</Drop>
|
Thanks in advance for any advise,
Mike |
|
|
 |
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Mar 29, 2010 5:02 am |
The #IF command and %if() function are rigidly just a true-false set of codeblocks. You can nest them as deeply as desired if you want, but with 3+ conditions to check you are much better off using #SWITCH (independant conditions with independant results equating to true) or #CASE (one condition with results indicating by number which code block to execute):
Code: |
#if (condition) {
//stuff to do when condition = true
#if (condition) {
//stuff to do when condition = true
} {
//stuff to do when condition = false
}
} {
//stuff to do when condition = false
#if (condition) {
//stuff to do when condition = true
} {
//stuff to do when condition = false
}
} |
Code: |
#switch (true1) {}
(true2) {}
(trueN) {} |
Code: |
#case (number) {} {} {} {} {} |
|
|
_________________ EDIT: I didn't like my old signature |
|
|
 |
Fizgar Magician
Joined: 07 Feb 2002 Posts: 333 Location: Central Virginia
|
Posted: Mon Mar 29, 2010 8:20 am |
Thanks Matt #switch seems to be working wonderfully just what I needed guess I overlooked it some how. However this still seems to break MXP just like my previous example did. i've disabled everything but the class folder that this script needs to run and it's still doing it. So i started a clean session and did the following.
I made a trigger
Pattern:MXP test
Script Text:
Code: |
#switch (@test = 1) {#show test = 1}
(@test = 2) {#show test = 2}
(@test = 3) {#show test = 3}
(@test = 4) {#show test = 4}
|
I then created the variable @test and set it to 1.
I type inventory and all my MXP links are fine.
I type #show MXP test
Cmud returns test = 1
I type inventory again and all my links are busted once more.
Gonna try and find another mud that has mxp on it and give this test another go and see if the results are the same since this is a new mud there could be something wrong on the servers end maybe, idk.
I'll post back in a bit. |
|
|
 |
Fizgar Magician
Joined: 07 Feb 2002 Posts: 333 Location: Central Virginia
|
Posted: Mon Mar 29, 2010 8:37 am |
Ok so i just tested this on two other muds and their MXP works fine so i'm guessing the problem has to do with this being a new mud. Does anyone have a clue as to what may be causing this so that I might be able to direct the Admins attention to the problem?
|
|
_________________ Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34 |
|
|
 |
|
|