ID:156740
Aug 3 2010, 12:57 pm
|
|
Hey I am making a board game and I want to control how many spaces a player can walk and then restrict them from walking until they roll again. I heard you should do this by affecting the client Move() instead of the mob one. I am finding trouble finding a guide or demo that tracks how many spaces a player has moved. Any Suggestions would be greatly appreciated.
|
In response to Albro1
|
|
Albro1 wrote:
If the players are walking the spaces on their own, then I recommend this: > mob Whenever a player rolls, just set their spaces_to_move to the number of spaces they are allowed to move. I hope you see where I am going with this. Feel free to ask if you are confused. I do follow what you are doing but when I tried something like that it complained that my varible was undefined (in this case spaces_to_move) |
In response to Remaru
|
|
Did you define the variable?
mob |
In response to Albro1
|
|
thanks for your help, i finally got it to work. turns out it was an indentation error of all things lol.
|
In response to Remaru
|
|
You are welcome.
|
In response to Albro1
|
|
That should be:
mob |
In response to Garthor
|
|
Can you please explain the difference between the two please?
I have seen it done both ways, I just want to see the reasoning, if you wouldn't mind. |
In response to Albro1
|
|
if(!X) should only be used if X is a binary (true or false) value. It's defined for other values but it's not good practice to use it like so.
The Move() proc should return a value indicating success or failure. Hence, return 0 to be a bit more explicit about failure, and return ..() to actually return a success value if the move succeeded. Oh, which reminds me that you probably don't want to lose a move if you try to make an invalid one, so I'd also suggest: client/Move() |
In response to Garthor
|
|
Aah, ok. Thanks.
|
In response to Albro1
|
|
I have run into another dilemma. When I am keeping track of the movements if i hit the direction arrow it counts it as a movement even though the location is the same. Is there a way to count moves only when the location changes? I was thinking of creating a process that called move() but that caused an infinite loop lol.
Here is a snippet of what I have so far: client Move() if(mob.Movement <= 0) return 0 mob.Movement-- return ..() |
In response to Garthor
|
|
Wow... I feel so bad im sorry somehow i completely overlooked your post. Thanks for your help
|
Whenever a player rolls, just set their spaces_to_move to the number of spaces they are allowed to move. I hope you see where I am going with this. Feel free to ask if you are confused.