Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Check if item have been taken  (Read 5164 times)

0 Members and 1 Guest are viewing this topic.

Yakuzza

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 50
    • View Profile
Check if item have been taken
« on: October 02, 2012, 06:59:03 PM »

Let's say to go to the next scene player must pick up 5 items from the various scenes.
Can someone please point me to the right direction on how to script it?
Logged

lof

  • Lurker
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 19
  • A Leap Of Fate
    • View Profile
Re: Check if item have been taken
« Reply #1 on: October 02, 2012, 07:33:06 PM »

if (Game.HasItem("itemname") && Game.HasItem("itemname") etc etc etc)
{
Game.ChangeScene("scenename");
}
else
{
actor.Talk("I need to pick up, itemnames before leaving the room.");
}
Logged

Yakuzza

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 50
    • View Profile
Re: Check if item have been taken
« Reply #2 on: October 02, 2012, 08:15:28 PM »

yeah i've tried that already
Code: [Select]
if (Game.HasItem("200euro") && Game.HasItem("I_Hairpin") && Game.HasItem("I_lipstick"))
{
Game.ChangeScene("scenes\Basement\Basement3\Basement3.scene", false, false);
}
else
{
Sleep(200);
}

but the game does nothing when all 3 items picked up
Logged

lof

  • Lurker
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 19
  • A Leap Of Fate
    • View Profile
Re: Check if item have been taken
« Reply #3 on: October 02, 2012, 11:33:55 PM »

hmm it should work.
when picking up items are you using Game.TakeItem or actor.TakeItem ?

i am assuming this happens in a script file with , on "LeftClick" and attached to the exit entity?
« Last Edit: October 02, 2012, 11:37:39 PM by lof »
Logged

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: Check if item have been taken
« Reply #4 on: October 03, 2012, 11:54:05 AM »

You could try using

Code: WME Script
Logged

Yakuzza

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 50
    • View Profile
Re: Check if item have been taken
« Reply #5 on: October 03, 2012, 02:54:32 PM »

Oh I didn't realize it has to be "OnLeftClick". I thought game gonna constantly check if items has been taken.
Anyway it works now.
Thanks for your help guys!
Logged

lof

  • Lurker
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 19
  • A Leap Of Fate
    • View Profile
Re: Check if item have been taken
« Reply #6 on: October 03, 2012, 07:20:46 PM »

:) sure no problem.

you can put it all in loop, it should work, but i haven't tried it.

Code: WME Script
  1. while (true)
  2. {
  3. if (Game.HasItem("200euro") && Game.HasItem("I_Hairpin") && Game.HasItem("I_lipstick"))
  4. {
  5. Game.ChangeScene("scenes\Basement\Basement3\Basement3.scene", false, false);
  6. }
  7. else
  8. {
  9. Sleep(200);
  10. }
  11. Sleep(20);
  12. }
« Last Edit: October 03, 2012, 07:22:40 PM by lof »
Logged

Yakuzza

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 50
    • View Profile
Re: Check if item have been taken
« Reply #7 on: October 06, 2012, 07:59:46 PM »

Thanks again lof!
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Check if item have been taken
« Reply #8 on: October 07, 2012, 12:17:22 AM »

To be honest - this "check in the loop" is a terrible advice. It will add a lot of unpredictability to your game. Typically when another action will be taking place suddenly player gets random scene change. Is it what you want?

What I personally would do is to make a global Scene method which would be called after each TakeItem.

So:

in scene_init.script

Code: WME Script
  1.  
  2. method CheckAllItems()
  3. {
  4.     if (actor.HasItem("item 1") && actor.HasItem("item 2") && actor.HasItem("item 3"))
  5.     {
  6.          Game.ChangeScene("scenes\Basement\Basement3\Basement3.scene", false, false);
  7.     }
  8. }
  9.  

then when you pick either of those items simply do:

Code: WME Script
  1.  
  2. actor.TakeItem("item 1");
  3. Scene.CheckAllItems();
  4.  
  5.  

This way you exactly can control where your scene changing occurs and you'll save yourself tons of pulled hair from impossible to replicate bugs reported by your testers.

Just my 2 cents.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet
 

Page created in 0.048 seconds with 19 queries.