I know this is simple, but I've been teaching myself scripting and cant seem to get it correct. I want a trigger to fire a certain command if a variable equals a certain string. What I'm doing now is making myself auto-swim back the way I came if I get pulled in while fishing. I know how to do it if the variable matches a number, that is with the ==, but how does one get a conditional statement to be true when the variable matches a string? for instance
if fishdir = e or east then swim w
that's obviously not the correct syntax but I'm just trying to clarify what I'm trying to do in the simplest terms.
Comments
In the case of Mudlet. Though having mass stops you from being pulled along while fishing I think.
This line is wrong:
if fishdir=="e" or "east" then
It is wrong, because what it means is "if fishdir is equal to e, or if east". Since "east" isn't false, that line will always be true. The correct way to do the conditional is:
if fishdir=="e" or fishdir=="east" then
EDIT: And even that is ambiguous to read. It will work, because of order of operations (== is evaluated before or), but just reading it with your eyes it's not entirely clear what parts are executed when. For readability's sake, I'd write it as
if ((fishdir=="e") or (fishdir=="east")) then
the claims are stated - it's the world I've created
it bears the mark of - it has the mark I care about, yay! --- set a flag indicating that I'm checking for bait
trigger for line two - it's baited, unset the flag
trigger for prompt - If I'm still checking for bait, that means the bait line never showed up, so I need to reel, bait, cast
the claims are stated - it's the world I've created
send("probe pole")
bait = false
When it checks, you'll see if you have it or not, and have the bait line send:
bait = true
Then have you're prompt right after the bait check line have:
if not bait then
send("bait pole with whatever")
bait = true
end
the claims are stated - it's the world I've created
EDIT:
Here's mine, converted from CMUD pattern matching to regex
^<(\d+)/(\d+)h\(\d+\) (\d+)/(\d+)m\(\d+\) (.*)x <([e-])([b-])>(?: (<.*>)?) (\d+)E (\d+)b$
My prompt looks like this:
<550/550h(100) 488/490m(99) 70.13x <eb> <db> 78E 0b
the claims are stated - it's the world I've created