Variable problems

Posted by Dragonlord on Sat 25 Mar 2017 05:13 PM — 5 posts, 23,021 views.

#0
<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
#1

<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
USA Global Moderator #2
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?
Amended on Sun 26 Mar 2017 12:05 PM by Fiendish
#3

<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.
USA #4
<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.