Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Mr_Threepwood

#21
Alright I tried the other way you said to do it with the MoveTo, it  sort of works.  The problem is that the onMouseClicked thing in the while loop gets activated immediately since you are clicking the door, a solution to that would be to put in a wait but it causes the character to delay doing stuff which is annoying.

I did however get a way that works, and doesn't even block the global script.  It doesnt seem very elegant so if there's a way I can make it cleaner or something just tell me.

Code: ags

//in room script for interact with object
//this moves player to 290, 140 with item to run on 1 and command to run on item 1
queuedCommand(290, 140, 1, 1);


//global script

bool inQueue=false;
int qx;
int qy;

function queuedCommand(int x, int y,int itemNum, int commandNum){
	inQueue=true;
	player.Walk(x, y);
	qx=x;
	qy=y;
	SetGlobalInt(20, itemNum);
	SetGlobalInt(21, commandNum);
  }

function repeatedly_execute() {
  if (inQueue&&player.x==qx&&player.y==qy){
    inQueue=false;
    CallRoomScript(0);
  }


//in on mouse click
inQueue=false;



//back to room script now
function on_call(int dummy){
  int itemNum=GetGlobalInt(20);
  int commandNum=GetGlobalInt(21);
  //Display("ARRIVED");
  if (itemNum==1&&commandNum==1){
    cEgo.ChangeRoom(5,45,160);
    }
  }


That did it, and it works but seems like stuff is getting passed around to different scripts like crazy.  Tell me what you think about it, it's a decent solution to the problem I think and manages to decoy the games on_call function.
#22
well I dont have it working but it would look like this I think:

Code: ags

//in the room script
function runQueuedCommand (int itemNum, int commandNum){

//door is itenNum, commandNum is open.Ã,  These numbers are just made up by me, no script references based on the actual objects number.Ã,  This way It could work with hotspots as well as objects

if(itemNum==1){
if(commandNum==1){
cEgo.ChangeRoom(5,100,100);
}
}else if (itemNum==2){
if(commandNum==1){
//in this case let itemNum be a book and command num be pick up
//5 is a book in the game inventory items
cEgo.AddInventory(5)
}
}

}

//now here's how I'd call a run queued command from an items interaction (in my case I always use usermode 1, and have a global int that tracks what they are doing (IE use, walk to, pick up);

//usermode 1 on item or hotspot

//global int 10 being 1 represents player pressing "open" on something
if (GetGlobalInt(10)==1){
//global function

//this is what I'd like to work, where 140,140 is where the character moves and 1,1 is the itemnum and object num.Ã,  The last two could be global ints instead if that makes it easier.

QueueCommand(140,140,1,1);

//so now my character will walk to 140,140 and when he reaches it it does runQueuedCommand 1,1.Ã,  Which from this example will open the door.



Sorry If I didn't explain it well, if there's any confusion just say so and I'll try to explain it better.  I'm pretty sure this would work, the only thing getting in the way is I don't know how to call a room script from the global one, and if you can't then I think I could call the one parameter room script on_call, which in turn just calls the runQueuedCommand.
#23
I think that even if you can't call local scripts per se from the global script I've managed to think of a workaround to it, tell me what you think.

For the ItemNum and CommandNum use global ints instead, have the global function runqueued command call the local on_call script, which then calls the reasl runqueuedcommand which then takes the two global integers and then does the command from there.

It's a little messy but to me seems like a good workaround if you can't normally call room scripts from the global script.
#24
There are many ways to make your character leave the room, the one Kristjan posted is probably the easiest if you are a beginner.  If you have programming experience you might have an easier time just diving into the script and figuring it out that way (it's very similar to java or c++).   In the script it's just characterScriptName.ChangeRoom(roomnum,x,y)

So for example:

cEgo.ChangeRoom(2,10,50);

Would take the character with the script name "cEgo" to room to at coordinates 10,50.

I find diving into the script gives you more control over your game, but if you're not used to programming do it the easy way, then look at how it's doing it in the script.
#25
OK I think I've almost got a way that will work for all objects that I want the character to walk to before interacting, but not blocking the script.  The only problem I am having is I can not figure out how to call a room function from the global script (except for the CallRoomScript one which I dont want because it can only accept one parameter).

The way I have it working (well not quite) is like this:

1.  Call queuedCommand(int x, int y, int itemNum, int CommandNum)
2.  Store all those in variables in the global script, make player walk to x,y.  Store boolean to say a queue is in place, cancel the boolean if player clicks anything else.
3.  In repeatedly execute check if player has reached x,y and que
4.  If player has reached x,y and is still in the queue then run the room function runQueuedCommand(int itemNum, int CommandNum)

That will let me have multiple interactions with items for the queued commands.

The only problem is I can't figure out how to get runQueuedCommand to run from the global script since it is a room script.  Is it possible to do it?  Alternatively I could use the less organized CallRoomScript which only accepts one integer, it would work but if I could organize it better it would be nice.
#26
Thanks for the response, but let me try to re explain my problem.

The problem with using eNoBlock is that it will then continue doing the script (which I want it to do but without the change room), if I just changed it right now from block to noblock then it would make my guy teleport to the new room as soon as you clicked "open door".

What I would like is a way that the script still goes, but "waits" until you are at the door before changing rooms.
#27
Is there an easy way to do this:

When a player clicks on an object and something is run, in my case open door, then the player walks to the door before changing rooms but without blocking the script.

The reason I ask is if it's easy I'd like to have it so you can click "open" on the door and then while your guy is walking you can click "walk to" somewhere else and have it stop you from going to the door and changing rooms.

Right now I have the script blocking when you walk to the door which works fine but isn't very elegant.

I was thinking maybe I could accomplish this with regions, or even better would be a simple if statement.
#28
I've got a strange problem, it doesnt cause any errors or anything but it's annoying to me.

Here's my room script

Code: ags

// room script file

#sectionstart room_aÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function room_a() {
Ã,  // script for Room: Player enters room (before fadein)
cEgo.x= 290;
cEgo.y=140;
cEvil.ChangeRoom(6, 280, 140);
 
}
#sectionend room_aÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart room_bÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function room_b() {
Ã,  // script for Room: Player enters room (after fadein)
Ã,  //cEvil.Walk(145, 145);
	cEgo.Walk(145, 145);
	cEvil.Walk(145, 145);
Ã,  
}
#sectionend room_bÃ,  // DO NOT EDIT OR REMOVE THIS LINE


The strange thing is that for some reason cEgo waits about half a second before he starts moving, whereas the other guy doesn't.

I have almost the exact same code in the previous room and it worked without any delays for that room.

I'm pretty sure it has to do with the character stacking, since if I move the characters to start from different spots it works like normal.Ã,  Is there a way I can ignore character collisions?
#29
Yea thats what it was I'm an idiot, I didnt know that when a gui is visible it activates a different cursor, and since I dont use that cursor anywhere else i neglected it.
#30
I posted something stupid, please delete.
#31
Advanced Technical Forum / Illegal Exception
Wed 19/07/2006 19:08:58
I dont know if this is me being stupid or what but here it is:

Quote
Illegal exception
---------------------------
An exception 0xC0000005 occured in ACWIN.EXE at EIP = 0x0043E14C ; program pointer is +6, ACI version 2.71.894, gtags (1,30)

This occured when I had a cutscene, I started it at the start of the game, and tried to end it after a character moved to an x,y location with blocking on.

If I moved it to before the character moved it worked fine but it didn't like the character movement.

Edit:

Nevermind I managed to work around this by using a global int to see if it's in a cutscene, I found out how walking works when you skip a cutscene, it doesnt teleport the character to their destination.
#32
Well thanks for that tip I've made some progress but am stuck again with it.

I can get the gui to pop up and be not disabled (by setting it so in the game options), however clicking the actual buttons does nothing since I think that using SayAt is using blocking and thus not allowing any other script functions to run.

Is there any way I can either make the SayAt not block, or even better would be a way to override the blocking and make the GUI be the new blocker so that the game waits until the user has selected a gui option.

Any insights in this would be helpful.
#33
I am making a simple intro and I have run into a few problems that I need some insights with.

The intro will consist of my character not being on the screen, and using SayAt to make his text be on the screen.  I dont want the keys to be able to skip the text (so I set it to mouse only in the game options), but at the same time I want the game script to continue while my character talks so that if I hit a certain key the save/load gui comes up.  The problem right now is what when I use SayAt it pauses the game script I think so it stops listening for keyboard input.  I also need the keyboard input so the ESC key will work and allow the player to skip past the intro to the start of the game (I'll use a global int to set whether or not the game is in the intro, so it knows to take them to the right room).
#34
In the AGS manual it says SayAt displays text with its top left corner at (X,Y).Ã,  I'm getting it to be that the bottom left corner is at X,Y.Ã,  Is the manual wrong here or is this just some weird thing I'm experiencing and no one else is?

Edit:  Something is definitly weird with the SayAt command, I did DisplayAt and it works perfectly whereas SayAt seems to scew the text from where it should be.  It has something to do with setting the width of a SayAt command.  Is this just how it is supposed to be, or is it a bug?
#35
This is vexing, I'm running into problems every step of the way on what should be simple things.

I want to display the mouse coordinates so I have tried to put them in a string using:

message=("coordinates %d , %d",mouse.x,mouse.y);

However that gets a parse error saying it doesnt like the %d 's, what am I doing wrong?

EDIT:
Nevermind I found out that String.Format is what you need to use to get this to work.  Seems weird though that the other way doesnt work as well, I mean what would you do if you already had a string and wanted to add numbers into it without getting rid of the information?
#36
Sorry to be a bit of a pain, but could anyone verify this problem or is it just me (in which case I'm doing something wrong)?

I read somewhere on the forums or on the AGS help something about relative screen position and how the resolution affects it or somethimg, but can't seem to get a definitive answer as to why I might be having this problem with placing items at x,y coordinates.  It's not like it's a syntax error or anything since it does it, but in the room editor I look at where I told it to go, but when I run the game it's off by a bit for some reason.
#37
Ok well here's what it looks like, I make my character SayAt (120,100), but the upper left hand corner of where it actually displays looks more like (120,60).  By this I mean I checked the coordinates on the room image to choose (120,100) so I could position it under the stuff in the image, however it is displaying higher then it should be for some reason.

When I make my games resolution 320x200 however, it displays in the correct spot.
#38
no the top left corner is definitly not being shown in the right place.  Does AGS really favor 320x200 resolution and mess up placement with anything else?  I think that might be the cause of my problems.
#39
One more thing, for some reason whenever I put in x y coordinate for my 320x240 room they never seem to be where they should be.  I'll look at the room editor and see the spot 120,100 for example, but when I print to those coordinates it doesnt print there, it prints in a close spot but not the right one.  Why is this and how can I fix it?
#40
Thank you that works, it was a very dumb reason I'll admit but I couldnt figure it out since I am so new to using AGS.

So is this how it works, you create an interaction to run a script, which then puts a new script labeled room_ and a letter into the main room script.  Then when the interaction is triggered it runs the function it's set for in the room script.
SMF spam blocked by CleanTalk