If you've got a relatively small amount of items, then you could store prices in globals and create a buy/sell menu for them.
Here's an example of how I went about it in the collab game that Feenicks and I did:
Code:
plotscript, trade, begin
open menu(2)
end
plotscript, prime buy, begin
variable(
menh #Menu Handle
mnih #Menu Item Handle
ctr #Counter
)
clear string(32) #Clear the string where text will be placed
menh := open menu(4)
ctr := 0
for(ctr, 1, 8) do(
mnih := add menu item(menh)
set menu item type(mnih, menutype:script)
set menu item subtype(mnih, @buygood)
set menu item extra(mnih, 0, ctr)
switch(ctr) do(
case(1) do($32 = "Water: ")
case(2) do($32 = "Food: ")
case(3) do($32 = "Textiles: ")
case(4) do($32 = "Ore: ")
case(5) do($32 = "Machines: ")
case(6) do($32 = "Medicine: ")
case(7) do($32 = "Weapons: ")
case(8) do($32 = "LuxGoods: ")
)
append number(32, read global(ctr + 59))
set menu item caption(mnih, 32)
)
wait for menu(menh)
end
plotscript, prime sell, begin
variable(
menh #Menu Handle
mnih #Menu Item Handle
ctr #Counter
)
clear string(32)
#show text box(2)
menh := open menu(5)
ctr := 0
for(ctr, 1, 8) do(
mnih := add menu item(menh)
set menu item type(mnih, menutype:script)
set menu item subtype(mnih, @sellgood)
set menu item extra(mnih, 0, ctr)
switch(ctr) do(
case(1) do($32 = "Water: ")
case(2) do($32 = "Food: ")
case(3) do($32 = "Textiles: ")
case(4) do($32 = "Ore: ")
case(5) do($32 = "Machines: ")
case(6) do($32 = "Medicine: ")
case(7) do($32 = "Weapons: ")
case(8) do($32 = "LuxGoods: ")
)
append number(32, read global(ctr + 59))
set menu item caption(mnih, 32)
)
wait for menu(menh)
end
plotscript, buy good, gdid, begin
#gdid is GooD ID, used to identify what is being selected
gdid := get menu item extra(selected menu item(top menu), 0)
variable(
cgud #Current Good
cprc #Current Price
ccsh #Current Cash
)
cgud := (gdid -- 1) + 60
cprc := read global(cgud)
ccsh := party money
if(ccsh << cprc) then(
)
else(
lose money(cprc)
get item(100 + gdid, 1)
)
#Update strings
#--------------------------------------------------------
$23 = "Water: "
$24 = "Food: "
$25 = "Textiles: "
$26 = "Ore: "
$27 = "Machines: "
$28 = "Medicine: "
$29 = "Weapons: "
$30 = "LuxGoods: "
$31 = "Credits: "
append number(31, party money)
append number(23, inventory(item:Water))
append number(24, inventory(item:Food))
append number(25, inventory(item:Textiles))
append number(26, inventory(item:Ore))
append number(27, inventory(item:Machines))
append number(28, inventory(item:Medicine))
append number(29, inventory(item:Weapons))
append number(30, inventory(item:LuxGoods))
#--------------------------------------------------------
end
plotscript, sell good, gdid, begin
#gdid is GooD ID, used to identify what is being selected
gdid := get menu item extra(selected menu item(top menu), 0)
variable(
cgud #Current Good
cprc #Current Price
ccsh #Current Cash
)
cgud := (gdid -- 1) + 60
cprc := read global(cgud)
ccsh := party money
if(inventory(100 + gdid) <= 0) then(
)
else(
get money(cprc)
delete item(100 + gdid, 1)
)
#Update strings
#--------------------------------------------------------
$23 = "Water: "
$24 = "Food: "
$25 = "Textiles: "
$26 = "Ore: "
$27 = "Machines: "
$28 = "Medicine: "
$29 = "Weapons: "
$30 = "LuxGoods: "
$31 = "Credits: "
append number(31, party money)
append number(23, inventory(item:Water))
append number(24, inventory(item:Food))
append number(25, inventory(item:Textiles))
append number(26, inventory(item:Ore))
append number(27, inventory(item:Machines))
append number(28, inventory(item:Medicine))
append number(29, inventory(item:Weapons))
append number(30, inventory(item:LuxGoods))ow I
#--------------------------------------------------------
end
I think that this should work fine. The way it works is that the prices (the cprc variable used in the buy good and sell good scripts) are stored in globals (globals 60 to 68, specifically) which are retrieved whenever buying or selling. The buy/sell part of the thing is in a custom menu which calls whichever of these plotscripts is needed.
Because prices are stored in globals, you'll be able to modify them however you want in another script.
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl