Arrays, switch, multiple IFs

BlackT

Dedicated Member
Dedicated Member
Sep 20, 2006
91
10
54
Hello,
I'm trying to script a simple quest which involves some multiple #IFs at some point. As I'm "obsessed" about code reusability, I can re-use large blocks of script but for this I need to make some checkings into a function and depending of the input value I set some global variables' values.
I want to ask if it's possible to avoid a long list of #IFs...maybe using arrays or sort of well known SWITCH? Other solution I was thinking about is to have a little table into Game3G where I keep the input value as primary key and the values for needed global variables as the other fields of that table.
Anyone having some other ideas?
Please keep in mind I'm a newbie when it comes about LOM3 scripting (but I learn fast :P)

Thanks in advance!
 

BlackT

Dedicated Member
Dedicated Member
Sep 20, 2006
91
10
54
Already did, that's how I learned to manipulate SQL data :) (thanks for the tutorial!!!)
My question is if this scripting language supports some advanced statements - like SWITCH - or more data types - like arrays.
 
Upvote 0

Inflikted

LOMCN Veteran
Veteran
Aug 4, 2003
256
7
114
probably not hehe.
but you can maybe ask chimera or idabiga :)

they know more about mir3, then everyone else combined hehe
 
Upvote 0

idaBigA

Holley Mir 3!!
VIP
Oct 28, 2003
1,966
110
310
Stoke, UK
I don't get you.. what do you mean by switch?

Mir 3 scripting is pretty basic, but I am sure we can find a way of doing what you need to do, can you be more specific in what you want to do?

P.S. Coly is far better than we are tbh, if there is a way, he will know how.
 
Upvote 0

BlackT

Dedicated Member
Dedicated Member
Sep 20, 2006
91
10
54
It's about using "switch" statement. Instead zillions if #IFs can use SWITCH or something. Some dummy code:
PHP:
SWITCH (%A5) {
    CASE 'blablah':
        MOV D1 10000
        break
    CASE 'blablah1':
        MOV D1 20000
        break
    CASE 'blablah2':
        MOV D1 30000
        break
}
addgold %D1

I hope that makes it clear :)
Is it possible? All NPC scripting tutorials I've read and all quest sources I;ve checked, couldn't find something like this...
 
Upvote 0

idaBigA

Holley Mir 3!!
VIP
Oct 28, 2003
1,966
110
310
Stoke, UK
That isn't that much different from

Code:
[@Switch()]
#ACT
Mov  D1  %ARG(0)

#IF
Equal  D1  1
#ACT
Mov   D1  10000
Goto @GiveGold
Break

#IF
Equal  D1  2
#ACT
Mov   D1  20000
Goto @GiveGold
Break

#IF
Equal  D1  3
#ACT
Mov   D1  30000
Goto @GiveGold
Break

#IF
#ACT
Break

[@GiveGold]
#ACT
Give Gold %D1

Slightly more lines, but its about all you can do in Mir..
 
Upvote 0

chimera

LOMCN VIP
VIP
Jul 30, 2003
1,054
23
235
UK
Mir coding is based it seems to me around BBC Basic, like Ida says it's truely "basic" and revolves around the simplest scripting. If you look up BBC basic which I learnt erm many many years ago you'll see what I mean ;)

ps. thx for the compliment but I just learnt by doing the same as any of you could, it's honestly not rocket science :)
 
Upvote 0

Coly

LOMCN Developer
Developer
Mar 31, 2005
1,399
33
195
Germany
and with A5 ^^ :

Code:
[@Switch()]
#ACT
 Mov  A1  %ARG(0)

#IF
 Equal  A1  "blablah"
#ACT
 Mov   N1  10000
 Goto @GiveGold
 Break

#IF
 Equal  A1  "blablah1"
#ACT
 Mov   N1  20000
 Goto @GiveGold
 Break

#IF
 Equal  A1  "blablah2"
#ACT
 Mov   N1  30000
 Goto @GiveGold
 Break

#IF
#ACT
 Break

[@GiveGold]
#ACT
 Give Gold %N1
 
Upvote 0

BlackT

Dedicated Member
Dedicated Member
Sep 20, 2006
91
10
54
Ok, I got the point. Thanks a lot for the helping hands coming from all of you!
 
Upvote 0