Mornedil
Member
I've had an idea for a while but not sure the best way to do it, so I thought I'd ask what everyone here on the forums think.
Players will be able to add their own behaviors to objects through a simple drag-and-drop system, then use those objects in gameplay. Imagine the drag-and-drop system in GameMaker:Studio, where you can add different actions, and if-then-else blocks as well.
The part about making the drag-and-drop editor is pretty straight forward, what I want to ask about is what you think would be the best way to perform the list of actions during gameplay? What would the easiest way to make it? What would give the best performance? etc, etc.
I have 2 different ideas so far:
1. save all D&D actions to an array, and loop through it during gameplay to perform the actions:
2. Generate a string code from the actions, and use an interpreter during gameplay to perform the actions:
These are the 2 ideas I have right now, maybe there are even better ways. How would you proceed with this?
Players will be able to add their own behaviors to objects through a simple drag-and-drop system, then use those objects in gameplay. Imagine the drag-and-drop system in GameMaker:Studio, where you can add different actions, and if-then-else blocks as well.
The part about making the drag-and-drop editor is pretty straight forward, what I want to ask about is what you think would be the best way to perform the list of actions during gameplay? What would the easiest way to make it? What would give the best performance? etc, etc.
I have 2 different ideas so far:
1. save all D&D actions to an array, and loop through it during gameplay to perform the actions:
I've tried this by storing values in a 2D array in the following pattern:
[n, 0] = script_index
[n, 1] = first argument
[n, 2] = second argument
etc, etc.
Then I just loop through the array and use script_execute() to execute the script_index with the arguments stored in the array. I've tested it and it works, although I have to add all behaviors as script resources, including scripts that simulate if-statements (if it's true it performs X amount of actions below it, else it skips them). This method would mean a lot of extra work to build from scratch how the system works. I'm also not sure how well this system would perform on a large scale.
[n, 0] = script_index
[n, 1] = first argument
[n, 2] = second argument
etc, etc.
Then I just loop through the array and use script_execute() to execute the script_index with the arguments stored in the array. I've tested it and it works, although I have to add all behaviors as script resources, including scripts that simulate if-statements (if it's true it performs X amount of actions below it, else it skips them). This method would mean a lot of extra work to build from scratch how the system works. I'm also not sure how well this system would perform on a large scale.
2. Generate a string code from the actions, and use an interpreter during gameplay to perform the actions:
This seems pretty straight forward, just taking the player's D&D actions, generate a string from them, and let the interpreter do it's work. Then it's just the question of finding the best interpreter, I've seen a few GML interpreters on the marketplace. So the real question here is performance, as far as I know interpreters are not exactly known to be fast, although I'm not sure how slow they are exatly.
These are the 2 ideas I have right now, maybe there are even better ways. How would you proceed with this?
Last edited: