how to change variable in mudlet terminal! HELP

Digital Ninja
Posts: 26
Joined: Mon Jun 07, 2010 1:43 am

how to change variable in mudlet terminal! HELP

Post by Digital Ninja »

Hello everyone... I haven't actually played MUD in years... back then i used zMud. however, i'm now on a mac. I found mudlet and am trying to get it to work.

my problem is this. i really can't figure out how to be setting up my aliases/triggers/scripts... I watched the videos and read some tutorials but couldn't find the answer to some of the basic stuff.

Example:
i read the guide, and it talked about breaking things into a lot of scripts... and declaring variables in the scripts.
however, if i make a bunch of scripts, that hold my variables... if i want to change that variable from within the "mudlet terminal" how do i do that?

quick example:
i have a script called target:
Code: [show] | [select all] lua
tar = "bob"
what if i want to change the target variable from in the mudlet terminal? i can't find a way to do this. i don't want to have to go to the actual script each time just to change the variable. so example. say i want to change the target to "the_dude"... how can i do that?

i tried stuff in the command line like: tar = "dude"
tar = dude
tar dude

and it just throws "the i don't get it" message.

help please would be fantastic!

Here is the basic process if have tried. so far it seems VERY lengthy just to be able to target a spell.
so say for a simple example. i want to cast an armor spell on my target.
i've gone in many circles on how to get this to work.

i created a some folders:
global
variable definitions
free functions

like i saw in the guide.

in the variable defs folder, i created a script called: target
the script body says:
tar = "bob"

i then scavenged around and found a suggestion for alias/script functions to handle targets that have been declared or a target that is declared during the command.

example:
i created an alias called: armor
Code: [show] | [select all] lua
pattern: ^csa(\s(\w+))?$
body: send("cast 'armor'" ..targ(matches[3] or t))
i then created a script in the free functions folder called: Target
Code: [show] | [select all] lua
function targ( t )
   if t == nil then
      return " " ..tar
   else
      return " " ..t
   end
end

Digital Ninja
Posts: 26
Joined: Mon Jun 07, 2010 1:43 am

Re: how to change variable in mudlet terminal! HELP

Post by Digital Ninja »

and also while i'm thinking about it:

in my scripts folder:
i've created a script for each variable to be set:
enemy
me
food
water
target

but like i posted earlier... i just can't figure out how i'm supposed to change these variables from within the mudlet terminal... i don't feel i'm setting this stuff up right.

for example:
i have in the scripts folder --> free functions folder:
Eat Food
Drink Water

Drink Water for example looks like this:
Code: [show] | [select all] lua
function dw()
	send("get " ..water.. " from sack")
	send("drink " ..water)
	send("put " ..water.. " in sack")
end
..water is referencing the variable script called water which is simply water = "waterskin"

but say, i want to drink water from bottle?
usually, in the olden days, i could just type in my terminal: water = bottle... and everything would work as usual. this isn't the case in here though. i can't seem to type water = bottle in the terminal.

so, what is the best way to do these variable assignments?

Cheers,
Thanks,
J

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: how to change variable in mudlet terminal! HELP

Post by Vadi »

Import http://forums.mudlet.org/viewtopic.php?f=8&t=100, type lua water = "bottle" in the input line.

Digital Ninja
Posts: 26
Joined: Mon Jun 07, 2010 1:43 am

Re: how to change variable in mudlet terminal! HELP

Post by Digital Ninja »

hey thanks for the fast reply...

i think i may have stumbled on a different approach. could you tell me if there is anything wrong with this?
i created an alias called: target
Code: [show] | [select all] lua
patter: ^tar(.*)$
Code: [show] | [select all] lua
tar = matches[2]
echo("The target is" ..tar)
i can then type: tar bob in the terminal...
and use my armor spell from above... that is csa.

if i do:
tar bob
csa
the armor casts on bob

if i do:
tar thedude
csa
the armor casts on thedude

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: how to change variable in mudlet terminal! HELP

Post by Vadi »

Nope... in fact that's what the video quite plainly describes to do. You might want to put a space after ^tar though.

Digital Ninja
Posts: 26
Joined: Mon Jun 07, 2010 1:43 am

Re: how to change variable in mudlet terminal! HELP

Post by Digital Ninja »

great thanks... i'm just trying to get the hang of it.

another one for you if you don't mind a little more of your time:
i'm trying to set up a way to have aliases for individual spells. or if you know i'm going to cast the same spell a lot, i want to have an alias for cs... cast spell...

so example:
i made an alias called: New Spell...
Code: [show] | [select all] lua
pattern: ^ns(.*)$
Code: [show] | [select all] lua
body: ns = matches[2]
echo("The new spell is" ..ns)
then i made an alias called: Cast Spell:
Code: [show] | [select all] lua
pattern: ^cs(\s(\w+)(\w+))?$
Code: [show] | [select all] lua
send("cast '" ..newSpell(matches[3] or nsp) "' on " ..targ(matches[4] or t))
the two functions: are scripts... newSpell and targ...

newSpell is:
Code: [show] | [select all] lua
function newSpell( nsp )
   if nsp == nil then
      return " " ..ns
   else
      return " " ..nsp
   end
end
targ is this:
Code: [show] | [select all] lua
function targ( t )
   if t == nil then
      return " " ..tar
   else
      return " " ..t
   end
end
i'm unable to get it to work. when i type:
ns armor

then

tar bob

then cs

nothing happens. cs (my cast spell alias) does not do anything. you have any ideas as to why?

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: how to change variable in mudlet terminal! HELP

Post by Vadi »

nope, check press the errors button bottom-right in the script editor and see what errors show up when you use the aliases. then we'll tell

Digital Ninja
Posts: 26
Joined: Mon Jun 07, 2010 1:43 am

Re: how to change variable in mudlet terminal! HELP

Post by Digital Ninja »

i noticed something... when i click the little error button *mine is on the left hand pannel*... the script editor splits... the bottom part where the error is shown is very small, and when i try and resize it, it only let's me make the bottom section a "very small" height. i can't adjust the resize all the way.

also i cannot "select all", and if i try and scroll and copy the error, i can't. so i am going to have to do tiny 5 line slivers at a time and copy and paste it:... here it goes:

not sure how to clear the errors and output new errors. i'm hoping some of those were fixed by now. i'm thinking the cs section is more the "bottom" lines of errors though hopefully
Code: [show] | [select all] lua
 new session ***

[ERROR:] object:<Endure> function:<Alias3>
         <[string "function Alias3()..."]:2: attempt to call global 'tar' (a string value)>
[ERROR:] object:<Drink> function:<Trigger3>
         <wrong argument type>
[ERROR:] object:<Drink> function:<Trigger3>
         <wrong argument type>
[ERROR:] object:<Drink> function:<Trigger3>
         <wrong argument type>
[ERROR:] object:<Drink> function:<Trigger3>
         <wrong argument type>
[ERROR:] object:<Drink> function:<Trigger3>
         <wrong argument type>
[ERROR:] object:<Drink> function:<Trigger3>
         <wrong argument type>
[ERROR:] object:<Drink> function:<Trigger3>
         <wrong argument type>
[ERROR:] object:<Drink> function:<Trigger3>
         <wrong argument type>
[ERROR:] object:<Drink> function:<Trigger3>
         <wrong argument type>
[ERROR:] object:<Drink> function:<Trigger3>
         <wrong argument type>
[ERROR:] object:<Drink> function:<Trigger3>
         <wrong argument type>
[ERROR:] object:<Drink> function:<Trigger3>
         <wrong argument type>
[ERROR:] object:<Drink> function:<Trigger3>
         <wrong argument type>
[ERROR:] object:<Drink> function:<Trigger3>
         <wrong argument type>
[ERROR:] object:<Drink> function:<Trigger3>
         <[string "function dw()..."]:2: attempt to call global 'water' (a string value)>
[ERROR:] object:<Drink> function:<Trigger3>
         <[string "function dw()..."]:2: attempt to call global 'water' (a string value)>
[ERROR:] object:<Drink> function:<Trigger3>
         <[string "function dw()..."]:2: attempt to call global 'water' (a string value)>
[ERROR:] object:<Drink> function:<Trigger3>
         <[string "function dw()..."]:2: attempt to call global 'water' (a string value)>
[ERROR:] object:<Drink> function:<Trigger3>
         <[string "function dw()..."]:2: attempt to call global 'water' (a string value)>
[ERROR:] object:<Drink> function:<Trigger3>
         <[string "function dw()..."]:2: attempt to call global 'water' (a string value)>
[ERROR:] object:<Drink> function:<Trigger3>
         <[string "function dw()..."]:2: attempt to call global 'water' (a string value)>
[ERROR:] object:<Drink> function:<Trigger3>
         <[string "function dw()..."]:4: attempt to call global 'water' (a string value)>
[ERROR:] object:<Drink> function:<Trigger3>
         <[string "function dw()..."]:4: attempt to call global 'water' (a string value)>
[ERROR:] object:<Armor> function:<Alias2>
         <[string "function targ( t )..."]:3: attempt to perform arithmetic on a string value>
[ERROR:] object:<Armor> function:<Alias2>
         <[string "function targ( t )..."]:3: attempt to perform arithmetic on a string value>
[ERROR:] object:<Food> function:<Alias16>
         <[string "function Alias16()..."]:3: attempt to concatenate global 'food' (a nil value)>
[ERROR:] object:<Food> function:<Alias16>
         <[string "function Alias16()..."]:3: attempt to concatenate global 'food' (a nil value)>
[ERROR:] object:<Cast Spell> function:<Alias1>
         <[string "function Alias1()..."]:2: attempt to call a string value>
[ERROR:] object:<Cast Spell> function:<Alias1>
         <[string "function Alias1()..."]:2: attempt to call a string value>
[ERROR:] object:<Cast Spell> function:<Alias1>
         <[string "function Alias1()..."]:2: attempt to call a string value>
[ERROR:] object:<Cast Spell> function:<Alias1>
         <[string "function Alias1()..."]:2: attempt to call a string value>


Digital Ninja
Posts: 26
Joined: Mon Jun 07, 2010 1:43 am

Re: how to change variable in mudlet terminal! HELP

Post by Digital Ninja »

hmmm i also noticed something wonky with my code...
right now i'm trying to give it the option to:

1. cast the spell with current ns and tar (spell and target)
ns armor
tar bob
cs
result:
cast armor on bob

2. cast the spell with new set spell and target
cs armor bob
result:
cast armor on bob

BUT...
I forgot about if i want to leave one of the variables blank..
say:
cs bob
hmmmm....
i'm assuming it will think that means bob is the ns (new spell)... and then will assume that last option is blank and use whatever the current target is...
result:
cast bob on bob

not good.

LOL
Cheers
Jonathan

Digital Ninja
Posts: 26
Joined: Mon Jun 07, 2010 1:43 am

Re: how to change variable in mudlet terminal! HELP

Post by Digital Ninja »

i feel like it has something to do with the body: and the single quote and double quote.
to cast a spell in the mud... it has to be like
Code: [show] | [select all] lua
cast 'armor' bob
in my alias for cs i have this:
Code: [show] | [select all] lua
pattern: ^cs(\s(\w+)(\w+))?$
Code: [show] | [select all] lua
send("cast '" ..newSpell(matches[3] or nsp) "' on " ..targ(matches[4] or t))
not really sure tho.
thanks,
j

Post Reply