[SOLVED] Creating/spawning objects through script

For questions about using Classic.

Post » Mon Mar 15, 2010 10:56 am

I can't seem to create or spawn objects by using a script, say:

[code:j289hzd6]System.Create(Sprite,1,100,100)[/code:j289hzd6]

Doesn't seem to do anything. Am I doing something wrong? :?

Edit: I'm stupid. Quotation marks!
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Mon Mar 15, 2010 11:25 am

While this remains unresolved, I've found an alternative:
Using the Function Object, create a function "Create Object" with the following action:
System > Create Object by Name (Function.Param(1)) on layer (Function.Param(2)) at X (Function.Param(3)) and Y (Function.Param(4))

Then I use the following script to create the object:
[code:ey2068uy]Function.AddParam("Text")
Function.AddParam("Main")
Function.AddParam(System.MouseX)
Function.AddParam(System.MouseY)
Function.Call("CreateObject",0)
Function.ClearParams[/code:ey2068uy]

However, I'd like to be able to create objects directly through Python script. This is bit of a roundabout solution...
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Mon Mar 15, 2010 5:19 pm

here's how to make it work:
[code:250y764g]System.Create("Sprite",1,100,100)[/code:250y764g]
Notice the quotes.
B
79
S
24
G
53
Posts: 4,735
Reputation: 40,233

Post » Mon Mar 15, 2010 5:26 pm

Hmm, then what is the difference from System.CreateByName?
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Mon Mar 15, 2010 5:29 pm

In python no difference whatsoever, they both use the same action.
B
79
S
24
G
53
Posts: 4,735
Reputation: 40,233

Post » Mon Mar 15, 2010 5:37 pm

I see, thanks. At first it didn't work within quotes, but I've must made a subtle typo then.

Disregard this thread, I'm stupid.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Tue Mar 16, 2010 12:57 am

[quote="Mipey":1iffyn34]I see, thanks. At first it didn't work within quotes, but I've must made a subtle typo then.

Disregard this thread, I'm stupid.[/quote:1iffyn34]

Veteran bugfinder's are never stupid. They are just so busy with important things that miss something small ;-)
B
28
S
8
G
8
Posts: 530
Reputation: 7,154


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests