You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the debugger up and running and everything is working fine in terms of breakpoints and using the console, but when I try to select this code in a lua file and use Debug: Evaluate in Console, it works the first time but fails the second time.
-- Function to get detailed entity count for a specific chunklocalfunctiongetEntityCountForChunk(surface, chunkPosition)
localentitiesInfo= {}
localentityCounts= {}
localchunkSize=32-- Size of a chunk in tileslocalchunkArea= {
{chunkPosition.x*chunkSize, chunkPosition.y*chunkSize},
{(chunkPosition.x+1) *chunkSize, (chunkPosition.y+1) *chunkSize}
}
-- Finding all entities in the specified chunk arealocalentities=surface.find_entities(chunkArea)
-- Counting entities by name and typefor_, entityinpairs(entities) dolocalidentifier=entity.name.."-" ..entity.typeifentityCounts[identifier] thenentityCounts[identifier].count=entityCounts[identifier].count+1elseentityCounts[identifier] = {name=entity.name, type=entity.type, count=1}
endend-- Converting the counts to a list formatfor_, infoinpairs(entityCounts) dotable.insert(entitiesInfo, info)
endlocalchunkData= {
chunk_position=chunkPosition,
entities=entitiesInfo
}
returnchunkDataendreturngetEntityCountForChunk(game.players[1].surface, {x=-1,y=-1})
First time, it runs successfully and outputs the table and I can inspect it no problem.
Now I just do the same thing again. With same text selected, I do Debug: Evaluate in Console and I get the following error:
!! Attempted to continue while not in a prompt
Things enter a strange state at this point. The game stops responding, as if the debugger had the game paused, but the debugger thinks the game is still running, the pause button doesn't do anything, and I cannot get the game to resume running without a full restart.
Really I'm just looking for a coding flow I can use where I can write code in the editor and evaluate it without having to save and reload the game every time. I thought the eval in console feature would be a good way to do that.
The text was updated successfully, but these errors were encountered:
Ahh, I am guessing that this error happens because I'm doing the debug:eval without the game paused. It seems that I need to set a breakpoint first, let the debugger pause, and then I can repeatedly do these evals OK.
It is interesting that the debug:eval never fails the first time I do it when the game is running.
So the next question would be, is the debugger supposed to support doing an eval while the game is running, similar to how it can be done via the game console? If so, I think there is a bug here. If not, I suggest printing a warning and rejecting the eval operation if the game is running.
I have the debugger up and running and everything is working fine in terms of breakpoints and using the console, but when I try to select this code in a lua file and use Debug: Evaluate in Console, it works the first time but fails the second time.
First time, it runs successfully and outputs the table and I can inspect it no problem.
Now I just do the same thing again. With same text selected, I do Debug: Evaluate in Console and I get the following error:
!! Attempted to continue while not in a prompt
Things enter a strange state at this point. The game stops responding, as if the debugger had the game paused, but the debugger thinks the game is still running, the pause button doesn't do anything, and I cannot get the game to resume running without a full restart.
Really I'm just looking for a coding flow I can use where I can write code in the editor and evaluate it without having to save and reload the game every time. I thought the eval in console feature would be a good way to do that.
The text was updated successfully, but these errors were encountered: