Help with your scripting

Trigger help please.

Trigger help please.

Postby epsilonion » 23 Jul 2015, 23:54

I have setup a trigger box with PhysX Trigger Volume and entered the code below in a microscript.

Code: Select all

obj = 0      -- | Define a variable for our object ID
entname =0;  -- | Define a variable for the entity name
fpstut =0;   -- | Define a variable for the tutorial GUI

function onInit(objID)
    obj = objID;
   gui.workSpace("tutorial/fps/");
   fpstut = gui.load("fpstut_container.rml",0,0);
   gui.hide(fpstut,fpstut);--hide this screen for now
   gui.hideCursor();--hide cursor as it shows if not used, still does not work
end

function onTrigger_Enter(hitID)
      
   entname = entity.getEntityName(hitID);
   
      if(entname == "Player")then            --If the player enters the trigger then go to pause game state.
         sky.setGameState(enum.GS_GamePaused());            
      end
   
   
end

function tutButtonEvent(Btn)                  --when the exit button of the gui is pressed hide gui and cursor
   if (Btn == "exit") then                      
      --gui.hide("fpstut","fpstut"); --gui.hideCursor();   -- hide the gui and cursor in exit of pause state.
      sky.setGameState(enum.GS_GameMain());         -- exit pause state and enter main game state.
   end
end

function onEnter( )
   sky.lprint("Main Entered");
end

function onEnter_GamePaused(  )               -- On entering the paused game state show gui and show cursor
   sky.lprint("Paused Entered");
   gui.show("fpstut","fpstut");
   gui.showCursor();
end

function onExit( )
   sky.lprint("Main Exit");
end

function onExit_GamePaused(  )               -- On exiting the paused game state hide gui and show cursor
   sky.lprint("Exit Paused ");
   gui.hide("fpstut","fpstut");                                      -- hide gui
   gui.hideCursor();                                                   -- hide cursor
end



when the player enters the trigger the game should go into a paused game state and a gui should be displayed and the cursor should be displayed.
when the exit button on the gui is pushed it should leave the paused state and enter the main game state, then it should hide the gui and cursor (well thats what I have been trying to do lol )but I get the error below and it does'nt work.

I know the path thing is messed up but it usually works when compiled and run to get around that error.

LUA ERROR: entity.callFn(..) failed. missing arg2 Target ID is invalid

and when exiting

_____________________________________________________________
|
| < GAME STOPPING >
|_____________________________________________________________

Main Exit
Main Entered
Main Entered
Main Entered
Main Entered
Main Entered
User avatar
epsilonion
Skyline Lead Moderator
Skyline Lead Moderator
 
Posts: 874
Joined: 26 Feb 2015, 11:51
Location: Hull, East Yorkshire, England
Skill: Business Manager
Skill: Great creative

Re: Trigger help please.

Postby CreativeOcclusion » 24 Jul 2015, 09:03

function onTrigger_Enter(hitID)

entname = entity.getEntityName(hitID);

if(entname == "Player")then --If the player enters the trigger then go to pause game state.
sky.setGameState(enum.GS_GamePaused());
end


end


Is the actual name of your player "Player" or is this the Tag...You may be trying to get the tag of the Player...You may try to use the getTagFromID()...

Code: Select all
function onTrigger_Enter(hitID)
             entname = entity.getTagFromID(hitID);
                if(entname == "Player")then            --If the player enters the trigger then go to pause game state.
                    sky.setGameState(enum.GS_GamePaused());           
               end
end


Not sure if this is the problem or not as I do not know what your player is named...or if "Player" is the name of your tag...just trying to help if I can...
Thanks, CreativeOcclusion
User avatar
CreativeOcclusion
Skyline Warrior
 
Posts: 366
Joined: 22 Jun 2015, 19:34
Location: Texas

Re: Trigger help please.

Postby ant0N » 24 Jul 2015, 09:35

Hi! :)
I did not find you the function: entity.callFn(..)
I think you have error in another script.
Sorry for my English. :)
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: Trigger help please.

Postby SolarPortal » 24 Jul 2015, 10:01

LUA ERROR: entity.callFn(..) failed. missing arg2 Target ID is invalid

This error is from the FPS Player because you have not added the HUD to the scene.
"RMB+click in the scene > Dynamic objects > FPS Kit: Full HUD"

This should remove the errors you are seeing to work on the script more :)

Here is the trigger event working based on what creative occlusion mentioned about the tag:
Code: Select all
function onTrigger_Enter(hitID)
   entname = entity.getTagFromID(hitID);
   if(entname == "Player")then       
      sky.setGameState(enum.GS_GamePaused());           
      sky.lprint("Player Detected...");
   end
end
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: Trigger help please.

Postby epsilonion » 24 Jul 2015, 14:56

It was ment to be like a pop up dialogue box with information about the game.

Several trigger boxes on the scene with different info on the pop ups so it isn't a hud per say but looking through the doc's couldn't see another way of doing it apart from displaying a picture and hit space to continue, tbh I don't know which would be easier lol
User avatar
epsilonion
Skyline Lead Moderator
Skyline Lead Moderator
 
Posts: 874
Joined: 26 Feb 2015, 11:51
Location: Hull, East Yorkshire, England
Skill: Business Manager
Skill: Great creative

Re: Trigger help please.

Postby StarFire » 24 Jul 2015, 15:55

You could display a simple gui for the "About" called from the lua trigger event as you can display multiple ui's ;)
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: Trigger help please.

Postby epsilonion » 24 Jul 2015, 16:29

Thats what I am trying to do lol,
its also started giving Particle Univers errors once I added the Hud..
User avatar
epsilonion
Skyline Lead Moderator
Skyline Lead Moderator
 
Posts: 874
Joined: 26 Feb 2015, 11:51
Location: Hull, East Yorkshire, England
Skill: Business Manager
Skill: Great creative

Re: Trigger help please.

Postby epsilonion » 24 Jul 2015, 16:37

This is what I am trying to display when the player collides with a trigger

I am trying to display this picture as information on say a tutorial.

newgame.png
trigger to show.
newgame.png (238.15 KiB) Viewed 10556 times



Attached is the scene file that I am trying to do it on, I already have a pause menu that seems to work when you press the P key (would rather that be the Escape key but that exits the game),


Errors:
The particle Universe errors came about when the FPS Hud was put in the scene.
If you rotate the FPS player to face a different direction the camera seems to rotate and the gun is no longer in front of you.
Every now and then after running the scene the terrain seems to go 1000% on the specular, reloading the scene seems to fix it for a short time.

Scene File: https://www.dropbox.com/s/0g90q84vdnimldo/example.zip?dl=0
Last edited by epsilonion on 24 Jul 2015, 17:12, edited 1 time in total.
Reason: more info
User avatar
epsilonion
Skyline Lead Moderator
Skyline Lead Moderator
 
Posts: 874
Joined: 26 Feb 2015, 11:51
Location: Hull, East Yorkshire, England
Skill: Business Manager
Skill: Great creative

Re: Trigger help please.

Postby CreativeOcclusion » 24 Jul 2015, 16:58

its also started giving Particle Univers errors once I added the Hud..


I get these too...I have been trying to figure this one out...It doesn't seem to affect game play, but I still don't like errors...
Thanks, CreativeOcclusion
User avatar
CreativeOcclusion
Skyline Warrior
 
Posts: 366
Joined: 22 Jun 2015, 19:34
Location: Texas

Re: Trigger help please.

Postby StarFire » 24 Jul 2015, 17:07

I will hunt down the errors once the new FPS player redesigning is started. I think they are Lua errors so could be removed, although I could be wrong without having a look. If not we could reduce the error message sensitivity to stop them completely for you. ;)
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: Trigger help please.

Postby epsilonion » 24 Jul 2015, 17:13

Just updated that post with scene file, gui, scripts etc.. :D
User avatar
epsilonion
Skyline Lead Moderator
Skyline Lead Moderator
 
Posts: 874
Joined: 26 Feb 2015, 11:51
Location: Hull, East Yorkshire, England
Skill: Business Manager
Skill: Great creative

Re: Trigger help please.

Postby StarFire » 24 Jul 2015, 21:03

Hey Liam, just found your problem and fixed it. We had put in a performance catch for all states other than the standard states, this catch prevented any scripts from running if the object was hidden(visibility) but with triggers and other volumes they are made invisible by default when playing the game thus no scripts could run on them. I have tested your scene on the new build and its now working fine.
The fix will be in the next update for you :D
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: Trigger help please.

Postby epsilonion » 24 Jul 2015, 22:36

Thank you very much..
User avatar
epsilonion
Skyline Lead Moderator
Skyline Lead Moderator
 
Posts: 874
Joined: 26 Feb 2015, 11:51
Location: Hull, East Yorkshire, England
Skill: Business Manager
Skill: Great creative


Return to Lua Scripting

Who is online

Users browsing this forum: No registered users and 5 guests

cron