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.
g_berriescollected=0
g_fiberscollected=0
g_watercollected=0
g_woodcollected=0
g_corncollected=0
g_meatcollected=0
g_mushroomscollected=0
g_featherscollected=0
g_fishcaught=0
g_trufflescollected=0
g_spicecollected=0
g_RPG_Gold=0
pressed = 0
function food_shop_selling_a_init(e)
end
function food_shop_selling_a_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 100 then
Text(43,2,1,"This Shop Sells Foods",3000)
--What the shop sells--
Text(1,7,1," Berries sell for 3 gold press 1 to buy")
Text(1,10,1," Fibers sell for 5 gold press 2 to buy")
Text(1,13,1," Water sells for 7 gold press 3 to buy")
Text(1,16,1," Wood sells for 8 gold press 4 to buy")
Text(1,19,1," Corn sells for 2 gold press 5 to buy")
Text(1,22,1," Meat sells for 10 gold press 6 to buy")
Text(1,25,1," Mushrooms sell for 3 gold press 7 to buy")
Text(1,28,1," Feathers sell for 6 gold press 8 to buy")
Text(1,31,1," Fish sells for 8 gold press 9 to buy")
Text(1,34,1," Truffles sell for 26 gold press 0 to buy")
Text(1,37,1," Spices sell for 28 gold press - to buy")
-- player inventory amounts--
Text(90,6,1,"You have")
Text(90,9,1,g_berriescollected.." Berries")
Text(90,12,1,g_fiberscollected.." Fibers")
Text(90,15,1,g_watercollected.." Water ")
Text(90,18,1,g_woodcollected.." Wood ")
Text(90,21,1,g_corncollected.." Corn ")
Text(90,24,1,g_meatcollected.." Meat ")
Text(90,27,1,g_mushroomscollected.." Mushrooms ")
Text(90,30,1,g_featherscollected.." Feathers ")
Text(90,33,1,g_fishcaught.." Fish ")
Text(90,36,1,g_trufflescollected.." Truffles ")
Text(90,39,1,g_spicecollected.." Spices ")
Text(46,95,1,g_RPG_Gold.." Gold")
end
if GetScancode() == 2 and pressed == 0 then
if g_RPG_Gold >= 3 then
g_RPG_Gold = g_RPG_Gold - 3
g_berriescollected = g_berriescollected + 1
end
elseif GetScancode() == 3 and pressed == 0 then
if g_RPG_Gold >= 5 then
g_RPG_Gold = g_RPG_Gold - 5
g_fiberscollected = g_fiberscollected + 1
end
pressed = 1
else
pressed = 0
end
end
this one doesn't sell the first item to the player
g_berriescollected=0
g_fiberscollected=0
g_watercollected=0
g_woodcollected=0
g_corncollected=0
g_meatcollected=0
g_mushroomscollected=0
g_featherscollected=0
g_fishcaught=0
g_trufflescollected=0
g_spicecollected=0
g_RPG_Gold=0
pressed = 0
function food_shop_buying_a_init(e)
end
function food_shop_buying_a_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 100 then
Text(43,2,1,"This Shop Buys Foods",3000)
--What the shop buys--
Text(1,7,1," I buy berries for 3 gold press 1 to sell")
Text(1,10,1," I buy Fibers for 5 gold press 2 to sell")
Text(1,13,1," I buy Water for 7 gold press 3 to sell")
Text(1,16,1," I buy Wood for 8 gold press 4 to sell")
Text(1,19,1," I buy Corn for 2 gold press 5 to sell")
Text(1,22,1," I buy Meat for 10 gold press 6 to sell")
Text(1,25,1," I buy Mushrooms for 3 gold press 7 to sell")
Text(1,28,1," I buy Feathers for 6 gold press 8 to sell")
Text(1,31,1," I buy Fish for 8 gold press 9 to sell")
Text(1,34,1," I buy Truffles for 26 gold press 0 to sell")
Text(1,37,1," I buy Spices for 28 gold press - to sell")
-- player inventory amounts--
Text(90,6,1,"You have")
Text(90,9,1,g_berriescollected.." Berries")
Text(90,12,1,g_fiberscollected.." Fibers")
Text(90,15,1,g_watercollected.." Water ")
Text(90,18,1,g_woodcollected.." Wood ")
Text(90,21,1,g_corncollected.." Corn ")
Text(90,24,1,g_meatcollected.." Meat ")
Text(90,27,1,g_mushroomscollected.." Mushrooms ")
Text(90,30,1,g_featherscollected.." Feathers ")
Text(90,33,1,g_fishcaught.." Fish ")
Text(90,36,1,g_trufflescollected.." Truffles ")
Text(90,39,1,g_spicecollected.." Spices ")
Text(46,95,1,g_RPG_Gold.." Gold")
end
if GetScancode() == 2 and pressed == 0 then
if g_berriescollected >= 1 then
g_RPG_Gold = g_RPG_Gold + 3
g_berriescollected = g_berriescollected - 1
end
elseif GetScancode() == 3 and pressed == 0 then
if g_fiberscollected >= 1 then
g_RPG_Gold = g_RPG_Gold + 5
g_fiberscollected = g_fiberscollected - 1
end
pressed = 1
else
pressed = 0
end
end
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