Post new topic    
Liquid Metal Slime
Send private message
On shop prices 
 PostFri Sep 19, 2014 1:15 am
Send private message Reply with quote
So I have a great deal of a game that relies on buying and trading items from shops. It would help me a a great deal if I could make shop prices random, but within a range, like in the "random (lownumber, highnumber)" command. Preferably, I would want the shop to change the prices every new game, not every time you open the shop. If there is any way at all I can do anything even close to editing shop prices in this way, with plot scripting, can somebody please tell me? If you have any comments at all, please share. Smile
My pronouns are they/them
Ps. I love my wife
Metal King Slime
Send private message
 
 PostFri Sep 19, 2014 1:51 am
Send private message Reply with quote
Currently shops can't be modified in any way by scripts, other than attaching tags to shop items to make them appear and disappear, but that would be a rather unpleasant workaround if you want more than just two options.

Obviously, we just haven't gotten around to adding script commands for it yet; it's been requested a number of times. Noone's really sat down yet and thought about how exactly it should work, considering that shop data is a bit complex and that we want to overhaul it. But we don't really need a complete solution; most importantly we just need commands to change the price of items, which is the main request.
Metal King Slime
Send private message
 
 PostFri Sep 19, 2014 2:30 am
Send private message Reply with quote
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
Display posts from previous: