Core functions

I'm trying to debug a room-cloning script that keeps throwing errors like these:

Error running script: Error evaluating expression 'GetAllChildObjects(room)': Collection was modified; enumeration operation may not execute.
Error running script: Error evaluating expression 'GetAllChildObjects(newParent)': Collection was modified; enumeration operation may not execute.
Error running script: Error evaluating expression 'ListCombine(ScopeReachableNotHeldForRoom(room), ScopeVisibleNotReachableForRoom(room))': Value cannot be null.Parameter name: collection

What's confusing is my script isn't using commands like GetAllChildObjects(newParent). I suspect the CloneObject or CreateBiExits commands I'm using are clashing with something else. If I knew how these commands worked, I might be able to diagnose the issue.

In the Wordpress codex, you can review the construction of their core functions. Is there a similar reference for Quest?


I found it! (At least the answer to my immediate question.) It's all in \quest-master\quest-master\WorldModel\WorldModel\Core\CoreFunctions.aslx. Sorry, I'm still a newbie at this.

Now for debugging my script to clone a room. I'll post again if I figure it out. In the meantime, if you all can already see something that's wrong based on the above, please let me know.


EDI: Posted at the same time :) Glad you found it.

If you have Quest installed locally, there will be a folder somewhere inside it named 'Core', which contains all the core functions. In the git repository, it's under WorldModel/WorldModel/, but not sure where it can be found once the thing compiles.

The expression given in your last error message appears in the file CoreScopes.aslx, within the function ScopeVisibleNotHeldForRoom.

The one above it is in the function ScopeVisibleNotReachableForRoom. And the line above that is for a line in the function ScopeReachableNotHeldForRoom; both of which are called from the expression in the last one. So I would assume they are the proximate cause of the error.

I can't see how those errors could come about. However, that particular error message is often uninformative, so can be hard to debug. If you want to share the code that you're having problems with, I'm quite familiar with the core code, so perhaps I can help you find something.

Hope that helps.


Thanks, man. I've been lurking here for the past month and have always been impressed with the care and attention you show to these posts. You are a true resource and teacher!

Here is my scenario. The player is in a room with the x-y-z coordinates of 2.0.0 (stored as attributes .x, .y, and .z) and alias of "2.0.0", and he wants to mine north to 2.1.0. This is done by cloning a room room called prospectiveroom with the respective placeholder attributes 7.7.7 and .isroom=false.

The steps are:

  1. Set prospectiveroom's .x, .y., and .z attributes to be the same as player.parent (2.0.0).

  2. Increment prospectiveroom's .y +1 to 1, so it's temporarily set to 2.1.0.

  3. Check if prospectiveroom's coordinates match those of a room already created. If they do, CreateBiExits to that room. (This part works fine.) If 2.1.0 does not exist yet, newroom = CloneObject(prospectiveroom).

  • And this is where the execution blows up every once in a while with this:

Error running script: Error evaluating expression 'GetAllChildObjects(newParent)': Collection was modified; enumeration operation may not execute.
Error running script: Error evaluating expression 'ListCombine(ScopeReachableNotHeldForRoom(room), ScopeVisibleNotReachableForRoom(room))': Value cannot be null.Parameter name: collection
Error running script: Cannot foreach over '' as it is not a list

  1. Reset prospectiveroom's x-y-z and alias attributes to 7.7.7.
  • At this point, I receive the following error, although I'm not sure if it's not just a continuation of the previous error:

Error running script: Error evaluating expression 'ListExclude(ScopeVisibleNotHeldNotScenery(), game.pov)': Object reference not set to an instance of an object.

  1. newroom.isroom = true ... All this manipulation of .isroom is because I have timer scripts using the scope AllRooms to randomly place objects and NPCs, and I don't want them dropping into places like prospectiveroom.

  2. CreateBiExits (direction, currentroom, newroom) ... In this case, it's passing in "east", player.parent, newroom

  • This step occasionally throws similar errors as under #3 above:

Error running script: Error evaluating expression 'GetAllChildObjects(newParent)': Collection was modified; enumeration operation may not execute.
Error running script: Error evaluating expression 'ListCombine(ScopeReachableNotHeldForRoom(room), ScopeVisibleNotReachableForRoom(room))': Value cannot be null.Parameter name: collection
Error running script: Cannot foreach over '' as it is not a list

It also tacks on:

Error running script: Error evaluating expression 'ListExclude(ScopeVisibleNotHeldNotScenery(),game.pov)': Object reference not set to an instance of an object.

What do you think? I have a feeling I'm going to have to ditch this this whole cloning-room thing and just pre-make the ones I want, and then hide or not construct the exits between them.


Do you move the player into the newly replicated room? The only explanation I can guess for those errors is if the player's parent has somehow become null.

I'm trying to recreate your code from the description so I can try some things; but would be easier if I could see either the game or this part of the code.

Will try again after lunch


The player doesn't enter the new room until he enters "n" to move into it. So that's something I find confusing, that the CloneObject command would even be concerned with what's going on in player.parent.

I made some modifications to the above to address concerns with shallow versus deep cloning. So instead of assigning my test .x-.z attibutes to prospectiveroom and then cloning prospectiveroom when they pass muster, the test attributes are assigned to local variables and then only copied to the newly cloned object after it's made, leaving the prospectiveroom template alone.

The weird thing it, it all seems to work until I've cloned and moved through 20 rooms in a row, and then on the 21st time, it goes on again about GetAllChildObjects(game.pov).

All that being said, I'd be happy to share my entire ASLX file with you, if you'd care to peak under the hood. What is the best way to do that? And thanks again! :)


Are there any objects inside the room being cloned? And if so, do any of them have a changedparent that will fire when they're moved? Changescripts can do some really unexpected stuff when their object is cloned.

Is it always the same number of rooms before you get an error?

I'm mostly guessing now


Excellent questions. No, there are no child objects of the room I'm cloning. I even re-created my room template clean and made sure the functions that do populate the newly made room happen after cloning and the creation of bidirectional exits.

There doesn't appear to be any consistency with the frequency of the error messages. Sometimes it's after 3 clones, sometimes 17, sometimes 30.

At this point, I'm really frustrated and will put this project on hold. I'll come back later to explore the code libraries here, or maybe just do things the hard way and pre-create all the rooms.


Sorry I can't offer any more useful advice.
Could you share the game so far, so that I can try to figure out the issue?


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums