PDA

View Full Version : Changing Token Rotation



Magnatude
November 16th, 2011, 01:32
Hey all... I know there was a post asking about this about 2 years ago...

But is there any way to change the behaviour of the rotation of tokens?

I'm attempting to create a "Car Wars" for FG2, and I need to change the rotational increments to 15 degrees (I think the current is 45)

Any possible way to have this lua scripted yet??? Pleeeeze?
This would make adapting the rules for more rulesets that require counter/tokens to be facing during combat (like ships and firing arcs)
In Car wars (a Steve Jackson game from the 80's) the cars move and face in 15 degree angles during movements

wbcreighton
November 19th, 2011, 01:20
Would the token frames be of any use:

https://www.fantasygrounds.com/forums/showthread.php?t=15216

I could see having a token with a frame for each angle of rotation.


Oh and Car Wars! Let me know when you get it running, I loved playing that game.

Just don't fail your next Handling roll!

Zeus
November 19th, 2011, 08:27
To change the default token orientation count you may want to take a look at the following method for an imagecontrol: setTokenOrientationCount( count )

setTokenOrientationCount sets the number of different token orientations available in the imagecontrol, evenly spread out along a full revolution.

So for 15 degree angles, try calling the method with a count value of 24 (360/15) in the imagecontrol's onInit() function:


setTokenOrientationCount(24)

Magnatude
November 21st, 2011, 05:05
Awesome, thanks for all of your help. the Frames script as well as the rotation both are very useful.

phantomwhale
November 22nd, 2011, 04:24
The rulesets (4E and SWEX at least) support hex maps, so along with the image rotation code is a bunch of other "non-square gird" mathematics (distance measuring etc...) and tricks all in the same file. Worth a look.

Car Wars, eh ? Would love to see a copy of that in action ! It's another one of those "used to play all the time, 20 years ago, when I had more time and nearby gamer friends" games that NEEDS a good internet engine behind it. Esp. as it had a lot of fiddlyness of rules that could be nicely streamlined inside FGII.

Would love to see what comes of this, even help out a little if your interested ?

Moebius
December 7th, 2011, 13:43
Sorry for the dumb question, I dont have a clue on ruleset but I am trying to modify/include that token rotation finer control into the foundation ruleset, what file should I look for? I am guessing this is already defined somewhere...

Moon Wizard
December 10th, 2011, 00:30
The function that controls the number of points on the token rotation is called setTokenOrientationCount. You can search through the existing ruleset files to find the places where it is set. (8 = standard square grid, 12 = standard hex grid)

Cheers,
JPG

Moebius
December 10th, 2011, 08:39
Thx! I found it now using the exact string :-)... the search tool I was using didnt work well.

Griogre
December 10th, 2011, 19:10
The DOS console "find" command it very good for this type of thing, where you are looking for a string but have no idea what file it is. You can search the whole directory easily. Usually I'll search the whole directory with the /c command and then when I find the files with more than 0 count I'll search each file again with the /n option to get the line numbers in the file where they are. Here's a link to the syntex: https://www.computerhope.com/findhlp.htm

Note despite the name these commands are work in all versions of Windows after Win3X. You just have to open a console window and it's easiest to do that in the directory you want to search.

Trenloe
December 12th, 2011, 00:01
Another great way to find what you're looking for across multiple files is the "Find in files" functionality in a number of text editors. A few people on these forums use Notepad++ (a GPL multiple-document text editor with text highlighting for LUA and XML files and xml plugins) which has this search in files facility. The search result window even allows you to double-click on the specific result and it will open up the relevant document - at the line which you clicked on. Very, very handy for tracking down where FG functionality is coded and referenced.

phantomwhale
December 12th, 2011, 00:04
Another great way to find what you're looking for across multiple files is the "Find in files" functionality in a number of text editors. A few people on these forums use Notepad++ (a GPL multiple-document text editor with text highlighting for LUA and XML files and xml plugins) which has this search in files facility. The search result window even allows you to double-click on the specific result and it will open up the relevant document - at the line which you clicked on. Very, very handy for tracking down where FG functionality is coded and referenced.

+1 - wouldn't code FGII stuff without it.

Stitched
January 11th, 2017, 17:32
Deprecated thread but is there a reason Fantasy Grounds doesn't allow customization of rotation for it's tokens? Seems something that should be in-built?

Trenloe
January 11th, 2017, 17:35
Deprecated thread but is there a reason Fantasy Grounds doesn't allow customization of rotation for it's tokens? Seems something that should be in-built?
It does allow customisation of the rotation, and this is mentioned in post #3 of this thread. The API command is detailed here: https://www.fantasygrounds.com/refdoc/imagecontrol.xcp#setTokenOrientationCount

Stitched
January 11th, 2017, 18:34
This is not an "option" or "setting in FG - this is altering code directly. Not the same thing.

Bidmaron
January 11th, 2017, 19:03
Stitched, what ruleset are you wanting this for? If it isn't a requirement in the relevant rules, you are unlikely to see this, as providing a user-friendly implementation in the user interface is a non-trivial affair.

Stitched
January 11th, 2017, 19:06
Using 5e - trying to find the entry in the ruleset and Notepad++ isn't finding any reference.

Bidmaron
January 11th, 2017, 19:12
If it were required, it would already be there. If it isn't then I would argue that since you are the first to ask (that I know of), it isn't worth doing. Forgive me, but I am not a5e guy.

Stitched
January 11th, 2017, 19:15
Reading other threads, it sounded like it was added to the Foundation Core...strange that it doesn't exist across the board.

Bidmaron
January 11th, 2017, 19:21
It isn't in most ruleset so why should it be? FG can do it, but, as I said, an easy-to-use interface is non-trivial and therefore since most don't care about it, it doesn't exist any the more popular rulesets as far as I know.

Trenloe
January 11th, 2017, 19:36
This is not an "option" or "setting in FG - this is altering code directly. Not the same thing.
Sorry for the misunderstanding, but for me "customization" usually refers to altering code. "Configuration" is normally used to refer to available options, such as the FG campaign options: https://www.fantasygrounds.com/wiki/index.php/Options

Anyway, that's just semantics - glad you've clarified what you were actually looking for. :)

You won't find a reference to this in the ruleset because all image controls will use the default. Oh, and it will be in CoreRPG, not 5E - because 5E is built on top of CoreRPG.

There's a setTokenOrientationMode call in the onInit function of the CoreRPG campaign\scripts\images.lua file. You could try adding in a setTokenOrientationCount command at the same point, with the default parameter you're looking for. But this would be a set value for all images, you'd need to do more coding if you wanted to change it on a image-by-image basis.

Moon Wizard
January 11th, 2017, 19:39
Stitched,

Perhaps if you explain the purpose, it may help.

Currently, the tokens use an 8-point rotation, since D&D is generally is built upon the concept of a square grid for tactical encounters, and 8 points covers the 4 sides and the 4 corners of each grid square for racing. When using a grid hex, the token rotation switches to 12-points. For squares, I would say that you could model less than 8, just by not using diagonal facings, and any more than 8 would become hard to manage from an interface perspective. (i.e. at 32 points, you would be guessing whether you are at point 14 or 15, and it probably wouldn't make much difference.

At any rate, it would need to be built as an extension to enable something different than the base behavior.

Regards,
JPG

Bidmaron
January 11th, 2017, 19:41
Maybe I am still confused, but I think he is asking why it isn't supported in the 5e ruleset already and not how he would go about it

Zacchaeus
January 11th, 2017, 19:51
Token facing is supported in 5e but I think the OP is looking for something different. Perhaps, as Moon Wizard asks you could expand on what it is you want to do.

Naroe
May 25th, 2019, 11:55
To change the default token orientation count you may want to take a look at the following method for an imagecontrol: setTokenOrientationCount( count )

setTokenOrientationCount sets the number of different token orientations available in the imagecontrol, evenly spread out along a full revolution.

So for 15 degree angles, try calling the method with a count value of 24 (360/15) in the imagecontrol's onInit() function:


setTokenOrientationCount(24)


I'm interested in a solution to this as well as I use hex maps. a count of 24 is good as it will suit square and hex maps. I have spent some time trying to understand the code that CORE uses to open an image but to no avail. Still get global nil value error in every location I think the setTokenOrientationCount should go. Did anyone ever post a solution.

Ignore me, I found an extention I had was overiding the image.lua file so nothing i did seemed to work. sorted now