Hi! Welcome to the forum for Platinum Arts Sandbox Free 3D Game Maker. I currently have the forums locked as I am attempting to properly update them.

In the meantime please join the new Discord Server!

If you have any questions please e-mail me through the Platinum Arts website.

Scripting for a Quest

Talk about anything related to Platinum Arts Sandbox here!
Locked
User avatar
GoBologna120
Member
Member
Posts: 167
Joined: June 10th, 2009, 3:07 pm
Name: Tim
IRC Username: GoBologna
Location: Nowhere in particular.

Scripting for a Quest

Post by GoBologna120 »

For those of you who have downloaded my recent map, The Factory, this script may look familiar to you.

Code: Select all

"on_start" = [
	"item_1" = 0
	"item_2" = 0
	"item_3" = 0
	"item_4" = 0
	"item_5" = 0
	"quest" = 0
	"quest_1_comeplete" = 0
	"money" = 20
	newgui main [
		guibutton "Game Status" "showgui Status"
		guibutton "Unload UI" "newgui main [ @main ]"
		guibar
		@main
	]
]

newgui "Status" [
	if ( = $quest 0 ) [
		guitext "You have obtained no tasks."
		guitext "Go talk to some workers."
	]
	if ( = $quest 1 ) [
		guitext "A worker needs help charging their console."
		guitext "Find an energy capsule to charge it with."
	]
	guibar
	guitext ( format "You have $%1 in your wallet." $money )
	guitab "Items"
	if ( > $item_1 0 ) [
		guitext ( format "You have %1 energy capsule(s)." $item_1 )
	]
	if ( > $item_2 0 ) [
		guitext ( format "You have %1 marshmallow(s)." $item_2 )
	]
	if ( > $item_3 0 ) [
		guitext ( format "You have %1 footlong sub(s)." $item_3 )
	]
	if ( > $item_4 0 ) [
		guitext ( format "You have %1 nothing(s)." $item_4 )
	]
	if ( > $item_5 0 ) [
		guitext ( format "You have %1 item(s)." $item_5 )
	]
]

newgui "Worker (Quest 1)" [
	if ( = $quest 0 ) [
		guitext "This console is out of order." chat
		guitext "I can't work like this." chat
		guitext "Could you help me fix it?" chat
		guibutton "Yes" "quest  = ( + $quest 1 )"
		guibutton "No" "cleargui"
	]
	if ( = $quest 1 ) [
		guitext "The console should respond if we give it a charge." chat
		guitext "Perhaps an energy capsule would do the trick?" chat
	]
]

newgui "Vending Machine" [
	guitext "WHAT DO YOU WANT TO BUY?"
	guibar
	guibutton "ENERGY CAPSULE: $10" [
		if ( > $money 9 ) [
			money = ( - $money 10 )
			item_1 = ( + $item_1 1 )
		]
	]
	guibutton "FOOTLONG SUB: $5" [
		if ( > $money 4 ) [
			money = ( - $money 5 )
			item_3 = ( + $item_3 1 )
		]
	]
	guibutton "NOTHING: FREE" [ item_4 = ( + $item_4 1 ) ]
	guibutton "I don't want anything." [ cleargui ]
]

"level_trigger_1" = [
	echo "What are you thinking?"
	echo "There's nowhere to go out there."
]

"level_trigger_2" = [
	newgui "Worker" [
		guitext "BOOM!  HEADSHOT!" chat
		guitext "Wait!  Um, I mean... The power circuit is clear, sir." chat
	]
	showgui "Worker"
]

"level_trigger_3" = [
	newgui "Worker" [
		guitext "That guy over there really needs to get to work." chat
	]
	showgui "Worker"
]

"level_trigger_4" = [
	newgui "Worker" [
		guitext "Mmm... marshmallows..." chat
	]
	showgui "Worker"
	sleep 3000 [
		echo "<Obtained a marshmellow.>"
		item_2 = ( + $item_2 1 )
		newgui "Worker" [
			guitext "Here.  You can have this one." chat
		]
		showgui "Worker"
	]
]

"level_trigger_5" = [
	showgui "Worker (Quest 1)"
]

"level_trigger_6" = [
	showgui "Vending Machine"
]

"level_trigger_7" = [
	newgui "Sarge" [
		guitext "HELLO!  I AM MR. FREDRICKSON!" chat
		guitext "I'M HERE TO MAKE SURE YOU MAGGOTS STAY ON TASK!" chat
		guitext "I WONDER WHY EVERYONE CALLS ME SARGE!" chat
	]
showgui "Sarge"
]
The part I'm worried about is this:

Code: Select all

newgui "Worker (Quest 1)" [
	if ( = $quest 0 ) [
		guitext "This console is out of order." chat
		guitext "I can't work like this." chat
		guitext "Could you help me fix it?" chat
		guibutton "Yes" "quest  = ( + $quest 1 )"
		guibutton "No" "cleargui"
	]
	if ( = $quest 1 ) [
		guitext "The console should respond if we give it a charge." chat
		guitext "Perhaps an energy capsule would do the trick?" chat
	]
]
I have three things I want to do with this part of the script:

1.) I want the second textbox to show up if you click yes. It's annoying having to go backward and forward just to see what he has to say next.

2.) I want to be able to finish the quest. The worker will say "Thank you. Here's a little something for helping me." and then he'll give you some money. This will also set $quest back to 0 and set $quest_1_comeplete to 1.

3.) I want the previous to also affect what the NPC says to you, since $quest will equal 0 again. Who wants to do the same thing over and over?

Any help would be appreciated. Thanks.
Image
Yay. ^_^
Hirato
Developer
Developer
Posts: 689
Joined: May 30th, 2009, 1:23 pm
IRC Username: hirato

Re: Scripting for a Quest

Post by Hirato »

let quest1 = 2 be the thank you messages?

and you can do more than 1 thing in a fucntion, just eb sure to separate them with ;'s or newlines
This is not a url, clicking it is pointless
Locked