Scripts / another attempt at a shop script

Author
Message
Honkeyboy
3D Media Maker
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 23rd May 2021 14:00 Edited at: 23rd May 2021 19:21
ok having a day off mapping and trying to get my scripting head on i have written a selling shop script now which works ok so far, well the very basics of one but for some reason the buying shop will not buy the first item "berries" works for the second but not the first so I'm confused can anyone point out why please? ( please bare with me as this is only the first draft )

this one seems to work ok.




this one doesn't sell the first item to the player



Edit: ahh spodded it forgot to delete the last couple of lines ..... I'll just blame that on the second covid jab giving my head a beating lol

Edit 2: I've found that for some reason if i use the same scancode keys in both the buying and selling shop scripts they don't work if i use different ones they do, do i need to add a condition or something? weird that the scripts interfere with each other in that way or is it just me being braindead again?
Intel i5 4950 Quad core 3.3ghz AMD FX 6300 x6 cores 3.5ghz(unclocked)
8gb Ram 8gb Ram
XFX R5 2gb AMD Radeon HD 6670 2gb
and a well fed mouse on a wheel

I only smile because i have absolutely no idea whats going on
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 23rd May 2021 19:38

Hey there.
Yeah, always set a
pressed = 1
directly after your if GetScancode() =

Also alterior (predominate / above) to any if statement (ran every frame)
needs a;
if g_Scancode == 0 then pressed = 0 end
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 23rd May 2021 19:50
Funny you should bring up Covid- which I had way, way early first week of 2020. It put me out for 3+ weeks, but since then and probably being passive all this year, my concentration seems to have diminished. LOL
So I was working on "shop" scripts, but what's difficult in doing so for other people would be to know exactly what vision the other person has. What will it look like, what location on screen and so forth they intend to use. They seem to be a project specific script that would be different for each user. Let me look at them again and see where I left off.
PM
Honkeyboy
3D Media Maker
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 23rd May 2021 20:16 Edited at: 23rd May 2021 20:22
Oh right got you yes m8 they are project specific project is here.
https://forum.game-guru.com/thread/220833
p.s the new build is all on the second half of page 2 as i had to rebuild it all AGAIN! lol
It's based on a story/aurora module I wrote years ago for NWN about Giants hence the title but in GG I have made it bigger so you now have professions one of which is a trader so basically you can travel to different continents and buy/sell goods for profit and experience up till master trader. Check the WIP m8 you'll get an idea of where I'm going
Intel i5 4950 Quad core 3.3ghz AMD FX 6300 x6 cores 3.5ghz(unclocked)
8gb Ram 8gb Ram
XFX R5 2gb AMD Radeon HD 6670 2gb
and a well fed mouse on a wheel

I only smile because i have absolutely no idea whats going on
Honkeyboy
3D Media Maker
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 25th May 2021 16:14 Edited at: 25th May 2021 16:24
well i now have the two shops working each selling or buying 10 items both set up atm with the same selling/buying values to be later set up to make a small profit depending how you work it. ( I think I've asked about the button press before but havent found it in my older posts yet )



The buying shop



The Selling Shop




Only two issues to sort out the first is that when you press a key to sell an item you sell them all or multiples at least so that needs sorting

the second for some reason when i use the same keys for both shops e.g 1-10 they dont seem to work when on the same map hence me using 1-10 for buying and number pad keys for selling. Which is kind of ok but I can see it creating problems when I introduce a new shop.
so if anyone could show me how to cure that I'd be grateful and also tell me why whatever code is needed and what it does exactly. If i get that in my head it will make it easier for me in the future
Cheers guys
Intel i5 4950 Quad core 3.3ghz AMD FX 6300 x6 cores 3.5ghz(unclocked)
8gb Ram 8gb Ram
XFX R5 2gb AMD Radeon HD 6670 2gb
and a well fed mouse on a wheel

I only smile because i have absolutely no idea whats going on
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 25th May 2021 18:02
Hi Honkeyboy.
Sure. Let me point out that you "just missed a spot"
maybe my directions above where too vague-- I can mumble I know.

notice that on your buying script AT THE BEGINNING you have:
pressed = 1 - - - - - PART OF THE TIME
but then it's missing for a portion of your script mid-way through the checks
------------------------------ from your script -----------------------------------------

elseif GetScancode() == 6 and pressed == 0 and g_corncollected >= 1 then
g_RPG_Gold = g_RPG_Gold + 2
g_corncollected = g_corncollected - 1
pressed = 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <<<<<<<<<<<<<<<<< here it is
elseif GetScancode() == 7 and pressed == 0 and g_meatcollected >= 1 then
g_RPG_Gold = g_RPG_Gold + 10
g_meatcollected = g_meatcollected - 1
--------------- MISSING "pressed = 1" ----------------------------------------

#1 You have to place this in at every iteration when detecting the keypress from GetScancode()

#2 And then to determine when there is a pause from a key press, use this;
if GetScancode() == 0 then pressed = 0 end
Let's put that at the very beginning of your <<main script body>> ON IT'S OWN LINE so we can see it,
and it functions correctly.

((I'm not yelling, just trying to clarify the important parts to make it work right!))
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 25th May 2021 18:11 Edited at: 25th May 2021 18:30
BTW, I think every shop should work fine (after you have corrected the key press issue) when
on your map they are spaced out FURTHER THAN the GetPlayerDistance that triggers each one.
So in other words, if they are all over 100 units away from each other, there shouldn't be an
issue with them tangling up together. Try spacing them a healthy bean-bag-toss distance apart
and see if that works.
To use both scripts;
((You would need to place your buying and selling scripts on separate map objects at the same shop.))
PM
Honkeyboy
3D Media Maker
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 25th May 2021 18:27
Thanks GB that's copy and pasting for you.... just added a little more code to open and close the shop a bit cleaner which works well
any ideas as to why i don't seem to be able to use the same keys for different shops?

Intel i5 4950 Quad core 3.3ghz AMD FX 6300 x6 cores 3.5ghz(unclocked)
8gb Ram 8gb Ram
XFX R5 2gb AMD Radeon HD 6670 2gb
and a well fed mouse on a wheel

I only smile because i have absolutely no idea whats going on
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 25th May 2021 18:37 Edited at: 25th May 2021 18:41
To use the same keys for buying and selling, we would need to add a 'mode' selection
for 'buy' mode or 'sell' mode, which would be quite simple, but would also need either a
third script or integrate the two scripts together. When you get the keypress corrected,
post what you have, and then I will fix them up so that we have a mode selection in there.

Edit: "same keys for different shops?"
Wait, I'm kinda confused by this. Have you looked at the distance spacing factor I mentioned?
Let's take it one step at a time and get the buy script working, and then the sell script working.
Without issues. then we move forward...
PM
Honkeyboy
3D Media Maker
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 25th May 2021 18:56 Edited at: 25th May 2021 19:07
yes m8 say in the buy script i use keys 1-10 for example if i use those keys in the sell script it didn't seem to work so i had to use the numberpad keys. but then thought ...hang on if i add more shops its going to get really confusing or not work, but haven't retested that since so will try that later. Any how m8 here's the buy script I've just added btn timer to open the page more smoothly and a freeze player so the player doesnt leave the shop open which caused the other shop not to open until it was closed the idea is to keep the items to around 10 per shop that way the player has to travel to each type e.g blacksmith for metals, carpenter for woods etc etc and then i can play with the pricing to enable profits though trades. the items in these two are basically the 10 base items you can pretty much collect anywhere.
p.s m8 thanks that also was a much better explanation i got that now
Edit: button thingy works now so looks like i can just use 1-10 for all

Intel i5 4950 Quad core 3.3ghz AMD FX 6300 x6 cores 3.5ghz(unclocked)
8gb Ram 8gb Ram
XFX R5 2gb AMD Radeon HD 6670 2gb
and a well fed mouse on a wheel

I only smile because i have absolutely no idea whats going on
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 25th May 2021 19:06
We might be kinda talking past each other in these forums chat...??

It's a matter of distance between shops... and I don't have your map, but space them out
a good bit and let's see if you can get the individual buy script working, and then the individual
sell script working, and then I will help you integrate them into one with a 'mode' selection.
PM
Honkeyboy
3D Media Maker
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 25th May 2021 19:10 Edited at: 25th May 2021 19:26
The buy script seems to work fine m8 well they both do for the most part only issue now is you press say key 1 to buy berries and you buy 5 with a quick keypress whereas i would think players who are doing trader would want 1 keypress 1 item so they have much more control on buying and selling. Other than that they are working.

here's a vid showing what i mean it becomes more important when you buy truffles or spices as they are collected exclusively in the northern and eastern maps so the prices are much higher elsewhere
Intel i5 4950 Quad core 3.3ghz AMD FX 6300 x6 cores 3.5ghz(unclocked)
8gb Ram 8gb Ram
XFX R5 2gb AMD Radeon HD 6670 2gb
and a well fed mouse on a wheel

I only smile because i have absolutely no idea whats going on
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 25th May 2021 19:20 Edited at: 25th May 2021 19:28
I've always (at least lately) used "g_Scancode" and not GetScancode()
which are probably one and the same until you check for repetition of key press...
That I don't know for sure, my suggestion is to use g_Scancode at all points you
detect a key press because that is the current value, and maybe GetScancode() resets
or modifies the check... so they get mixed up when used together? It's worth a shot.

I think you have individual scripts for each shop... that's perfectly OKAY!
But go through them all and double check what we have mentioned today with the key press,
etc for EVERY script.

Just make sure to check for always having "pressed = 1" in the script at point AFTER
you looked for > if g_Scancode ==
PM
Honkeyboy
3D Media Maker
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 25th May 2021 19:27
OK will give that a bash
Intel i5 4950 Quad core 3.3ghz AMD FX 6300 x6 cores 3.5ghz(unclocked)
8gb Ram 8gb Ram
XFX R5 2gb AMD Radeon HD 6670 2gb
and a well fed mouse on a wheel

I only smile because i have absolutely no idea whats going on

Login to post a reply

Server time is: 2024-04-18 16:22:24
Your offset time is: 2024-04-18 16:22:24