Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Crashes The Game
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#13
RE: Script Crashes The Game

That would be nice of you =)

Well, my script is rather short with big intention. It's also very specific to the entities I've made so it might be difficult for me to explain, but I'll give it a go. It's only about half way done at the moment though, but I can't finish it before I fix this issue. Prepare yourself for a long explanation! :O

I'm making a puzzle that requires the player to find small slates represeting paths. Here's an example of how a horizontal slate looks like:
Spoiler below!
[Image: expl_slate.png]
This entity also has a body with the name of "west_east" This comes in play later.
I also have slates representing vertical paths, turns and combinations. The body names of all these include the directions they face: "north_south" "south_east" "north_west_south" are examples.

These slates can be placed with sticky areas into the slots of a big frame in the floor. This frame has 5x5 slots with a few built-in slates that can't be moved. It looks like this (the empty slots have the Ankh symbol):
Spoiler below!
[Image: expl_frame.png]
This frame is also located inside a maze of sorts. The map consists of 5x5 rooms with doors in between them. The setup for this whole room is like this:
Spoiler below!
[Image: fric_sys_ex.png]
This system works in the way that each room has their own co-ordinate. The room in the middle is named x3y3. This is also the room with the cross slate as well as where the big frame is located.

The idea is to place a slate in the slot next to another used slot in order to open the door in between the represented rooms, as long as the slates connect with each other. For example placing the horizontal slate in x4y3 will open the door connecting room x3y3 and room x4y3. The naming system I'm using for the doors (they are MoveObjects btw) is "move_room1_room2. The door mentioned above is named "move_x3y3_x4y3" This is the best system I could come up with to make it organized. The first room is always the north or west room, the second room is always the south (if first is north) or east (if first is west).

The remaining things to mention within the map are just the different slates as well as the sticky areas. The slates do not use any naming system other than the body names mentioned way up, but they all include "slate" in their name. The sticky areas are named "area_co-ord" similar to the doors, except they only have 1 co-ord for the room and not the 2 connecting rooms. These areas accept entities with "slate" in their name to connect with. Upon connecting, they call the script function "AttachSlate."

Now the scripting (yay):
Spoiler below!
PHP Code: (Select All)
bool bWestbEastbNorthbSouth;

void AttachSlate(string &in asAreastring &in asBodyName)
{    
    if(
StringContains(asBodyName"west") == truebWest true; else bWest false;
    if(
StringContains(asBodyName"east") == truebEast true; else bEast false;
    if(
StringContains(asBodyName"north") == truebNorth true; else bNorth false;
    if(
StringContains(asBodyName"south") == truebSouth true; else bSouth false;
    
    for(
int x=1<= 5; ++x) for(int y=1<= 5; ++y) {
                
        
string sThisArea "area_x"+x+"y"+y;
        
string sThisDoor "move_";
            
        if(
bWest  == truesThisDoor sThisDoor +"x" + --x; else sThisDoor sThisDoor +"x" +x;
        if(
bNorth == truesThisDoor sThisDoor +"y" + --y; else sThisDoor sThisDoor +"y" +y;
        if(
bEast  == truesThisDoor sThisDoor +"_x"+ ++x; else sThisDoor sThisDoor +"_x"+x;
        if(
bSouth == truesThisDoor sThisDoor +"y" + ++y; else sThisDoor sThisDoor +"y" +y;
             
        if(
asArea == sThisArea) {
            
UpdateDoors(sThisDoor1);

            
AddDebugMessage("Area: " sThisAreafalse);
            
AddDebugMessage("Door: " sThisDoorfalse);
        }
    }
    
    
bWest false;
    
bEast false;
    
bNorth false;
    
bSouth false;
}

void UpdateDoors(string &in asDoorint alState)
{
    
AddDebugMessage("Updating Door: " asDoorfalse);
    
SetMoveObjectState(asDooralState);


So far in the script, I have not implemented the connecting slates part. So far it only opens a door leading to the room represented by the area the slate was placed in. This is where the problem occurs. Only sometimes, the game freezes up, just like what happened to you, the moment the slate connects with the area. I'm unsure why this happens. It seems to work fine with the horizontal slate in all slots (though only on the "west" side). Whenever I take a "north_east" slate, it freezes. It also freezes (randomly) if I enable the script for closing the doors again within a "DetachSlate" function, which is similar to the attach one. I have excluded it because I don't need to close the doors before I can properly open them.

Do you understand what's going on here? Any ideas? Undecided

(This post was last modified: 03-14-2014, 03:01 PM by Mudbill.)
03-14-2014, 02:59 PM
Find


Messages In This Thread
Script Crashes The Game - by Wapez - 03-11-2014, 01:54 PM
RE: Script Crashes The Game - by PutraenusAlivius - 03-11-2014, 02:34 PM
RE: Script Crashes The Game - by Wapez - 03-11-2014, 02:39 PM
RE: Script Crashes The Game - by PutraenusAlivius - 03-11-2014, 02:43 PM
RE: Script Crashes The Game - by Wapez - 03-11-2014, 02:57 PM
RE: Script Crashes The Game - by Mudbill - 03-11-2014, 03:12 PM
RE: Script Crashes The Game - by Daemian - 03-11-2014, 03:15 PM
RE: Script Crashes The Game - by Wapez - 03-11-2014, 03:40 PM
RE: Script Crashes The Game - by Mudbill - 03-11-2014, 09:09 PM
RE: Script Crashes The Game - by Daemian - 03-12-2014, 01:22 AM
RE: Script Crashes The Game - by Mudbill - 03-13-2014, 09:27 PM
RE: Script Crashes The Game - by Wapez - 03-14-2014, 08:54 AM
RE: Script Crashes The Game - by Mudbill - 03-14-2014, 02:59 PM
RE: Script Crashes The Game - by Wapez - 03-14-2014, 03:56 PM
RE: Script Crashes The Game - by Apfel - 03-14-2014, 04:35 PM
RE: Script Crashes The Game - by Wapez - 03-14-2014, 04:42 PM
RE: Script Crashes The Game - by Apfel - 03-14-2014, 05:31 PM
RE: Script Crashes The Game - by Wapez - 03-14-2014, 05:36 PM
RE: Script Crashes The Game - by Mudbill - 03-14-2014, 05:49 PM



Users browsing this thread: 1 Guest(s)