Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/www/users/phun/forum/include/common.php on line 58

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/phun/forum/include/common.php:58) in /usr/www/users/phun/forum/header.php on line 31

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/phun/forum/include/common.php:58) in /usr/www/users/phun/forum/header.php on line 32

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/phun/forum/include/common.php:58) in /usr/www/users/phun/forum/header.php on line 33

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/phun/forum/include/common.php:58) in /usr/www/users/phun/forum/header.php on line 34
Phun - 2D physics sandbox - forum / [scripting] how to spawn an existing scene

Phun - 2D physics sandbox - forum

Official Forum

You are not logged in.

#1 2009-06-03 13:30:07

Bronie12345
wolverina
From: The Forest
Registered: 2008-06-20
Posts: 1355
Website

[scripting] how to spawn an existing scene

well, you all know that it is hard to create something with scripting, but i found a simple solution
just scripting isnt enough for it, you have to look in your folders and scenes also...

step 1
search for a nice scene (art or mech, doesnt matter)
i use one of my own scenes as an example, something simple...
link to the example

step 2
now you have a simple scene, saved as a phz file
search for the phz file, and change the file extension into .zip

step 3
open the zip file (extract or not, doesnt matter)
now you see 3 files
a text file, an image file, and a phn file
open the phn file with wordpad or an other text editor that doesnt show weird signs but text (notepad for instance doesnt work)

step 4
in the text you now see a couple of settings, but dont use them
search for this text: scene.addPlane {........
now remove all line breaks in the code (i suggest using this tool (thnx to standardtoaster)

step 5
now you have a very long line of code
copy this code (ctrl+c)

step 6
open phun, make a box and select it
search for the script menu (be sure advanced mode is enabled)
if you dont see the script menu, goto step 6.5, if you see the script menu, goto step 7

step 6.5
open the console (with ` )
type in: App.enableScriptMenu
yes, the caps does matter in this case
now, select the box again and search for the script menu (if it still isnt there, repeat this step, if it IS there, goto step 7)

step 7
once you have opened the script menu, search for: onCollide
this should be in the text box after that: (e)=>{}
set your cursor between the {}

step 8
press ctrl+v (if not the whole code appears, repeat this tut from step 3)
now press enter (or else the code wont be saved)

step 9
exit the script menu, and now make a mech to collide with the box that has the script when you press a key (enter as an example)

step 10
now put it on a fighter or something, and enjoy it spawning some simple fighting bots


thats it



notes:
u should take the planes out of the scene, or use a phunlet

this makes it spawn at only one place, but not in front of the object
to make it spawn infront of the object, paste "e.pos+[1, 1]+" after the =, but b4 the [
like this: "pos = [0.000001, 12.56]" becomes: pos = e.pos+[1, 1]+[0.000001, 1]
the 1 is becus otherwise it will fall from hight, but take always the same number to make it less (1 becomes -2, 40 becomes 37 etc...)

Last edited by Bronie12345 (2009-06-03 13:56:55)


http://i484.photobucket.com/albums/rr204/Bronie12345/blueside333x250.jpg     need off-road tires for your phun car? pm me
http://i540.photobucket.com/albums/gg327/ioncann0ns/ubd9085-1.png                need a powerful engine for your phun car? pm me

Offline

 

#2 2009-06-03 13:40:39

standardtoaster
Posting Lord
Registered: 2008-04-30
Posts: 1042
Website

Re: [scripting] how to spawn an existing scene

Bronie12345 wrote:

now prepair for a long taking job: working the enters out (find and replace if very handy)

A better way to do it would be to go http://www.textfixer.com/tools/remove-line-breaks.php, paste your text in the top textbox, and check off remove line breaks and paragraph breaks.


www.stykz.net pretty much a mac version of pivot but with more features. Windows version is out! It will also be made for Linux 2009.

My phun scenes

Offline

 

#3 2009-06-03 13:42:11

Bronie12345
wolverina
From: The Forest
Registered: 2008-06-20
Posts: 1355
Website

Re: [scripting] how to spawn an existing scene

thanx sdtoaster
ill add it to the tut tongue


http://i484.photobucket.com/albums/rr204/Bronie12345/blueside333x250.jpg     need off-road tires for your phun car? pm me
http://i540.photobucket.com/albums/gg327/ioncann0ns/ubd9085-1.png                need a powerful engine for your phun car? pm me

Offline

 

#4 2009-06-03 22:25:25

HoodlumExMx
Seasoned Member
From: :P
Registered: 2009-04-26
Posts: 52

Re: [scripting] how to spawn an existing scene

How do you change the file extension?


http://internetometer.com/image/2222.png

Offline

 

#5 2009-06-04 00:42:50

Bronie12345
wolverina
From: The Forest
Registered: 2008-06-20
Posts: 1355
Website

Re: [scripting] how to spawn an existing scene

select the phz file
right mouse click on the phz file and click on: change filename
now you can change the filename...
change it to: temp.zip (or something like that)
you're done
if you dont see the file ext in the name, you should enable that in the windows folder view options... (dunno how it is at mac or linux)


http://i484.photobucket.com/albums/rr204/Bronie12345/blueside333x250.jpg     need off-road tires for your phun car? pm me
http://i540.photobucket.com/albums/gg327/ioncann0ns/ubd9085-1.png                need a powerful engine for your phun car? pm me

Offline

 

#6 2009-06-04 02:51:22

HoodlumExMx
Seasoned Member
From: :P
Registered: 2009-04-26
Posts: 52

Re: [scripting] how to spawn an existing scene

How do you go to the windows view options?


http://internetometer.com/image/2222.png

Offline

 

#7 2009-06-04 07:37:11

Bronie12345
wolverina
From: The Forest
Registered: 2008-06-20
Posts: 1355
Website

Re: [scripting] how to spawn an existing scene

this is for windows 7 (not on my own comp right now)
goto control panel
goto appearance and personalization
goto folder options
goto the tab: view
uncheck: hide extensions for known file types

for windows XP: (this will come here when im home)


http://i484.photobucket.com/albums/rr204/Bronie12345/blueside333x250.jpg     need off-road tires for your phun car? pm me
http://i540.photobucket.com/albums/gg327/ioncann0ns/ubd9085-1.png                need a powerful engine for your phun car? pm me

Offline

 

#8 2009-06-07 22:39:45

HoodlumExMx
Seasoned Member
From: :P
Registered: 2009-04-26
Posts: 52

Re: [scripting] how to spawn an existing scene

Bronie12345 wrote:

this is for windows 7 (not on my own comp right now)
goto control panel
goto appearance and personalization
goto folder options
goto the tab: view
uncheck: hide extensions for known file types

for windows XP: (this will come here when im home)

Thanks!


http://internetometer.com/image/2222.png

Offline

 

#9 2009-06-08 00:11:36

Bronie12345
wolverina
From: The Forest
Registered: 2008-06-20
Posts: 1355
Website

Re: [scripting] how to spawn an existing scene

you have windows 7 then?
or windows vista, they are atthis point almost the same st folders...


http://i484.photobucket.com/albums/rr204/Bronie12345/blueside333x250.jpg     need off-road tires for your phun car? pm me
http://i540.photobucket.com/albums/gg327/ioncann0ns/ubd9085-1.png                need a powerful engine for your phun car? pm me

Offline

 

#10 2009-06-10 10:36:17

HoodlumExMx
Seasoned Member
From: :P
Registered: 2009-04-26
Posts: 52

Re: [scripting] how to spawn an existing scene

I have windows XP.
Its similar to 7.


http://internetometer.com/image/2222.png

Offline

 

#11 2009-06-10 11:22:40

guyboy
Phunky Munkey
From: Zürich, Switzerland
Registered: 2008-04-02
Posts: 1866

Re: [scripting] how to spawn an existing scene

A much easier way to do this is:

step 1
Open notepad, type something, and copy the text. (This makes sure copying in phun works)

step 2
In your phun scene, select what you want to spawn, and press CTRL+C

step 3
Paste into line break remover, and remove.

step 4
Copy from line break remover.

The rest like above post...


http://i38.tinypic.com/s474pl.jpg
Human horse pasture expansion OpenGL Book Hall
Kwon owned Version (C) 2002-2008

Offline

 

#12 2009-06-10 11:30:44

Bronie12345
wolverina
From: The Forest
Registered: 2008-06-20
Posts: 1355
Website

Re: [scripting] how to spawn an existing scene

i dont get it, guyboy...


http://i484.photobucket.com/albums/rr204/Bronie12345/blueside333x250.jpg     need off-road tires for your phun car? pm me
http://i540.photobucket.com/albums/gg327/ioncann0ns/ubd9085-1.png                need a powerful engine for your phun car? pm me

Offline

 

#13 2009-06-10 14:31:24

guyboy
Phunky Munkey
From: Zürich, Switzerland
Registered: 2008-04-02
Posts: 1866

Re: [scripting] how to spawn an existing scene

Bronie12345 wrote:

i dont get it, guyboy...

=O You don't???

Copy objects in phun and paste into notepad... smile


http://i38.tinypic.com/s474pl.jpg
Human horse pasture expansion OpenGL Book Hall
Kwon owned Version (C) 2002-2008

Offline

 

#14 2009-06-10 15:04:09

Bronie12345
wolverina
From: The Forest
Registered: 2008-06-20
Posts: 1355
Website

Re: [scripting] how to spawn an existing scene

now i get it tongue


http://i484.photobucket.com/albums/rr204/Bronie12345/blueside333x250.jpg     need off-road tires for your phun car? pm me
http://i540.photobucket.com/albums/gg327/ioncann0ns/ubd9085-1.png                need a powerful engine for your phun car? pm me

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson

Phun and Phunland.com is copyright of Algoryx