Jump to content


Joysurrender

Member Since 21 Jul 2006
Offline Last Active Mar 01 2013 01:07 PM

Topics I've Started

Writing Text Files

27 February 2013 - 04:47 PM

Well, I'm making a map editor for my 3D game.
The basic facts are: I choose a model, i choose its position and, when I'm ready, I press enter and, in the file "map.txt" it's added a line with the code I need (that will be read, after, in the game, such as CreateModel(x,y,z,name) ;).
So, if I make a map with 4 objects and the room, it should be a text file with 5 lines:

CreateModel(0,0,0,room.3ds);
CreateModel(20,11,0,forniture.3ds);
CreateModel(40,22,40,lamp.3ds);
CreateModel(60,33,1,door.3ds);
CreateModel(80,90,6,control_panel.3ds);


Now... my camera set it all up.
In the create event of my camera, I wrote:

fail = file_text_open_read("mappa.txt");

Fail is how I read "file", pretend it's ok, nothing about failing XD

In the Enter keyboard press event (that I press when I finish with that model) I wrote:

file_text_write_string(fail,"InstanceCreate(" + string(new_model.x) + "," + string(new_model.y) + "," + string(new_model.z) + "," + string(global.file) + ");");
file_text_writeln(fail);

I get:

ERROR in
action number 1
of Key Release Event for <Enter> Key
for object camera:

File is not opened for reading.


What's wrong with it?
The file doesn't even get created.

Applies To Another Object

27 February 2013 - 03:26 PM

Hello there.
I've been not touching GML for a while and here I am with a very simple question xD
I can't remember how to say apply to onother object in the code.
I mean, you could set the "Applies to:" option in the code event, but I need it only on one line.
Example:
In global_settings object, when I press Enter, if lol does exist, it has to be changed in lal.
The code is
if instance_exists(lol) ***** instance_change(lal,0)

***** = What do I have to write in here?? lol has to change, not global_settings.

How do I set an direction-based cone of sight?

15 September 2012 - 02:05 PM

Hi there.
First of all... *a, not an XD
I need to set up an AI for my stealth game.
The enemy must have a "line of sight".. but not a line, it has to be a triangle... If the player steps inside it, the guard will change to "alert mode" (like in Metal Gear Solid). But I have some doubts...

First: how do I set a line of sight that rotate together with the enemy (since he follows a path and has image_angle = direction) if the collision line direction is set by x1,x2,y1,y2? It would mean that the guard would only watch ONE side, even if his face is in the other direction.

Second: How do I set a triangle and not a line? The line is too little, our view is more and more larger than it xD

keyboard_string for numbers

07 September 2012 - 11:45 AM

Hello there.
I'm working on a little software.
It has to compare the value typed by the user with a given value.

Example:

2.50 + 2 = 4.50
User: 5

Compare 5 with 4.50. If equal, go ahead... else, show "Are you f.. kidding me?".

The fact is that I don't want to show "extra windows" for typing, so I don't want to use the get_integer function... I want the user directly typing in my window, so I've used the keyboard_string function, but naturally Game Maker gave me error. It says that it can't compare them (of course, one is a string and one a float).
What should I use instead of "keyboard_string"?
...or: how should I convert that string in float?

Polygons Interpolation

25 July 2008 - 12:09 PM

Is it possible in Game Maker?

(Naturally, I'm talking about 3D)