Quests that require "X" items

Talk about things that are not making games here. But you should also make games!

Moderators: Bob the Hamster, marionline, SDHawk

Post Reply
User avatar
maunderingcabal
Red Slime
Posts: 37
Joined: Sun Oct 30, 2016 8:49 am
Location: Hell, California
Contact:

Quests that require "X" items

Post by maunderingcabal »

Is there a way to run a script like the toll script, but instead use items? Like here is the original

Code: Select all

plotscript, a1, begin
Show text box (78)
wait for text box
if (check tag (tag: A1)) then (
 if (pay money (50)) then (
 set tag (tag: A1, on) 
 show text box (90)
 wait for text box) 
end
to make it something like this (I know the script is wrong for the check item:

Code: Select all

plotscript, a2, begin
Show text box (91)
wait for text box
  if (check tag (tag: A2)) then (
  check item (1,10)
  if (delete item (1,10)) then (
   set tag (tag: A2, on) 
   show text box (92)
   wait for text box)
end
Thanks for everyone on this forum. You guys are always really helpful!
Here is my OHRRPGCE Development Page: https://startru.wordpress.com. Follow us on Twitter @startruckerdev
User avatar
maunderingcabal
Red Slime
Posts: 37
Joined: Sun Oct 30, 2016 8:49 am
Location: Hell, California
Contact:

Post by maunderingcabal »

The only work around I can think of is to create an item in the shop to sell for 10 of the item to trigger the tags to continue the quest. I don't want to do that though, it seems sloppy.
Here is my OHRRPGCE Development Page: https://startru.wordpress.com. Follow us on Twitter @startruckerdev
KutKu
Red Slime
Posts: 31
Joined: Sun Jan 01, 2017 11:17 pm

Post by KutKu »

Hi hi!

I think I can offer some help on this. I've been brewing up a script that acts like the equip menu so hopefully I can offer up something.

So in the "Edit items" option, there's a condition (12th one iirc) you can activate for items called "is in invertory TAG (X) (ITEMNAME)" This condition basically checks "TAG (X)" as true so long as there are more than 0 (at least 1) of an item in your inventory.

You could try creating a script that checks for the condition of this tag every time they speak to whatever entity is acting as the gate keeper.

Code: Select all

global variable (5, tollcount) # I'm using the global declaration, variables are discarded within plotscripts after they finish

while (check tag (5) == TRUE) do( # as long as you have more than one of the "toll" item in your inventory, this will run!
	delete item ("tollitem", 1) # this will delete/remove the item from the player's inventory every loop
	tollcount += 1 # this will count how many of these items have been deleted/removed
)
if (tollcount == 10) then(
	show textbox (10) # "Yep that's ten in all" the reply the player gets for fufilling this
)
else(
	show textbox (11) # "You've got no "toll" items in your inventory, get lost!" # when the player has none of the items they need and haven't paid
)
That's the bare bones advice I can offer you. If you wanted to show a specific amount, you'll have to fudge around with the string functions Hspeak gives you. There's an option to insert string IDs into textboxes "${S#}" from game.exe. I think "globals to string" would help you get the correct value for telling the player how much more of an item they would need.
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

The scripting command you want is called "inventory" . It checks how many of an item you have in your inventory.
User avatar
Spoonweaver
Liquid Metal King Slime
Posts: 6462
Joined: Mon Dec 08, 2008 7:07 am
Contact:

Post by Spoonweaver »

to check the number of a specific item you'd use the command;

inventory (item)

example :
plotscript, a2, begin
Show text box (91)
wait for text box
if (check tag (tag: A2)),and,inventory (1)==10) then (
delete item (1,10)
set tag (tag: A2, on)
show text box (92)
wait for text box)
end
User avatar
maunderingcabal
Red Slime
Posts: 37
Joined: Sun Oct 30, 2016 8:49 am
Location: Hell, California
Contact:

Post by maunderingcabal »

You guys rock! Let me see if some of this works.
Here is my OHRRPGCE Development Page: https://startru.wordpress.com. Follow us on Twitter @startruckerdev
User avatar
maunderingcabal
Red Slime
Posts: 37
Joined: Sun Oct 30, 2016 8:49 am
Location: Hell, California
Contact:

Post by maunderingcabal »

OK getting this error with is code. Any ideas? I tried messing with the ")"s

Code: Select all

plotscript, a2, begin
 Show text box (79)
 wait for text box)
  if (check tag (tag: A2)),and,inventory (1)==10) then ( 
  delete item (1,10)  
  set tag (tag: A2, on)
  show text box (92) 
  wait for text box))
end
Attachments
error.JPG
error.JPG (22.75 KiB) Viewed 4296 times
Here is my OHRRPGCE Development Page: https://startru.wordpress.com. Follow us on Twitter @startruckerdev
User avatar
Spoonweaver
Liquid Metal King Slime
Posts: 6462
Joined: Mon Dec 08, 2008 7:07 am
Contact:

Post by Spoonweaver »

SORRY

there were some stray ) in there.
I wasn't really paying attention with my example.

Code: Select all

plotscript, a2, begin
  Show text box (79)
  wait for text box
    if (check tag (tag: A2),and,inventory (1)==10) then (
     delete item (1,10) 
     set tag (tag: A2, on)
     show text box (92)
     wait for text box
    )
end

Also, if you want to have a textbox tell the play how many more then need to collect you'd want something like this.
declare a variable

Code: Select all

global variable (5, tollcount)
assign 10 minus the amount of current items to the variable

Code: Select all

tollcount:=10--inventory (1)
Then you'd just need to add the ${V5} code into a textbox where you want the amount to appear.
Last edited by Spoonweaver on Thu Aug 10, 2017 1:26 am, edited 1 time in total.
User avatar
maunderingcabal
Red Slime
Posts: 37
Joined: Sun Oct 30, 2016 8:49 am
Location: Hell, California
Contact:

Post by maunderingcabal »

Spoonweaver wrote:SORRY

there were some stray ) in there.
I wasn't really paying attention with my example.

Code: Select all

plotscript, a2, begin
  Show text box (79)
  wait for text box
    if (check tag (tag: A2),and,inventory (1)==10) then (
     delete item (1,10) 
     set tag (tag: A2, on)
     show text box (92)
     wait for text box
    )
end
That worked! Thanks. Lets see if it all works now.
Here is my OHRRPGCE Development Page: https://startru.wordpress.com. Follow us on Twitter @startruckerdev
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

You'll probably want to write "inventory(item:carrot) >= 10" instead of "inventory(item:carrot) == 10"!

Also, no, you don't want to use "globals to string" for anything. It's obsolete and only is useful for one thing now (related to inspecting save slots).
User avatar
maunderingcabal
Red Slime
Posts: 37
Joined: Sun Oct 30, 2016 8:49 am
Location: Hell, California
Contact:

Post by maunderingcabal »

So I'm using this code and I'm so confused. I've been trying to fix this for like an hour and can't get it to work...

Code: Select all

plotscript, a2, begin 
 show text box (91)
 if (check tag (tag: A2),and,inventory(item:Iron Ore)>=10) then ( 
  delete item (1,10) 
  set tag (tag: A1, off)
  set tag (tag: A2, on) 
  show text box (92) 
  wait for text box 
  )
end 
The option to trade the ore works and the ore deletes, but the second text box does not come up after the trade. If I go back to talk to the NPC again the second box comes up and the tags fix. WTF mates?
Here is my OHRRPGCE Development Page: https://startru.wordpress.com. Follow us on Twitter @startruckerdev
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

Maybe throw in a 'wait for text box' right after the first text box?

EDIT: Actually that probably isn't it.

What I think may be happening though is that the tag "A2" is off the first time you talk to the NPC. However, maybe a setting in Edit NPCs... is enabled that turns that tag on when the NPC is used. Then you talk to them again, and on the second time the A2 tag is turned on, so it satisfies the if statement's requirement and the iron ore part of the script is ran.
Last edited by Foxley on Fri Aug 11, 2017 11:38 pm, edited 1 time in total.
User avatar
maunderingcabal
Red Slime
Posts: 37
Joined: Sun Oct 30, 2016 8:49 am
Location: Hell, California
Contact:

Post by maunderingcabal »

Foxley wrote:Maybe throw in a 'wait for text box' right after the first text box?

EDIT: Actually that probably isn't it.

What I think may be happening though is that the tag "A2" is off the first time you talk to the NPC. However, maybe a setting in Edit NPCs... is enabled that turns that tag on when the NPC is used. Then you talk to them again, and on the second time the A2 tag is turned on, so it satisfies the if statement's requirement and the iron ore part of the script is ran.
I feel incredibly dumb... adding that wait after the first text box fixed it...Thanks for the help!
Here is my OHRRPGCE Development Page: https://startru.wordpress.com. Follow us on Twitter @startruckerdev
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

Looks like I was over thinking it!
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Also, I notice that the "if" checks whether the tag A2 is on, and if so it does some stuff and turns it on. That's redundant. So maybe it's not what you wanted to write.
Post Reply