#Create instance layer dosent work

13 messages · Page 1 of 1 (latest)

spice vessel
#

you are trying to add "player_instance" to the ds_list, but the scr_start_battle doesn't know what "player_instance" is

fierce flame
#

also what is player_instance and enemy_instance supposed to be, instance id's? something else?

because calling ds_list_sort will sort the list as is, not "by speed" - it'll only sort by speed if the list contains a list of speeds aka numbers, un attached to any instances

#

you might wanna look into using arrays instead and array_sort

array_sort is much more powerful than ds_list_sort

green tendonBOT
#

With this function you can sort an array in ascending order or descending order or using a custom function to define the sort order. The function requires you to provide the array to sort, and then either of the following:

Arguments
variable: The variable that holds the array.
**sorttype_or_function **: The sort type (true for ascending or false for descending) or a function reference to use for sorting.

fierce flame
#

if you look in the example, it shows how to sort an array of instances, but by their x value

weary galleon
#

Looking at the error I assume this code is in a script asset - scr_start_battle, right?
What are player_instance and enemy_instance?
Scripts are run when game starts, so if they are supposed to be some objects, they do not exist yet.
Are you on an old Gamemaker version or following old tutorial when scripts and function worked differently?

#

Hmm, haha, I'm not sure what gms2 means exactly - can you click on your IDE and runtime (top right corner), it will copy that numbers, and paste it here

#

Alright, so you're on the latest, it's called just Gamemaker now 🙂

#

ok, so are you following some older tutorial or this is your doing it "the old style"?

#

Generally you will want to wrap your scripts in a correct function syntax

#

Well, I can't answer that, because I don't know what you have and how that suppose to work, sometimes objects are generated with code, sometimes put by hand into room

#

Are you just starting with Gamemaker or you used old versions and are coming back?