Variables

Posted by Val on Sat 12 Mar 2011 01:10 PM — 11 posts, 38,416 views.

#0
Hi

Two things I am trying to do though I'm not sure if its possible.

I want a miniwindow to show my target or whatever variable I like instead of the status line, though I'm unsure how to do this.

Also can the keypad be adjusted to send a variable, so if I press 0 it will 'cast @thespelliwant on @target'?

It may of been mentioned in the past and I have searched, but can't find it, if you can point me in the right direction it would be appreciated.

Val
Australia Forum Administrator #1
Val said:

I want a miniwindow to show my target or whatever variable I like instead of the status line, though I'm unsure how to do this.


Template:function=SetStatus
SetStatus

The documentation for the SetStatus script function is available online. It is also in the MUSHclient help file.




Val said:

Also can the keypad be adjusted to send a variable, so if I press 0 it will 'cast @thespelliwant on @target'?


I think the simplest way to do this is to make an alias, like this:


<aliases>
  <alias
   match="keypad_0"
   enabled="y"
   expand_variables="y"
   sequence="100"
  >
  <send>cast @thespelliwant on @target</send>
  </alias>
</aliases>


Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


Now set keypad 0 to send "keypad_0".

The alias catches that, and sends the spell you want.
#2
Thank you for the keypad_0, works well.

I already use the status line, and wanted to see if I could place that information on a miniwindow instead, just a little more noticeable for me

Also if you use the statue line for something else, the last piece of information on it goes, so if I want to have a few things on it, I would have to make the statue line quite long -

Target : attacker / Spell Magic missile / Exits north southwest,,

you get the idea, I know you can make the exits go on a miniwindow, just would of been nice to see the target and spell on it and make it a little bigger and brighter.

It's no biggie though

Thanks for the above, appreciated


Val
Australia Forum Administrator #3
This video shows how to do that:

http://www.gammon.com.au/forum/?id=9626
#4
Hi

I have two variables, target and spellname.

The code for target works well enough, I managed to make a small window where the target is displayed (though I have not mastered moving it yet).

My problem is some spells are cast on the character, though I have managed to alter the variables in the spell to do this, I cannot get the miniwindow to refresh to show the new variable (me).

this is what I have to target -

SetVariable ("target", "%1")


local spellname1 = GetVariable("spellname1")
local target = GetVariable("target")

ColourNote ("white", "blue", "Spell is still: " .. spellname1)
ColourNote ("white", "blue", "Target is now: " .. target)

SetStatus ("Target: " .. target, " / Spell: " .. spellname1)

win = GetPluginID ( ) .. ":targetwindow"

font = "f"

WindowCreate ( win, 0, 0, 1, 1, 9, 0, 0)

WindowFont ( win, font, "Couier", 10)

height = WindowFontInfo ( win, font, 1) + 10

width = WindowTextWidth ( win, font, "Target is: " .. target) + 10

WindowCreate ( win, 0, 0, width, height, 9, 0, ColourNameToRGB ( "salmon"))

WindowText ( win, font, "Target is: " .. target, 5, 5, 0, 0, ColourNameToRGB ( "yellow"))

WindowShow ( win, true)

Typing in t attacker will set that target and ill appear in the miniwindow

And this is for my spells so typing arm gives-

SetVariable ("spellname1", "armor")

SetVariable ("target", "me")

local spellname1 = GetVariable("spellname1")
local target = GetVariable("target")
SetStatus ("Target: " .. target," / Spell: " .. spellname1)

ColourNote ("white", "blue", "Spell is now: " .. spellname1)
ColourNote ("white", "blue", "Target is still: " .. target)

world.Execute ("t " .. target (just added after I first made this post)

Though the spell and targets are correct and it works when I cast the spell, I cant get the targetwindow to refresh.
I've tried WindowShow ("targetwindow", true) which does not come up with an eror, but it does not refresh the target window.


Any advise on where I'm going wrong?


For the moment I'm using - "world.Execute ("t " .. target) at the end of the spellname alias (just discovered it after writing this) I would like to know if there is a better method

Thanks
Val
Amended on Sat 19 Mar 2011 02:29 PM by Val
Australia Forum Administrator #5
To save me trying to put all that together to test it, can you please copy the two aliases like this? ...

Template:copying
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.

#6
Hi

Hopefully as below

This is my target


<aliases>
  <alias
   match="t *"
   enabled="y"
   expand_variables="y"
   group="Target"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable ("target2", "%1")


local spellname1 = GetVariable("spellname1")
local target2 = GetVariable("target2")

ColourNote ("white", "blue", "Spell is still: " .. spellname1)
ColourNote ("white", "blue", "Target is now: " .. target2)

SetStatus ("Target: " .. target2, " /  Spell: " .. spellname1)

win = GetPluginID ( ) .. ":targetwindow"

font = "f"

WindowCreate ( win, 0, 0, 1, 1, 9, 0, 0)



WindowFont ( win, font, "Couier", 10)
  
height = WindowFontInfo ( win, font, 1) + 10

width = WindowTextWidth ( win, font,  "Target is: " .. target2) + 10



WindowCreate ( win, 0, 0, width, height, 9, 0, ColourNameToRGB ( "salmon"))

WindowText ( win, font, "Target is: " .. target2, 5, 5, 0, 0, ColourNameToRGB ( "yellow"))

WindowShow ( win, true)

</send>
  </alias>
</aliases>


This is one I use to cast on a me



<aliases>
  <alias
   match="arm"
   enabled="y"
   expand_variables="y"
   group="mage"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable ("spellname1", "armor")


SetVariable ("targetme", "me")

local spellname1 = GetVariable("spellname1")
local target = GetVariable("targetme")
SetStatus ("Target: " .. targetme," /  Spell: " .. spellname1)

ColourNote ("white", "blue", "Spell is now: " .. spellname1)
ColourNote ("white", "blue", "Target is : " .. targetme)
</send>
  </alias>
</aliases>


and this is one for a mob


<aliases>
  <alias
   match="aa"
   enabled="y"
   expand_variables="y"
   group="mage"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable ("spellname1", "acid arrow")



SetVariable ("targetme", "not me")

local spellname1 = GetVariable("spellname1")
local target2 = GetVariable("target2")
SetStatus ("Target: " .. target2," /  Spell: " .. spellname1)

ColourNote ("white", "blue", "Spell is now: " .. spellname1)
ColourNote ("white", "blue", "Target is still: " .. target2)

world.Execute ("t " .. target2)</send>
  </alias>
</aliases>


This is to let me use one alias to cast spells where it knows the difference between spells I cast on me and mobs with an option of casting a spell normally for me (a heal) to a friend, hence the if post I made


<aliases>
  <alias
   match="keypad_0"
   enabled="y"
   expand_variables="y"
   group="cast"
   send_to="12"
   sequence="100"
  >
  <send>

local x = GetVariable("targetme")

local spellname = GetVariable("spellname1")
local targetme = GetVariable("targetme")

local target2 = GetVariable ("target2")

if x == "me" then Send ("cast "  .. spellname, " on " .. targetme)

else
Send ("cast "  .. spellname, " on " .. target2)
end
</send>
  </alias>
</aliases>


With this done I will have to figure out how to move the target box in the 't *' and then see if I can master the inventory problem I have with the line.

Thank you for your help
val
Amended on Sun 20 Mar 2011 11:04 AM by Val
Australia Forum Administrator #7
It changed for me. What I suspect is happening is that you have two miniwindows, one on top of the other, and the one underneath is changing. Try closing the world completely (to get rid of the windows) and try again. I moved the target to the top right corner by changing the position parameter:


<aliases>
  <alias
   match="t *"
   enabled="y"
   expand_variables="y"
   group="Target"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable ("target2", "%1")


local spellname1 = GetVariable("spellname1")
local target2 = GetVariable("target2")

ColourNote ("white", "blue", "Spell is still: " .. spellname1)
ColourNote ("white", "blue", "Target is now: " .. target2)

SetStatus ("Target: " .. target2, " /  Spell: " .. spellname1)

win = GetPluginID ( ) .. ":targetwindow"

font = "f"

WindowCreate ( win, 0, 0, 1, 1, 9, 0, 0)



WindowFont ( win, font, "Couier", 10)
  
height = WindowFontInfo ( win, font, 1) + 10

width = WindowTextWidth ( win, font,  "Target is: " .. target2) + 10



WindowCreate ( win, 0, 0, width, height, miniwin.pos_top_right, 0, ColourNameToRGB ( "salmon"))

WindowText ( win, font, "Target is: " .. target2, 5, 5, 0, 0, ColourNameToRGB ( "yellow"))

WindowShow ( win, true)

</send>
  </alias>
</aliases>



Oh, and you misspelt "Courier" as "Couier". That won't give you Courier.
#8
Hi

The aa alias will change it because of the world.Execute ("t " .. target2) but the arm alias won't change it, and if I try world.Execute ("t " .. targetme) then it changes the variable target2 as well.

So by going 't attacker' target2 changes to attacker, when I go arm, I get -targetme me- but if I add the world.Execute as above and use arm alias then target2 also becomes me

I was thinking if it was a WindowShow or some kind of refresh command it might help

And thanks the Courier, never noticed, too busy looking at the program itself

Val
Australia Forum Administrator #9
Val said:

... but the arm alias won't change it ...


The arm alias doesn't change the miniwindow at all.

I think you are getting into a bit of a muddle here. You really want a function (or an alias maybe) that simply updates the miniwindow. Then call that from various spots.
#10
Hi Nick

Yes thats what I want, a means of refreshing the window, though I dont know how to go about it, any chance of pointer please?

Thank you
Val