Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ Writing an EQ Switching Plugin...

Writing an EQ Switching Plugin...

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Queso   (5 posts)  Bio
Date Fri 24 Oct 2003 10:50 AM (UTC)
Message
I have written this in jscript, and everything is working, with the exception of a world.savestate() call. To be a bit more specific, I moved the savestate to it's one function and I have an alias that passes to it, it works fine. I have another 30-40 line alias that handles changing the eq, and it calls the same function - but it doesn't seem to save the state. I have echo's in place just to double check everything - the echo's come out right, but the state is never actually saved for some reason. The code for the function:

function setCurEQ(curSet)
{
test = world.SetVariable("curEqSet", curSet);
world.SaveState();
curEqSet = world.GetVariable("curEqSet");
world.note("Your Current EQ Set is now: " + curEqSet);
}

If you notice, I echo the var from a GetVariable statement, and it does seem to confirm the change. But if I echo the var out after that function is run - the varaible is what it was before the change. This is the last thing I need to get this script functioning and it is driving me nuts!

Thx for any help,
Queso
Top

Posted by Queso   (5 posts)  Bio
Date Reply #1 on Fri 24 Oct 2003 11:59 AM (UTC)
Message
Ok,

After a bit more testing, SaveState returns 0 in the function above when it works right. In the case where it doesn't work, it is returning a 30035 which is eNotAPlugin?!

Anyone have any idea what I am doing wrong?

--Q
Top

Posted by Queso   (5 posts)  Bio
Date Reply #2 on Fri 24 Oct 2003 01:01 PM (UTC)

Amended on Fri 24 Oct 2003 02:19 PM (UTC) by Queso

Message
I hope I am not overloading anyone who is reading this, but I am going to attach the alias and the function is calls - this is the function that calls the above function to save the variable. It appears any savestate that is done by this function(changeEQ) or any it calls, it returns error code 30035.

<alias
match="^eq (.*)$"
enabled="y"
regexp="y"
name="eq"
script="changeEQ"
sequence="100"
send_to="12"
>
</alias>

function changeEQ()
{
newEqSet = world.getaliasinfo("eq", 101);
innerRobe = world.GetVariable("innerRobe");
curEqSet = world.GetVariable("curEqSet");
eqArray = readEQ();
curSetNum = findSet(eqArray, curEqSet);
newSetNum = findSet(eqArray, newEqSet);
curContainer = eqArray[curSetNum][19];
newContainer = eqArray[newSetNum][19];
curRobe = eqArray[curSetNum][13];
newRobe = eqArray[newSetNum][13];
newSet = eqArray[newSetNum];
curSet = eqArray[curSetNum];
world.execute("rem all");
world.execute("get " + innerRobe + " " + curRobe);
if (curRobe != newContainer)
{
world.execute("get " + newContainer + " " + innerRobe);
}
if (curRobe != curContainer)
{
world.execute("get " + curContainer + " " + innerRobe);
}
for (i = 1; i < newSet.length; i++)
{
if ((newSet[i] != curSet[i]) & (i != 13) & (i != 19))
{
world.execute("put " + curSet[i] + " " + curContainer);
}
}
world.execute("get all from " + " " + newContainer);
if (newRobe != curContainer)
{
world.execute("put " + curContainer + " " + innerRobe);
}
if ((curRobe != curContainer) & (curRobe != newRobe))
{
world.execute("put " + curRobe + " " + innerRobe);
}
if (newRobe != newContainer)
{
world.execute("put " + newContainer + " " + innerRobe);
}
world.execute("put " + innerRobe + " " + newRobe);
world.execute("wear all");
setCurEQ(newEqSet);
}

Thx for any help :)
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #3 on Sat 25 Oct 2003 06:49 AM (UTC)
Message
I am not familiar with Jscript, and I don't know what code you have outside of that function, but if it were VBS, I might be asking if you are managing the scope of your variables correctly.

That is, variables declared inside a function or subroutine only exist while that routine is in use. If you want to access the value outside your routine, you need to ensure it is a global variable. (This is pretty standard behavior in most programming languages).

BTW, I have an almost identical plugin, written in VBS. Mine is geared towards a mud called "Ages of Despair", altough it would probably be adaptable to other muds. If you are interested, it's on my webpage, the URL is in my sig.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Queso   (5 posts)  Bio
Date Reply #4 on Sat 25 Oct 2003 10:21 AM (UTC)
Message
Magnum,

Everything is this script is handled thru local function scoped variables. If something goes between functions, I just set it as a world variable. My understanding is that world.Get and world.Set variables working for any language, and so does world.SaveState().

As you can see, the function in question is only a 4 lines piece of code, but that is the one that isn't working right - when called from the changeEQ function.

As this point, I am not even sure what debugging I should do to try and find this bug. I think this is more of a MushClient bug than bad jscript?

Thx,
Queso
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #5 on Sun 26 Oct 2003 07:23 AM (UTC)
Message
Can you clarify something? It isn't obvious from your post. Is this script actually in a plugin, or is it running outside a plugin?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #6 on Sun 26 Oct 2003 09:27 AM (UTC)
Message
I notice you are using "world.execute" a fair bit. I suspect the problem is to do with this. Either you are executing something that calls that script, or the way execute works has a bug, but basically when you 'execute' a command you are re-submitting it outside of the context of the current plugin.

For example, if plugin A does "execute X" and X is actually implemented in plugin B, then X will run in the context of plugin B, not plugin A, or no plugin if X is implemented globally.

However what might be happening is that the execute command is discarding the current plugin state, thus leading to the error message you get. One simple approach might be to rearrange the sequence so that your call to the "save state" is done before any execute statements.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #7 on Sun 26 Oct 2003 06:38 PM (UTC)
Message
Why use world.execute and not world.send? If world.execute has all those problems, and all you're sending is plain text (i.e. no aliases or anything) seems to me that that's a much simpler option.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


23,889 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.