Intermediate Trigger of the Day - Array Questshop

Login to reply  Page: « < 1 of 1 > »
13 May 2008 - 17:57531
Intermediate Trigger of the Day - Array Questshop
This does the same thing as Rumble's questshop posted earlier today except it's a few lines longer, but more customizable for adding more items to it in that each item only requires a single line.

Name: 'Mob Questshop Example',  VNum: [  167], RNum: [  167]
Trigger Intended Assignment: Mobiles
Trigger Type: Command , Numeric Arg: 100, Arg list: *
Commands:
if %cmd.mudcommand% == list
  %send% %actor%  ##   Available   Item                                Cost in Questpoints
  %send% %actor% -------------------------------------------------------------------------
  %send% %actor%   1)  Unlimited   War's Blood                                         100
  %send% %actor%   2)  Unlimited   shadow stealer                                      100
  %send% %actor%   3)  Unlimited   the staff of spellfire                              100
elseif %cmd.mudcommand% == buy
  set object[1] 1 21 100
  set object[2] 2 22 100
  set object[3] 3 23 100
  set i 1
  set found 0
  while %i% < 4
    extract number 1 %%object[%i%]%% 
    if %number% == %arg%
      extract object_vnum 2 %%object[%i%]%%
      extract quest_price 3 %%object[%i%]%%
      set found 1
      break
    end
    eval i %i% + 1
  done
  if !%found%
    %send% %actor% You must provide either the number of the item you want to buy,
    %send% %actor% such as 'buy 1'
    halt
  end
  if %actor.qp% < %quest_price%
    tell %actor.name% You don't have enough questpoints for that. 
  else 
    nop %actor.qp(-%quest_price%)% 
    %load% obj %object_vnum% %actor% 
    tell %actor.name% Here is your new item for %quest_price% QP.
  end 
elseif %cmd.mudcommand% == sell 
  tell %actor.name% I don't purchase items from players. 
else 
  return 0 
end


__________________

Last edited by Fizban (13 May 2008 - 18:00)
07 Nov 2009 - 03:262006
Armitage reported that Fizban's trigger above didn't work. I fixed the first problem by replacing
    extract number 1 %%object[%i%]%%
with
    extract number 1 %object[%%i%%]%

but the follow on extracts won't work!
extract object_vnum 2 %object[%%i%%]%
extract quest_price 3 %object[%%i%%]%
Though they are the exact same format as the above working extract...
Any ideas?

Full trig below:
The echo to test the variables for "buy 1" outputs: Arg: 1 number: 1 vnum: price:
vnum and price return nothing
 Name: 'Questshop',  VNum: [60878], RNum: [ 4435]
Trigger Intended Assignment: Mobiles
Trigger Type: Command , Numeric Arg: 100, Arg list: *
Commands:
if %cmd.mudcommand% == list
%send% %actor%  ##   Available   Item                                Cost in Questpoints
%send% %actor% -------------------------------------------------------------------------
%send% %actor%   1)  Unlimited   War's Blood                                         100
%send% %actor%   2)  Unlimited   shadow stealer                                      100
%send% %actor%   3)  Unlimited   the staff of spellfire                              100
elseif %cmd.mudcommand% == buy
  set object[1] 1 21 100
  set object[2] 2 22 100
  set object[3] 3 23 100
  set i 1
  set found 0
  while %i% < 4
    extract number 1 %object[%%i%%]%
**********moved here for testing
    extract object_vnum 2 %object[%%i%%]%
    extract quest_price 3 %object[%%i%%]%
%echo% arg: %arg% number: %number% vnum: %object_vnum% price: %quest_price%
**********
    if %number% == %arg%
      set found 1
    end
    eval i %i% +1
  done
if !%found%
  %send% %actor% You must provide either the number of the item you want to buy,
  %send% %actor% such as 'buy 1'
  halt
end
if %actor.questpoints% < %quest_price%
  tell %actor.name% You don't have enough questpoints for that.
else
  nop %actor.questpoints(-%quest_price%)%
  %load% obj %object_vnum% %actor% inv
  tell %actor.name% Here is your new item for %quest_price% QP.
  end
elseif %cmd.mudcommand% == sell
  tell %actor.name% I don't purchase items from players.
else
  return 0
end


__________________
Rumble
The Builder Academy
tbamud.com 9091

Last edited by Rumble (07 Nov 2009 - 03:27)
07 Nov 2009 - 12:272007
I have no clue why the change you made worked, but to be honest it shouldn't have, syntax to parse generally speaking is definitely %%object[%i%]%% not %object[%%i%%]%, regardless, the following does work, couldn't get it to work tough when directly trying to extract, needed to eval first.

if %cmd.mudcommand% == list
  %send% %actor%  ##   Available   Item                                Cost in Questpoints
  %send% %actor% -------------------------------------------------------------------------
  %send% %actor%   1)  Unlimited   War's Blood                                         100
  %send% %actor%   2)  Unlimited   shadow stealer                                      100
  %send% %actor%   3)  Unlimited   the staff of spellfire                              100
elseif %cmd.mudcommand% == buy
  set object[1] 1 21 100
  set object[2] 2 22 100
  set object[3] 3 23 100
  set i 1
  set found 0
  while %i% < 4
    eval tmp %%object[%i%]%%
    extract number 1 %tmp%
    if %number% == %arg%
      extract vnum 2 %tmp%
      extract price 3 %tmp%
      set found 1
      break
    end
    eval i %i% + 1
  done
  if !%found%
    %send% %actor% You must provide either the number of the item you want to buy,
    %send% %actor% such as 'buy 1'
    halt
  end
  if %actor.qp% < %price%
    tell %actor.name% You don't have enough questpoints for that. 
  else 
    nop %actor.qp(-%price%)% 
    %load% obj %vnum% %actor% 
    tell %actor.name% Here is your new item for %price% QP.
  end 
elseif %cmd.mudcommand% == sell 
  tell %actor.name% I don't purchase items from players. 
else 
  return 0 
end

The original was likely mailer code, that was actually tested though and works 100%.


__________________
Login to reply  Page: « < 1 of 1 > »