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 ➜ Lua ➜ Variable problems

Variable problems

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


Posted by Dragonlord   (24 posts)  Bio
Date Sat 25 Mar 2017 05:13 PM (UTC)
Message
<triggers>
<trigger
custom_colour="2"
enabled="y"
group="Blackjack"
ignore_case="y"
match="^Your current total is\: (.*?)\|Your current total is\: (.*?) \(soft\)$"
regexp="y"
send_to="12"
sequence="100"
variable="bjtotal"
>
<send>SetVariable ("bjtotal", "%1")
SetStatus ("Your current total is: %1")
</send>
</trigger>
</triggers>

Your current total is: 14 <--- this variable is frozen to this number and not changing to
a new number. I can't find where to make the adjustment.
<triggers>
<trigger
enabled="y"
group="Blackjack"
keep_evaluating="y"
match="^(A blackjack dealer asks, ){0,1}'Will you hit,{0,1} (or ){0,1}stay,{0,1}( or double down){0,1},{0,1} Lyneirari\?'( a blackjack dealer asks\.){0,1}$"
regexp="y"
send_to="10"
sequence="100"
>
<send>Blackjack_Game</send>
</trigger>
</triggers>

<aliases>
<alias
match="Blackjack_Game"
enabled="y"
echo_alias="y"
group="Blackjack"
variable="bjtotal"
send_to="12"
ignore_case="y"
keep_evaluating="y"
sequence="100"
>
<send>local bjtotal

bjtotal = tonumber (GetVariable("bjtotal"))

if bjtotal &lt;= 12 then
Send ("say hit")
elseif bjtotal &gt;= 13 then
Send ("say stay")
end</send>
</alias>
</aliases>

Run-time error
World: Materia Magica GMCP
Immediate execution
[string "Alias: "]:5: attempt to compare nil with number
stack traceback:
[string "Alias: "]:5: in main chunk
Top

Posted by Dragonlord   (24 posts)  Bio
Date Reply #1 on Sun 26 Mar 2017 03:19 AM (UTC)
Message

<aliases>
<alias
match="Blackjack_Game"
enabled="y"
echo_alias="y"
group="Blackjack"
variable="bjtotal"
send_to="12"
ignore_case="y"
keep_evaluating="y"
sequence="100"
>
<send>local bjtotal

bjtotal = tonumber (GetVariable("bjtotal"))

if bjtotal &lt;= 12 then
Send ("say hit")
elseif bjtotal &gt;= 13 then
Send ("say stay")
end</send>
</alias>
</aliases>




<triggers>
<trigger
custom_colour="2"
enabled="y"
group="Blackjack"
ignore_case="y"
match="^Your current total is\: (.*?)\|Your current total is\: (.*?) \(soft\)$"
regexp="y"
send_to="12"
sequence="100"
variable="bjtotal"
>
<send>SetVariable ("bjtotal", "%1")
SetStatus ("Your current total is: %1")
</send>
</trigger>
</triggers>


Your current total is: 14 <--- this variable is frozen to this number and not changing to a new number. I can't find where to make the adjustment.


<triggers>
<trigger
enabled="y"
group="Blackjack"
keep_evaluating="y"
match="^(A blackjack dealer asks, ){0,1}'Will you hit,{0,1} (or ){0,1}stay,{0,1}( or double down){0,1},{0,1} Lyneirari\?'( a blackjack dealer asks\.){0,1}$"
regexp="y"
send_to="10"
sequence="100"
>
<send>Blackjack_Game</send>
</trigger>
</triggers>


Run-time error
World: Materia Magica GMCP
Immediate execution
[string "Alias: "]:5: attempt to compare nil with number
stack traceback:
[string "Alias: "]:5: in main chunk
Top

Posted by Fiendish   USA  (2,558 posts)  Bio   Global Moderator
Date Reply #2 on Sun 26 Mar 2017 12:03 PM (UTC)

Amended on Sun 26 Mar 2017 12:05 PM (UTC) by Fiendish

Message
Template:codetag To make your code more readable please use [code] tags as described here.


Quote:
attempt to compare nil with number


This is your error message, and it's only caused by one thing (comparing nil with a number).

You would get the same message if you did
print(nil <= 12)


Why do you have those variable="bjtotal" lines all over?

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Dragonlord   (24 posts)  Bio
Date Reply #3 on Sun 26 Mar 2017 04:45 PM (UTC)
Message

<aliases>
  <alias
   match="Blackjack_Game"
   enabled="y"
   echo_alias="y"
   group="Blackjack"
   variable="bjtotal"
   send_to="12"
   ignore_case="y"
   keep_evaluating="y"
   sequence="100"
  >
  <send>local bjtotal 

bjtotal = tonumber (GetVariable("bjtotal"))

if bjtotal &lt;= 12 then
  Send ("say hit")
elseif bjtotal &gt;= 13 then
  Send ("say stay")
end</send>
  </alias>
</aliases>


The variable bjtotal belong to this alias


<triggers>
  <trigger
   enabled="y"
   group="Blackjack"
   keep_evaluating="y"
   match="^(A blackjack dealer asks, ){0,1}'Will you hit,{0,1} (or ){0,1}stay,{0,1}( or double down){0,1},{0,1} Lyneirari\?'( a blackjack dealer asks\.){0,1}$"
   regexp="y"
   send_to="10"
   sequence="100"
  >
  <send>Blackjack_Game</send>
  </trigger>
</triggers>


This trigger calls to Blackjack_Game


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   group="Blackjack"
   ignore_case="y"
   match="^Your current total is\: (.*?)\|Your current total is\: (.*?) \(soft\)$"
   regexp="y"
   send_to="12"
   sequence="100"
   variable="bjtotal"
  >
  <send>SetVariable ("bjtotal", "%1")
SetStatus ("Your current total is: %1")
</send>
  </trigger>
</triggers>


This trigger handles the player card total the player is holding.

the problem is SetStatus ("Your current total is: %1") is not changing if another is dealt, or new game.
Top

Posted by hogarius   USA  (22 posts)  Bio
Date Reply #4 on Mon 27 Mar 2017 01:44 PM (UTC)

Amended on Mon 27 Mar 2017 02:14 PM (UTC) by hogarius

Message
<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   group="Blackjack"
   ignore_case="y"
   match="^Your current total is\: (.*?)\|Your current total is\: (.*?) \(soft\)$"
   regexp="y"
   send_to="12"
   sequence="100"
   variable="bjtotal"
  >
  <send>SetVariable ("bjtotal", "%1")
SetStatus ("Your current total is: %1")
</send>
  </trigger>
</triggers>


I think your match line may have an extra backslash in it, before the `|` pipe symbol.
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.


21,844 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.