PDA

View Full Version : Creating a Deck of Cards, need a reference point



Lorddamax
August 27th, 2007, 14:23
I am going to be adding Gamemastery's Critical Hit Deck into my FG ruleset.

I know with FG2 there is scripting, I've been waiting for FG2 to come out to do that.

What I need is some start point, a reference to look at to get me started. Something that shows you clicking a button, and the game showing an image. I found the scripting and XML references, but from what i've seen there are no examples listed. I'm an excellent programmer but everything is easier with a base to work off of.

The code I can do. The starting point is what I need. Has anyone done anything similar, or is there something already in FG that works like that that I'm unaware of that someone could point me to?

Foen
August 27th, 2007, 16:45
Take a look at Joshuha's explanation, below.

Lorddamax
August 27th, 2007, 17:03
I bought FG1 last year at Gencon and completely redid the ruleset to work with my house rules. FG2 is a cool enough update that I'm using that now, but dont have the time to bother screwing with redoing my ruleset. So I'm going standard 3.5 with house rules piled on top. Are modules new? I dont remember them from before - I wanted to check out the d20 spells and saw it's a binary mod file and no longer a xml.

What I want is to have a button on the desktop or char sheet (I am coomfortable editing the ruleset to add this, I COMPLETELY rewrote the char sheet min FG1) where when its clicked it pops up a window with an image in it, and automaticallly shares the image with all players. With simple rng functionality I can make it pick from a random assortment of images.

I am just not sure about how to cause the image to appear and auto-share it to all player desktops.

Am I making sense?

joshuha
August 27th, 2007, 17:08
This is doable but will require some work to get it right.

Look at using a windowclass hosting a genericcontrol (or a buttoncontrol) containg the control for the button. The easiest way to put this on the desktop is to mount it on a panel (look at the desktop_*.xml files).

The in LUA have the click event of your control open up a windowinstance of the imageclass and share a certain image by DB reference. Use some type of math.rand function to pick which one. Then call a .share() on the windowinstance in LUA to share it.

Lorddamax
August 27th, 2007, 17:14
Can ya'll think of anything even remotely like this in the rulesets already so I have a reference? Like I said, I'm good with code. Learn this stuff well, but I learn BEST by example... so if I had something to go off of I could bang this out pretty quick.

Its been almost a year since I messed with my custom ruleset in FG1 and I remember adding in things to pop up windows etc. I guess I gotta go back in there and see what I got to work with.

Actually now that I think about it, every character sheet had a background image that set up the 'frames' and whatnot, should not be that hard to to.

Gonna have to scan in a few cards first and see what I can get working.

Foen
August 27th, 2007, 17:15
You're making perfect sense, I'll try to dig out (and test) some sample code.

Bleh! Ignore the rambling below, Joshuha has the right of it.

Module files are more heavily used in FG2, but are really just zipped text files, more or less, with the extension changed to MOD from ZIP. You can export adventure data quite easily from FG2 to a MOD (typing /export starts a wizard) but the pain arises when you want to do something that doesn't fit in the 'adventure' category, like sharing standing data. I always get in a pickle hand-editing the files, not least because it is unfamiliar territory to me.

I think (if you don't want to edit the d20 ruleset much) you might be able to use a MOD file to extend the underlying functionality and also package card images etc.

There has been a good post on the types of MOD file (not by me, but someone who knew what they were talking about, covering Client, Shared and Host), but I can't find it at the moment.

I'll give this a look and try to get back soon.

Cheers

Stuart
(Foen)

joshuha
August 27th, 2007, 17:40
Stuart,

What he wants to do can't be accomplished in a module file without heavy rewrites to the base ruleset code anyways. He could later package it into a module but its kinda of pointless since all the windowclasses and LUA files that would contain the meat of his code needs to be part of the ruleset.

---------------------------

As far as examples, for something like this there isn't. Nothing in the default D20 ruleset does this kind of thing automatically (besides in the source code).

I would just start piece by piece. Look at the desktop_classes file on how a windowreference control opens up another windowclass.

Then create you own windowclass and just add a buttoncontrol with an icon graphic defined. Then make a windowreference control that opens up this window class.

Then write a <script> function on the button control for onClickRelease() that fires off something. A print() to the console or create a message to the chat box. Then added in the math.random parts and make sure that generates your right range.

Then read up on how to open other windowclasses through Interface.openWindow() and experiment with opening a fixed image DB path. Then tie that into your random generator. Then lock at windowinstance functions on sharing windows.

Just take it step by step.

Lorddamax
August 27th, 2007, 17:47
Where the heck is the default d20 ruleset? under my app data directory the rulesets folder is empty. Nothing in the fg2 folder under program files either.

Edit: Nevermind, I found the d20.pak and d20unpack.exe

Lorddamax
August 27th, 2007, 18:53
Ok I have edited the ruleset, and have added a 'Draw Crit Card' button. When you press the button you get an appropriately sized frame.

Now...

Should I load a 'button' with the correct image, or use the imagecontrol? There is only ONE instance of imagecontrol in the default ruleset, and its not clear how it works. i've looked at the documentation, but I dont see how to pre-load an image in the image control.

I've no problem using a 'button' as the card image, but then the question becomes, can I randomize the 'button' image each time the window opens?

Using imagecontrol seems more... correct... since buttons should not really be randomized in appearance, and scripting a random image then sharing it out would make the most sense. But like I said, suport for imagecontrol seems lacking, cant figure it out.

joshuha
August 27th, 2007, 19:28
Well in adventure_images.xml it defines the entire windowclass imagewindow which has a datasource in the DB called images..

When you use Interface.openWindow to open a windowclass you need to pass it the datasource as the second tag. In the case of an image if you pass it the specific node in the DB of the image you are looking for it should pull it up.

Note I am not sure if a windowreference will be able to do that through scripting. My suggesting was storing your card dealing control inside of that class the window reference opened and when clicking on that button control it opens up an imagewindow class. If you wanted you could skip the windowreference altogether and just put a windowclass with a buttoncontrol straight on the desktop.

Lorddamax
August 27th, 2007, 19:37
Greek to me ;)

All that was stuff I havent gotten a grasp of yet, and it made no sense whatsoever, you're using technical terms I'm not familiar with yet.

I've reread it a few times and cant make sense of any of what you said... can you retry that in english, and not in FG-code-speak?

joshuha
August 27th, 2007, 19:46
Its hard to break these down into simple terms and most is learned by experimenting until it makes sense. Some day I might right a full fledged scripting guide but it make take awhile. Learning how the pieces interact is important before trying to jump into the scripting part. I would read through the entire ruleset modification guide and then through the reference guide for each of these parts.


Windowclass - This is essentially a frame with various controls on it. It *can* be tied to a database node so the information stored in those controls can be recalled later.

Windowinstance - This is referring to an indivdual window that opens using a windowclass as its base. So for character sheets say you have a windowclass defining the controls (and a databasenode storing the information), each PC that has his sheet open is working with a different windowinstance of that windowclass. Same controls, different instatiations (is that a word?).

Database structure - This one is really important but pretty difficult to explain. I will have to come up with a guide or something later.

LUA - Most everything can have LUA scripting attached to it and most of it is based off of events. So windowclasses can have LUA script which inherit to their windowinstances, controls on the windowclass can have LUA script which inherit to the instance, and the windowinstance itself has LUA functions that can mess with just one individual window.

Lorddamax
August 27th, 2007, 19:52
Is there a reference document written thats NOT in html? I'd like to print and read something instead of clicking links.

Hamish
August 27th, 2007, 20:31
Ah.. that's a question I can answer, although the answer is disappointing: No!
And Joshuha, that scripting guide would be VERY highly appreciated. I'm not a bad scripter myself, but it's very difficult to see how a FG ruleset works without proper documentation of the interactions.