Script for managing items

From OHRRPGCE-Wiki
Jump to navigation Jump to search
# You should run the script "Management" from a menu (e.,g your main menu), and set it to close that menu when activated
# WARNING: There are limitations to this script. Notably, you can drop items that otherwise "cannot be dropped/sold". You can over-ride this manually
# Another thing is that there is no cursor memory. Can be annoying if you have a lot of items.
# Quite an important thing is that you can't tell through script whether an item is usable or not! 
# If you try to use an item which cannot be used, nothing will happen. You can add a message "Item cannot be used" or over-ride this for individual items
# ANOTHER important thing is that you can't tell whether an item is consumable or not! It removes a used item regardless, but you can over ride this
plotscript, management, begin
variable (mi, iis, slot)


# If you want to reposition the menus or change them, you can replace "create menu" with "open menu" and use your predefined menus that you already made :)
manage:=create menu
set menu bit(manage, menubit:suspend player even if gameplay allowed, 1)


variable(gis)
gis:=get inventory size
gis-=1

for(slot, 0, gis, 1)do(

iis:=item in slot (slot)

# If you want to add over-rides for items, so they are not displayed, or are displayed differently, or have different usage options, you should do that here... somewhere haha
# You should do it like this IF(iis==item)THEN( and change the next line to ELSEIF instead of IF

IF(iis<>-1)THEN(
mi := add menu item(manage)
# get item description (50, iis)  # You can change this to "Get item name" if you want to display the name instead of the description
get item name (50, iis)

# you can comment out the next 2 lines if you don't want to show how many items
$50+" x"
append number (50, inventory(iis))

set menu item caption(mi, 50)
    set menu item extra(mi, 0, slot) # 
    set menu item extra(mi, 1, menu item true slot(mi)) #
    set menu item extra(mi, 2, random(0,100)) # 
set menu item type(mi, menutype:script)
set menu item subtype(mi, @managedata)
) # add to menu for valid items

) # do loop of inventory
mi := add menu item(manage)
$50="Exit"
set menu item caption(mi, 50)
set menu item bit(mi, menu item bit: close menu when activated,1)
end

global variable (2999, manage) #    global variable for the item list


#   this handles a second menu when you select an item from the first menu
# this menu gives options on how to use the item, so go nuts! 
plotscript, manage data, whoops, what, where, begin
variable(whatx,wherex)
whatx:=what
wherex:=where
variable( slot)
slot:=menu item by true slot (manage,where)

variable(deal,mi)
deal:=create menu
set menu bit(deal, menubit:suspend player even if gameplay allowed, 1)
IF(deal)THEN(
mi := add menu item(deal)   # USE ITEM
$50="Use"
set menu item caption(mi, 50)
set menu item extra(mi, 0, what) # what inv slot
set menu item extra(mi, 1, where) # where slot in manage menu
set menu item extra(mi, 2, whoops) # what inv slot
set menu item type(mi, menutype:script)
set menu item subtype(mi, @usage)

mi := add menu item(deal) # DISCARD ITEM
$50="Discard"
set menu item caption(mi, 50)
set menu item extra(mi, 0, what) # what inv slot
set menu item extra(mi, 1, where) # where slot in manage menu
set menu item extra(mi, 2, whoops) # what inv slot
set menu item type(mi, menutype:script)
set menu item subtype(mi, @remove)

mi := add menu item(deal)
$50="Exit"
set menu item caption(mi, 50)
set menu item bit(mi, menu item bit: close menu when activated,1)
) # THEN deal menu is open
end

plotscript, remove, whoops, what, where, begin
variable(slot, which)
which:=iteminslot(what)
    delete item(which)
slot:=menu item by true slot(manage, where)
select menu item(slot)
    delete menu item(slot)
close menu(top menu)
close menu(top menu)
management
end

plotscript, usage, whoops, what, where, begin
variable(slot, which)
which:=iteminslot(what)
IF(use item(which))THEN(delete item (which) # items used with a script aren't deleted from inventory, so it must be done manually.
)
slot:=menu item by true slot(manage, where)
select menu item(slot)
close menu(top menu)
close menu(top menu)
management
end