Jump to content

How to set a variable to be a function of another variable


Landsbanki

Recommended Posts

I'm building a Top Trumps cartridge. I need to keep track of how many cards the player has and how many cards the non-player opponent has so I can structure the order of cards in each hand. One is a simple function of the other. So if the pack has 48 card and the player has 15 cards then the opponent has 48 minus15 cards. I'm using the Earwigo. I can't find a way of implementing this calculation. You can set a variable to be the same as another variable and you can increment by fixed amounts but what you don't seem to be able to do if increment by a function of a another variable. There is a function tab which I use a lot but I've not yet understood what the parameter x component of it is. The wiki for this section is still under construction. I'm wondering if this is something I can do using the function option. Any help would be gratefully received as at the moment I'm having to have two completely independent variables which is increasing the amount of code and also allows for increased chance of errors.

Link to comment

In Earwigo, you can take advantage of the "Lua statement" to achieve this.

 

Don't forget that you'll have to prefix your variables' names by "var_" (if you didn't change this in the cartridge's properties).

 

For example, if your variables are named player_hand and opponent_hand, you could write this "Lua statement" :

 

var_opponent_hand = 48 - var_player_hand

 

Edited by Tungstène
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...