Basic questions: a lot o' them!

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
panurge
Posts: 22
Joined: Sat Jul 04, 2009 11:08 pm

Basic questions: a lot o' them!

Post by panurge »

I am amazed by the potentialities of ZGE, but i really can't get into its style of composition. I'd like to use scripts rather than the project tree. I think that some way to bypass this already exists, but here's some questions i could not answer:

How do you 'call' actions (e.g. SpawnModel) in a script? I'd really like something as "SpawnModel(model1,X,Y);"
Tell me this can be done! I randomly tried some awe-inspiring syntax but nothing was accepted.

A thing i don't quite understand is how expressions work on bitmaps.
I'd like to create a, say, 16x16 (black and white) bitmap, and then put in a 2_dimensional array all the single values (1=white, 0=black).
Is there a way to access a particular pixel value of the bitmap? When i write something like a=this.pixel, i don't understand which pixel's value is being considered.

this lead to another question.

In certain situations, ZGE says "Graph can not be displayed for this Mesh". I added three variables in the mesh folder and now i cannot edit the graph anymore. But me be glad to keep do dis, rilley.
Uh... I also tried defining variables in the model, not in the mesh. But then i have another problem...
When accessing CurrentModel.variablename, ZGE seems not to see it.

Thank you again, please pardon my noobyness. With one or two sets of questions like this one answered, i'd hopely be ready to dive inside ZGE like a foolman. :D
User avatar
Kjell
Posts: 1891
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Panurge,

Let me try to answer your questions.
How do you call "Actions" from a Script?
Sorry, but you can't ( at the moment ). Unlike GM where drag 'n drop and scripts are pretty much interchangeable, you'll need both in ZGE. While I'm not entirely happy about this either, it's actually not so bad once you get the hang of it.

So, in order to Spawn a Model / Clone you really need to use the SpawnModel Component. But keep in mind, in case you need to use it in combination with a "if-statement", there is the "Condition" Component .. or when you need a whole bunch ( repeat / for-statement ), you can use the "Repeat" Component.
Is there a way to access a particular pixel of a bitmap?
Yes and no :) You can access particular pixels of a Bitmap ... but for each time you do that, technically you're actually looping through all of them. While I do think that there should be "GetPixel" and "SetPixel" Components, for your situation the way it works now is perfect ... well, almost.

Almost, because BitmapExpression uses OpenGL style coordinates ( from 0 to 1 for both X and Y ). So when you have a 16x16 2D Array filled with 0's and 1's and want to create a Bitmap to represent that data, we'll have to convert the coordinates.

Code: Select all

int PixelX = X*16;
int PixelY = Y*16;

this.Pixel = MyArray[PixelX,PixelY];
And you where on the right track with you last issue.

Don't put any DefineVariable Components in a Mesh. Variables defined using that component are always global unless they are put inside the Definitions leaf of a Model. And in order to access such Model-specific variable from a ZExpression, just use the VariableName instead of CurrentModel.VariableName. Don't worry, I made that mistake as well when just starting out with ZGE :wink:

Hope this helps ~
K
User avatar
panurge
Posts: 22
Joined: Sat Jul 04, 2009 11:08 pm

Post by panurge »

Thank you so much for the answers! You helped me very much.
I also gave a look to you video tutorial: there are some interesting stuff in it! I liked how you created an "iput" array and refreshed it in the app. update folder. I'll steal you that idea :D
I everything goes right i'll be able to finish the little stuff i was thinking about.
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Re: Basic questions: a lot o' them!

Post by kattle87 »

panurge wrote:I am amazed by the potentialities of ZGE, but i really can't get into its style of composition. I'd like to use scripts rather than the project tree. I think that some way to bypass this already exists, but here's some questions i could not answer:
The _easiest_ way is: write down your if, then split the ZExpression in 2 different expressions and add a "condition" component.
You are done ^^

Off Topic: Maybe I'm out of the mist for some days... But let's see how the exam went today before speaking :roll:
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

Hi panurge,. yeah I want to do some of those as well,. ZGE is very powerfull but it does take a little work to get into,. especialy if like me you came from GM, I wanted similar scriptability, like spawn_model(name,x,y,z), etc. however, it is just a mater of learning the system, finding the strengths, and exploiting them! start simple, get some stuff done, then try harder things,. peace.
iterationGAMES.com
Post Reply