Create object of type?

Stultissimus
18 Dec 2022, 16:50

Hey, I just started playing around with Quest, but I have some experience with coding. I haven't done anything particularly complex yet. I'm just trying to get my feet wet. I created a "mob" object type with a single attribute and I made a little function to dynamically create an object of type "mob."

game.StupidGame_total_mobs = game.StupidGame_total_mobs + 1
new_mob = create ("mobid%game.StupidGame_total_mobs%", "mob")
return new_mob

But when I call the function, it throws the error

Error running script: Error compiling expression 'create ("mobid%game.StupidGame_total_mobs%", "mob")': FunctionCallElement: Could find not function 'create(String, String)'

According to the documentation, create (string name, string type) is how you create an object of a specified type. So what am I doing wrong here?

Edit: Adding that I am using Quest desktop version 5.8.0


mrangel
18 Dec 2022, 17:04

Create is a statement, not a function. It does not return a value, and must be the only thing on the line.

If you want the element, you need to get it by passing the same name to GetObject.

I think you probably want something like:

mobname = GetUniqueElementName ("mob")
create (mobname, "mob")
return (GetObject (mobname))