Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Pages: [1] 2  All

Author Topic: Some easy questions (newbie)  (Read 11051 times)

0 Members and 1 Guest are viewing this topic.

organican

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 74
    • View Profile
Some easy questions (newbie)
« on: September 25, 2004, 01:43:34 PM »

Hi everybody ;)

I'm new at this (programming and everything...)  :o
so I hope you could help me out and getting this to work.

I'm trying to learn how to make a "if var a = 1 then do this"
but i'm not sure if i should put it in the object's script..
and i'm not quite sure "if(a=1)" is a real event, like "LeftClick".
I think that maybe it will only be activated once and then not work anymore.
Should I use "for" or "while" or something instead.
Sorry if this is too talky...
and i'm trying to make some things happen every x seconds. Should I use the date object for that?
or does the "Sleep (100)" work?

I'm new at this so I haven't quite figured out the syntax and all yet...
And then I'm trying to make an object rotate 1 degree at a time = this.Rotate = this.Rotate + 1,
but that doesn't work. Ordinary rotation work.. like "this.Rotate = 180;"

some code:

var tree;
var rotate;
/*
on "LeftClick"
{
this.Rotate = this.Rotate + tree;
}
*/

while (tree<10)
{ tree = tree + 1;
Sleep (200);
}

if (tree=10)
{ rotate = this.Rotate + 1;
this.Rotate = rotate;
tree = 1;
Sleep (100);
}

Thanx and everything
Logged

MMR

  • Global Moderator
  • Frequent poster
  • *
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 349
  • http://mmrdeveloper.wordpress.com/
    • View Profile
    • TinyWME
Re: Some easy questions (newbie)
« Reply #1 on: September 25, 2004, 02:51:28 PM »

To compare values remember to use "==" instead of "=".

"=" is used to asign values and "==" is used to compare values.

In your case if (tree=10) should be if (tree==10)

For and While are loop statements. It means they are repeating some piece of code until the loop reaches the condition. For example if you want to count from 0 to 10, you could use a For loop like this:

Code: [Select]
var a=0;
for(a=0; a<10; a=a+1)

You could also use a While loop for this:

Code: [Select]
var a=0;
while(a<10)
{
   a=a+1;
}

Also remember FOR, WHILE, IF... aren't EVENTS. The most common events are "LeftClick", "RightClick", "Keypress"... and they're precede by the reserved word on

Code: [Select]
on "LeftClick"

on "RightClick"

on "MyEvent"

Check the Docs for more details: Scripting in WME -> About the scripting language (the whole chapter)

BTW if you want something happends every X seconds... do this:

1) Create a new script file, for instance... x_secs.script
2) Write inside it something like:

Code: [Select]
while(true)
{
// your code goes here

Sleep(1000);
}

The "Sleep" suspends the script execution for the time in milliseconds written between the ( ). In our case, 1000 milliseconds = 1 second.

Note: It's very important to put a Sleep(x) at the end of a while(true) loop. If you don't do that, the engine/game will hang.

3) Attach this script to your game.script in this way:

Code: [Select]
Game.AttachScript("scripts/x_secs.script");
Now you have a piece of code repeating every X milliseconds ;)

Good Luck!
« Last Edit: September 25, 2004, 03:11:23 PM by MMR »
Logged

organican

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 74
    • View Profile
Re: Some easy questions (newbie)
« Reply #2 on: September 25, 2004, 05:10:31 PM »

 ;D Than :Dks...

It now works to rotate an object..
Though it seems you have to specify it's rotation in advance
//could be zero or anything, but somehow you have to do it
this.Rotate = 0;

var tree = 1;

//somehow this loop here seems to work inside the object script... Cool...
while(tree < 2)
{ tree = tree + 1;
Sleep (20);
if (tree==2)
{
//this tells the object to only rotate 0.05 degrees at a time. It's more smooth that way.
this.Rotate = this.Rotate + 0.05;
this.Rotate = this.Rotate + 0.05;
this.Rotate = this.Rotate + 0.05;
this.Rotate = this.Rotate + 0.05;
this.Rotate = this.Rotate + 0.05;
this.Rotate = this.Rotate + 0.05;
this.Rotate = this.Rotate + 0.05;
tree = 0;
Sleep (10);
}
}

//Now you can all use this to make objects rotate... though you probably already knew this
//It can make some great graphix effects too - used wisely (like water effects)
//(btw, I had to "hack" my scene's .scene-file in notepad to make the object rotable and add ROTABLE=TRUE...
//I couldn't find that option in SceneEdit - only scalable, colorable and interactive.

Well that's all for now  >:(

See ya!  :D
Logged

organican

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 74
    • View Profile
More questions. inventory window and musics
« Reply #3 on: September 26, 2004, 03:35:39 PM »


 
Soooo...
I have made a window that appears and disappears when you do something (click somewhere).
But now I want the inventory to be shown in this window. I'm not sure how to do this. Help me out PLEASE!!!  :'(

And now another question.
ogg is all great and all, but what if I wanted 15-20 songs in a game + sounds + graphics + the game.exe ...
then this would be something like 40 or 50 MB at least. But I want my games to be downloadable (by people like myself with only a 56k connection). I know myself that I don't want do download really big files unless it's something really really good (and how do I know it's really really good if I don't download it? I wont! So then I will not play or download this craptastic masterpice almost noone cares about cos they don't play it or download it.
I guess in the future we will have 10 GB per nanosecond connection via satellite directly through our head implants and everything.. but right now it cost a fortune and take forever to download really big games and stuff.
So then it's the question of midi and mod and all that but isn't there a way to make a midi bank feature in this othervise really great engine? So then it loads regular midi files and adds the soundfont or wav/ogg-files of your choice for different instruments.
I'm sure this wont be a problem in the far future, but right now it is.
So U have any ideas how to overcome this obstacle?
Make a game without music? Craaaaaaaaaaap!! :'(

Ok. That's all. Have fun::rock. And remember people what they say: They say do it again and you're history!
Logged

MMR

  • Global Moderator
  • Frequent poster
  • *
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 349
  • http://mmrdeveloper.wordpress.com/
    • View Profile
    • TinyWME
Re: Some easy questions (newbie)
« Reply #4 on: September 26, 2004, 04:39:28 PM »

Quote
I have made a window that appears and disappears when you do something (click somewhere).
But now I want the inventory to be shown in this window. I'm not sure how to do this. Help me out PLEASE!!!

Okis, a Quick & Easy answer... Open the inventory.def file that comes with the demo project and replace the Window definition for the one you've made.

The best way should be to write this file from the beginning, but as I've said, this is a Quick & Easy answer.

Try also to read the Docs:  Inside a game -> Working with the inventory   i'm sure it will help you deeply  ::rock
Logged

organican

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 74
    • View Profile
Answered that. Now something new...
« Reply #5 on: September 27, 2004, 11:14:23 AM »

It works. IT WOOOOOORKS!!! ::rock

The problem was that I had still some code left from the wme demo.
I had to remove some lines from the game_daemon script
// display the inventory window
//  if(Game.Interactive && Game.MouseY < 45 && !Game.ResponsesVisible && !WinMenu.Visible)
//Game.InventoryVisible = true;
//  else if(Game.MouseY > 100 || Game.ResponsesVisible || !Game.Interactive) //Game.InventoryVisible = false;
Because they made the inventory window always being closed unless (something???)
Then I just added some code to my windows script so that the inv is only visible when the window is.
I think it wworks with while(true)... too but I havn't tried it.

global scr;

while(scr<10)
{
while(scr<3)
{

this.Visible = false;
Game.InventoryVisible = false;
Sleep(30);
}

while(scr>3)
{
Game.InventoryVisible = true;
this.Visible = true;
Sleep(30);
}
Sleep(30);
}

//Then I just attach I script to a button/entity where I click to make the window and inventory become appear and disappear
//Cool huh?
global scr;

on "leftClick"
 {
if(scr==0)
{ scr=5; }
else
{ scr=0; }
}
//Oh, and you might want to put a line in game.script so that the scr variable is 0 at the beginning
global scr=0;


Now another question...
How can I make a window display text?
Like, I have this window, and when (in an object's script file) i say something like
on "LeftClick"
{ if(verb=="look")
{ actor/this/whatever.Talk("Hey! It's a script line!"); }
}
only I want it said in a window instead of spoken an entity or something.
Should I make an invisible entity inside the window?
Or is there some way to make the text be displayed directly inside a box or whatever?
 ::rock

That's all for now. See ya!
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Some easy questions (newbie)
« Reply #6 on: September 27, 2004, 11:27:00 AM »

You can place various controls onto your window, one of them being a static control, which can display either a text or an image. See the menu.window file in WME demo, it contains a STATIC section defining such a control which display the name of a selected object when you right-click it. Then, you can set the text displayed using its .Text property in a script.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

organican

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 74
    • View Profile
Supersize me.exe
« Reply #7 on: September 27, 2004, 04:49:37 PM »

(to Mnemonic)
Thanx I'll try it.

Now about the  ::thumbup ::rockmusical stuff I "discussed" earlier...
I thought about distiributing some of the music separately (for the "downloaded this 10GB file over a 1 kb per year connection and the download just stopped for the fitieth time in a row"-people) and then I found the information about the packages and that sound really great...

The only problem is.. I distributed the music as a separete file/folder and then compiled the pack's. However...
When I play the exe the music is there... but if I remove the music.dcb the music is still there...
It's stored inside the game.exe or data.dcp somehow...
I wanted it to be handled separately... and then to be removed, distributed and handled like the separate dir/datapack it is.
The music data pack is the same size as the music files btw...
Can't I do this?  :'(

Sorry for troubling you people so much.
And I really like WME so far (good work Mnemonic ::thumbup ::rock)

Ok. That's about it.
see ya!
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Some easy questions (newbie)
« Reply #8 on: September 27, 2004, 05:16:50 PM »

You need to define a second package in ProjectMan, you probably did, since music.dcp is generated when you compile the game. Now, you need to *move* the music files to this package. You can use any file manager, the package folders are actually regular folders on your disk. If you do so and compile the game, the music files should be packed into music.dcp and music will only be played when this package is present in the same folder as the exe file.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

organican

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 74
    • View Profile
Inventory stuff (simple question)
« Reply #9 on: September 29, 2004, 12:26:53 AM »

Sorry if I'm doing all my talking in the same thread
 ::hijack

but...
first of all: all my previous problems soved!!  ::rock Even the ones I didn't think I could solve, I fixed them all...

But now my new problem. Ok, I have a (new!) window where I want to display this second inventory. But I can't seem to "load" the inventory of the spells entity. OK, here's the code...

global spells; //?? should I? It might be something about globals but I'm not sure.
//The globals... the globals... the globals is coming to get me... ahhhh...

while(true)
{
while(spells<3)
{
this.Visible = false;
spells.InventoryVisible = false;
Sleep(30);
}
while(spells>3)
{
spells.InventoryVisible = true;
this.Visible = true;
Sleep(30);
}
Sleep(30);
}

I tried Game.spells.InventoryVisible and some other things too... I just couldn't make it work.
And then I want the spells.entity to take an "object" but I'm not sure how to do this really,
from outside it's script (another objects script).
I guess it's a beginners thing.  ;D


on "LeftClick"
{ if(verb=="look")
{
active=1;
spells.TakeItem("songspell");
text="You find a secret spell there... the song spell.";
}
}
That's it.

OK. Have fun. And always bring the good news first...
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Some easy questions (newbie)
« Reply #10 on: September 29, 2004, 12:39:11 PM »

Well, the problem is, currently WME supports only one inventory. If you need to display both the inventory AND the spells, you'll need to use an ordinary window, with for example a button for each of the spells (I don't know how many spells you are planning..). Then you can disable/enable the buttons depending on how many spells does the player have.

BTW I'm kinda lost in the code above, what are those while cycles supposed to do? ??? Also, you might want to use the [ code] tag to preserve indenting of the code, it makes it much more readable, thanks :)
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

organican

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 74
    • View Profile
Multiple inventory galore
« Reply #11 on: September 29, 2004, 03:56:31 PM »

Quote: "Well, the problem is, currently WME supports only one inventory. If you need to display both the inventory AND the spells..."

From the WME documentation: (inside a game/working with the inventory)
quote: "Taking, dropping, destroying and querying items

You generally reference inventory items by their name. If you want to take an item into inventory, use the Game.TakeItem(), for example:

Game.TakeItem("book");
 

This will add the "book" item into inventory. If you are using multiple inventories, you'll need to call the TakeItem method on the actual object you want to take the item, for example OldGuy.TakeItem("book");

Removing item from inventory works in a similar fashion. Only use the Game.DropItem() method instead:

Game.DropItem("book");
 

This command will remove the item from inventory. Although the inventory item is no longer displayed in the inventory, it may be reused later. If you want to remove the item from the game permanently, use the Game.DeleteItem() method.

You can query an item using the Game.GetItem() method. It will return an item object which can be used to set item's attributes.

To query if a certain object is taken by some game object, use the Game.IsItemTaken() method. It will search the inventories of all game objects to see if one of them has the item taken. On the other hand, the game objects provide a HasItem() method, which you can use to ask one concrete object if he has the item.

Example:

// has anyone the book?
var IsBookTaken = Game.IsItemTaken("book");

// has OldGuy the book?
var OldGuyHasBook = OldGuy.HasItem("book");

(...)

Multiple inventories

In WME each object (game, actors, entities) can have its own private inventory. It's mainly useful for games with multiple main characters. In that case you can control whose inventory is currently displayed on screen. This is done by setting the Game.InventoryObject attribute. By default this attribute is set to the Game object, which is just fine for single-inventory games. If you have multiple switching actors you'll want to set this attribute to the current actor."

Well what do you say now? (sorry for being sarcastic)

Maybe you're right in the documention, maybe you're right here when you speak,
but I wanna know which of your statements is true, if it's not too much to ask for. (sorry for being so demanding)

As for the code...

I've made one window that displays the inventory on top if it only if a certain variable is greater than 3 . I'll make that later, and remove the loops too, you don't have to worry too much about them, it's the "spells.InventoryVisible=true;" that doesn't work.
When I use the code for the regular inventory it works just fine.

the "LeftClick"... part is inside an objects script, so that when you "Look" at it the spells entity will take the song spell.
I've figured out a way around that, by using more variables. Like when the spelltake variable is 1, the spells entity will take spell 1 and set it to 0. When it's 2, it will take spell 2 and set it to 0, and so on. U can't do this from another entitys script?
Anyway, it should work.

But the problem is, that I can't make the spells inventory visible.

I thought this engine really rocked when I read that about multiple inventories. And now I can't...
 :'(
« Last Edit: September 29, 2004, 04:02:18 PM by organican »
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Some easy questions (newbie)
« Reply #12 on: September 29, 2004, 04:37:51 PM »

Believe it or not, both of my statements are true. You can have multiple inventories, meaning multiple sets of items (each character can have its own). But you can only *display* one of those inventories at one time. Of course, that applies to the built-in inventory system. You can script another inventory from scratch, but it's more complicated. That's what I was trying to suggest above.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

organican

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 74
    • View Profile
Re: Some easy questions (newbie)
« Reply #13 on: September 29, 2004, 07:02:40 PM »

But that's what I mean... really.

BTW me forgot to tell ya one little tiny detail... my game is perst-person, which means u don't have care about the dumb actors.

So it doesn't matter if he's called spells or equipment or some other fancy stuff..

I made an actor called spells. So now I want to make his inventory appear as the regular Game.Inventory.
In some code I'll probaby just change between the different actors and make their things appear... *magically*

I just thought that inventories could be held by entities and items and stuff... The documentation almost said so,
but I'll guess this will do too.

So a little help here... please...
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Some easy questions (newbie)
« Reply #14 on: September 29, 2004, 08:03:21 PM »

Aaah, I see! Ok, in that case, it's easy :)
The *magic* line is: Game.InventoryObject = SomeObject;

...where "SomeObject" is the actor/entity/whatever, whose inventory you want to display. So in your case, to display the spells, you'd write:

Game.InventoryObject = spells;
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
Pages: [1] 2  All
 

Page created in 0.043 seconds with 18 queries.