Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Interesting code needed for lantern/pickup functions
Apfel Offline
Junior Member

Posts: 19
Threads: 3
Joined: Jun 2011
Reputation: 1
#3
RE: Interesting code needed for lantern/pickup functions

Here is something I got managed to work similar to what you wanted.


- When you grab an object and you use your lantern the grabbed object will be dropped.
- when your lantern is active and you try to grab an object the lantern will be switched off automatically (you can change it to manual, see commentary in the script).
- there is a timer to prevent to grab an object while the switch off animation of the lantern is still going on.
- Instead of normal messages I used debug-messages, so they need to be exchanged (bolded text)

regarding to your second request:
"2) The lantern should be impossible to use while holding an object, and display a message along the lines of "Drop that object to use your lantern!" when you try to use it."

I can do this, too, but without the message, because the lantern callback wouldn't be called when the lantern is disabled and/or has no oil.



script:

Spoiler below!


void OnStart()
{
SetLanternLitCallback("lantern");
for(int i=1; i<=8; i++) SetEntityPlayerInteractCallback("entity_"+i, "holding_entities", false);
}


void lantern(bool abLit)
{
RemoveTimer("lantern_switch_off_animation");
AddTimer("lantern_switch_off_animation", 0.6f, "");
for(int i=1; i<=8; i++) if(GetPropIsInteractedWith("entity_"+i) && abLit) AddDebugMessage("________You dropped the object because you used your lantern!______", false);
ChangePlayerStateToNormal();
}

void holding_entities(string &in asEntity)
{
if(GetTimerTimeLeft("lantern_switch_off_animation") != 0) ChangePlayerStateToNormal();
// This prevents the player to pick up an object while the
// switch-off animation is still playing, just for logical
// purpose (it is weird when you can still see the hand on
// the lantern while carrying something... all with one hand)


if(GetLanternActive())
{
AddDebugMessage("________You cannot hold an object while using your lantern!______", false);

// This is for switching off the lantern automatically/manually
SetLanternActive(false, false); // automatic
//ChangePlayerStateToNormal(); // manual
}
}


09-11-2013, 03:21 PM
Find


Messages In This Thread
RE: Interesting code needed for lantern/pickup functions - by Apfel - 09-11-2013, 03:21 PM



Users browsing this thread: 1 Guest(s)