[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Variable problems
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Variable problems

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


Posted by Dragonlord   (24 posts)  [Biography] 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
[Go to top] top

Posted by Dragonlord   (24 posts)  [Biography] 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
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] 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
[Go to top] top

Posted by Dragonlord   (24 posts)  [Biography] 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.
[Go to top] top

Posted by hogarius   USA  (22 posts)  [Biography] 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.
[Go to top] 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.


1,449 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]