Scripts / Collect items to win the game?

Author
Message
DanTuga
9
Years of Service
User Offline
Joined: 24th Oct 2015
Location:
Posted: 25th Oct 2015 01:26
I was wondering how to make a script where you collect certain items and at the end you win the game?
PM
Pirate Myke
Forum Support
14
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 25th Oct 2015 01:36 Edited at: 25th Oct 2015 01:42
Name this script winitem.lua and place it in the scriptbank folder.

Assign it to the object you want to be the win object and when the player gets 80 units from it it will jump to an assigned level in the ifused field.

If no next level is assigned there, it will end the game.

In test game you will get a level complete trigger prompt, but when you build your stand alone, then you will see it end the game or jump to the next level.

Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit

smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 25th Oct 2015 09:05
That just finishes the level, doesn't take into account collecting objects.

Take a look at the cartoon demo level, that does what you're after.
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
kcan
9
Years of Service
User Offline
Joined: 13th Dec 2015
Location:
Posted: 16th Dec 2015 21:08 Edited at: 16th Dec 2015 21:14
Gameguru why do not provide this feature easily ?
Actualy my suggestion should be available event. For example İtem properies include No more item button, click no more ıtem button and activated and automatically should be display options Quit game, restart game, finish game increase health or lives and more. following photo
PM
wermer
9
Years of Service
User Offline
Joined: 18th Sep 2015
Location:
Posted: 16th Dec 2015 22:15
I think the feature is not quite that easy so we can have more flexibility with designs. The scripting allows for more complex systems, such as a game where you collect "100 Gold". You can do this not only by collecting 100 gold, but also by collecting 1000 silver, or 10 diamond - or any combination of these that equals 100 gold. As smallg said the example game "Cartoon Antics" shows a good example of how to achieve this. Cartoon Antics uses 2 scripts, but they could be in the same script if you like. Check \scriptbank\stories\Cartoon Antics\ for the scripts.

coincollect.lua - IF THE PLAYER TOUCHES COIN THEN MAKE SOUND, INCREMENT "CoinCount", REMOVE COIN
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 80 then
PlaySound(e,0)
CoinCount=CoinCount+1
Destroy(e)
end

coindisplay.lua - IF THE PLAYER HAS ALL THE COINS("CoinCount"=100) THEN END GAME GRACEFULLY
if CoinCount==100 then
HideImage(1)
FreezePlayer()
SetImagePosition(50,50)
ShowImage(3)
if g_KeyPressE == 1 then
UnFreezePlayer()
HideImage(3)
FinishLevel()
Destroy(e)
end
Prompt("Press E to close or Esc to end level.")
end

Windows 10 Home 64-bit / Intel i5 2500k @ 4.4Ghz + Asetek 510LC / Intel DP67DE / Intel 530 Series 240GB SSD / 12GB Kingston KVR 1333 / XFX Radeon R9 285 / Corsair TX 650 / Antec 300
PM

Login to post a reply

Server time is: 2024-12-22 10:25:49
Your offset time is: 2024-12-22 10:25:49