Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Variable .value()

Im not very sure about this, but im looking for a way to use the value inside a variable and not the relation with a variable in a set...
I have this code
<<for $MochilaE to 0;...$MochilaE++>>
...
<<click>>
<<set $MochilaEquipado[3]=$MochilaE>> 
<</click>>
<</for>>

But as when i click, the variable have change, the set is wrong and i think i need the for, the click and the set.

For more information, im trying to list an inventory and when click an item, update de value of an array of equiped items. Thats the reason i need a for ( to show all items ), click ( to interact with the player ) and ( set to update ).

I hear ideas guys, im very obfuscated by now -.-

Comments

  • The <<set>> within the <<click>> will assign whatever value $MochilaE equals at the time the user clicks on the link because that is when the <<set>> is evaluated.

    Try replacing everything between the <<click>> and <</click>> (including them as well) in your example with the following:
    <<print "<<click>><<set $MochilaEquipado[3]=" + $MochilaE + ">><</click>>">>
    
  • edited September 2015
    OMG -.- i'm feel stupid...
    Solved, but with a small problem...

    4e8a0007875a8fc22b00682157f4ed.png

    As you can see in the image, a line appears between two atributes or habilities... i have try to insert in the print code a \ or a nobr but seems not work
    <h1>Ficha de personaje</h1>
    <table width="100%" border="1">
      <tr class="celda celdaTitulo celdaEncabezado">
        <td colspan="6">Atributos</td>
      </tr>
      <tr class="celda celdaTitulo">
        <td colspan="2">Fisicos</td>
        <td colspan="2">Sociales</td>
        <td colspan="2">Mentales</td>
      </tr>
     
    
    
     <<for $i=0;$i<$Atributos[0][0].length;$i++>>
        	[i]<<print "<tr class='celda'><td>"+$Atributos[0][0][$i]+"</td><td>"+$Atributos[0][1][$i]+"<<if $Xp>=$Atributos[0][1]["+$i+"]*4>>[[+|Ficha][$Atributos[0][1]["+$i+"]+=1;$Xp-=$Atributos[0][1]["+$i+"]*4]]<<endif>></td><td>"+$Atributos[1][0][$i]+"</td><td>"+$Atributos[1][1][$i]+"<<if $Xp>=$Atributos[1][1]["+$i+"]*4>>[[+|Ficha][$Atributos[1][1]["+$i+"]+=1;$Xp-=$Atributos[1][1]["+$i+"]*4]]<<endif>></td><td>"+$Atributos[2][0][$i]+"</td><td>"+$Atributos[2][1][$i]+"<<if $Xp>=$Atributos[2][1]["+$i+"]*4>>[[+|Ficha][$Atributos[2][1]["+$i+"]+=1;$Xp-=$Atributos[2][1]["+$i+"]*4]]<<endif>></td></tr>">>[/i]
      <</for>>
      
    
    
    <tr class="celda celdaTitulo">
      	<td colspan="2">+</td>
        <td colspan="2">+</td>
        <td colspan="2">+</td>
      </tr>
      <tr class="celda celdaTitulo celdaEncabezado">
        <td colspan="6">Habilidades</td>
      </tr>
      <tr class="celda celdaTitulo">
        <td colspan="2">Talentos</td>
        <td colspan="2">Tecnicas</td>
        <td colspan="2">Conocimientos</td>
      </tr>
       
    
    
    <<for $i=0;$i<$Habilidades[0][0].length;$i++>>
        	<<print "<tr class='celda'><td>"+$Habilidades[0][0][$i]+"</td><td>"+$Habilidades[0][1][$i]+"<<if $Xp>=$Habilidades[0][1]["+$i+"]*4>>[[+|Ficha][$Habilidades[0][1]["+$i+"]+=1;$Xp-=$Habilidades[0][1]["+$i+"]*2]]<<endif>></td><td>"+$Habilidades[1][0][$i]+"</td><td>"+$Habilidades[1][1][$i]+"<<if $Xp>=$Habilidades[1][1]["+$i+"]*2>>[[+|Ficha][$Habilidades[1][1]["+$i+"]+=1;$Xp-=$Habilidades[1][1]["+$i+"]*4]]<<endif>></td><td>"+$Habilidades[2][0][$i]+"</td><td>"+$Habilidades[2][1][$i]+"<<if $Xp>=$Habilidades[2][1]["+$i+"]*2>>[[+|Ficha][$Habilidades[2][1]["+$i+"]+=1;$Xp-=$Habilidades[2][1]["+$i+"]*4]]<<endif>></td></tr>">>
      <</for>>
      
    
    
      <tr class="celda celdaTitulo">
        <td colspan="2">+</td>
        <td colspan="2">+</td>
        <td colspan="2">+</td>
      </tr>
    </table>
    

    The solution for this error, if someone is interested on it, is that the for need to be like this
    </tr>
    <<for>><<print...>><</for>>
    </tr>
    without any line inside the for
  • edited September 2015
    You should not have all of that whitespace in the middle of your table for one. However, the more serious issue is that you were having the <<for>> macro insert an initial line break for every table record.

    Try this: (note the \ after each opening <<for>>)
    <h1>Ficha de personaje</h1>
    <table width="100%" border="1">
      <tr class="celda celdaTitulo celdaEncabezado">
        <td colspan="6">Atributos</td>
      </tr>
      <tr class="celda celdaTitulo">
        <td colspan="2">Fisicos</td>
        <td colspan="2">Sociales</td>
        <td colspan="2">Mentales</td>
      </tr>
    <<for $i=0;$i<$Atributos[0][0].length;$i++>>\
      <<print "<tr class='celda'><td>"+$Atributos[0][0][$i]+"</td><td>"+$Atributos[0][1][$i]+"<<if $Xp>=$Atributos[0][1]["+$i+"]*4>>[[+|Ficha][$Atributos[0][1]["+$i+"]+=1;$Xp-=$Atributos[0][1]["+$i+"]*4]]<<endif>></td><td>"+$Atributos[1][0][$i]+"</td><td>"+$Atributos[1][1][$i]+"<<if $Xp>=$Atributos[1][1]["+$i+"]*4>>[[+|Ficha][$Atributos[1][1]["+$i+"]+=1;$Xp-=$Atributos[1][1]["+$i+"]*4]]<<endif>></td><td>"+$Atributos[2][0][$i]+"</td><td>"+$Atributos[2][1][$i]+"<<if $Xp>=$Atributos[2][1]["+$i+"]*4>>[[+|Ficha][$Atributos[2][1]["+$i+"]+=1;$Xp-=$Atributos[2][1]["+$i+"]*4]]<<endif>></td></tr>">>
    <</for>>
      <tr class="celda celdaTitulo">
        <td colspan="2">+</td>
        <td colspan="2">+</td>
        <td colspan="2">+</td>
      </tr>
      <tr class="celda celdaTitulo celdaEncabezado">
        <td colspan="6">Habilidades</td>
      </tr>
      <tr class="celda celdaTitulo">
        <td colspan="2">Talentos</td>
        <td colspan="2">Tecnicas</td>
        <td colspan="2">Conocimientos</td>
      </tr>
    <<for $i=0;$i<$Habilidades[0][0].length;$i++>>\
      <<print "<tr class='celda'><td>"+$Habilidades[0][0][$i]+"</td><td>"+$Habilidades[0][1][$i]+"<<if $Xp>=$Habilidades[0][1]["+$i+"]*4>>[[+|Ficha][$Habilidades[0][1]["+$i+"]+=1;$Xp-=$Habilidades[0][1]["+$i+"]*2]]<<endif>></td><td>"+$Habilidades[1][0][$i]+"</td><td>"+$Habilidades[1][1][$i]+"<<if $Xp>=$Habilidades[1][1]["+$i+"]*2>>[[+|Ficha][$Habilidades[1][1]["+$i+"]+=1;$Xp-=$Habilidades[1][1]["+$i+"]*4]]<<endif>></td><td>"+$Habilidades[2][0][$i]+"</td><td>"+$Habilidades[2][1][$i]+"<<if $Xp>=$Habilidades[2][1]["+$i+"]*2>>[[+|Ficha][$Habilidades[2][1]["+$i+"]+=1;$Xp-=$Habilidades[2][1]["+$i+"]*4]]<<endif>></td></tr>">>
    <</for>>
      <tr class="celda celdaTitulo">
        <td colspan="2">+</td>
        <td colspan="2">+</td>
        <td colspan="2">+</td>
      </tr>
    </table>
    

    You also don't need to <<print>> the entire chunk of markup. For example, you could write the $Atributos loop a bit more naturally thus:
    <<for $i=0;$i<$Atributos[0][0].length;$i++>>\
      <tr class="celda">
        <td><<print $Atributos[0][0][$i]>></td>
        <td><<print $Atributos[0][1][$i]>><<if $Xp>=$Atributos[0][1]["+$i+"]*4>>[[+|Ficha][$Atributos[0][1]["+$i+"]+=1;$Xp-=$Atributos[0][1]["+$i+"]*4]]<</if>></td>
        <td><<print $Atributos[1][0][$i]>></td>
        <td><<print $Atributos[1][1][$i]>><<if $Xp>=$Atributos[1][1]["+$i+"]*4>>[[+|Ficha][$Atributos[1][1]["+$i+"]+=1;$Xp-=$Atributos[1][1]["+$i+"]*4]]<</if>></td>
        <td><<print $Atributos[2][0][$i]>></td>
        <td><<print $Atributos[2][1][$i]>><<if $Xp>=$Atributos[2][1]["+$i+"]*4>>[[+|Ficha][$Atributos[2][1]["+$i+"]+=1;$Xp-=$Atributos[2][1]["+$i+"]*4]]<</if>></td>
      </tr>
    <</for>>
    
Sign In or Register to comment.