This is where active bugs can be seen and where to post a new bug.

External Script bug

External Script bug

Postby SpiderMack » 28 Sep 2017, 22:34

Hi,

I have a scene with player and zombie mesh , zombie has Physix controller, i can run the game fine.

I made this code.

Code: Select all
 
moveMaxSpeed = 50

obj          = 0;
 

randomX = 0 ;
randomY = 0;

function onInit(objID)
   obj = objID;
   --character.setJumpDownforce(obj,850);
   character.setGravity(obj, 0, -10, 0);
   initialPos    = newType.vec3(entity.getPosition(obj));
   randomX =  math.random(1,5);
   randomY =  math.random(1,5);
   newPosition =  newType.vec3(entity.getPosition(obj));
   newPosition.x= newPosition.x + randomX ;
   newPosition.y = newPosition.y + randomX ;
end

function onUpdate( td )
   moveSpd       = moveMaxSpeed;
   character.move(obj, moveSpd );   
end


If i add this script as external file the editor crash :o
But if i add it as micro script the editor does not crash ?

What is the problem with external scripts ?
User avatar
SpiderMack
Skyline Expert
 
Posts: 441
Joined: 02 Dec 2016, 09:15
Skill: Concept artist
Skill: 3D Modeller
Skill: Level Designer
Skill: Scripter

Re: External Script bug

Postby Shando » 28 Sep 2017, 22:57

Hey buddy,

External Scripts work fine for me. How are you calling it?

I use:

Code: Select all
sky.include ( "external_script.lua" )


Shando
Ryzen 7 4800H 16GB GTX1650 Win 11 64
Love, Hope, Strength http://www.lovehopestrength.co.uk
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: External Script bug

Postby SpiderMack » 28 Sep 2017, 23:02

Hey Shando,

Where do you write that include ?
User avatar
SpiderMack
Skyline Expert
 
Posts: 441
Joined: 02 Dec 2016, 09:15
Skill: Concept artist
Skill: 3D Modeller
Skill: Level Designer
Skill: Scripter

Re: External Script bug

Postby Shando » 28 Sep 2017, 23:15

Hey again,

You can write it anywhere, but usually at the top of the script, so that it's available throughout.

I have, however, also used an if..then to determine which external script to load. Just remember that it will *ONLY* be available after it has been loaded.

HTH

Shando
Ryzen 7 4800H 16GB GTX1650 Win 11 64
Love, Hope, Strength http://www.lovehopestrength.co.uk
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: External Script bug

Postby SolarPortal » 29 Sep 2017, 10:26

Thanks for helping out @Shando :D

@Spidermack, could you write what actions you have applied to the character. Are you using both a microscript and external script.
Would love to replicate this one and fix any crashes found :)
Even sending a preset of the zombie should do it and i can copy the code from the forum post :)
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: External Script bug

Postby SpiderMack » 29 Sep 2017, 13:08

The bug can be closed.

Shando resolved it.

Any external script must have
Code: Select all
sky.include ( "external_script.lua" )

Otherwise this will make crash the editor when running the scene.
User avatar
SpiderMack
Skyline Expert
 
Posts: 441
Joined: 02 Dec 2016, 09:15
Skill: Concept artist
Skill: 3D Modeller
Skill: Level Designer
Skill: Scripter

Re: External Script bug

Postby StarFire » 29 Sep 2017, 13:19

Just avoid confusion, the include script is not the objects "external script", but another lua script residing in a file who's contents are included into the objects script. :)
Dream the Journey, Live the Experience!
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1678
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer

Re: External Script bug

Postby SolarPortal » 29 Sep 2017, 14:48

also to note, that you cannot have a script such as a microscript or external including a file that also contains the base event functions such as:

onInit()
postInit()
onUpdate()
onKeyDown()
onKeyUp()
etc...

The included scripts(sky.include("*.lua")) should have their own function which is then called in the main scripts skyline event functions and not sharing the same function names :)
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: External Script bug

Postby StarFire » 29 Sep 2017, 16:24

Just tried the script you wrote and its fine. just make sure you saved it, check in the properties.

Clipboard Image.jpg
Clipboard Image.jpg (11.16 KiB) Viewed 8590 times
Dream the Journey, Live the Experience!
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1678
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer

Re: External Script bug

Postby StarFire » 29 Sep 2017, 16:33

Just thought you may of had an issue due to the script not being in the resources. When a script is created, which I presume you did. It needs to be added to the resources system, now this is done for you automatically but will throw up a box asking you do you want to add this script.... if you clicked no then it will be ignored.

Try this:
Go the the scripts folder in asset manager and click on the folder to display its contents. Now if its added to resources nothing will happen, except showing the folder contents. If its not then the Message box will show.
Dream the Journey, Live the Experience!
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1678
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer


Return to Active / New Bugs

Who is online

Users browsing this forum: No registered users and 2 guests

cron