-1
'인벤토리'및 'pickupblade/takeblade'라는 단어를 입력하면 서브 루틴을 호출해야하는 텍스트 모험에서 선택 사례를 설정했습니다. 그러나 서브 루틴을 올바르게 호출하는 경우에도이 서브 루틴은 호출되지 않고 있습니다 (1 & 2). 코드는 예외를 발생시키지 않지만 해당 서브 루틴은 호출되지 않습니다.사례 반환 값이 없습니다.
while playing
console.write("Where to next? ")
' get the command from user
command = console.readline()
' command should be of either a single verb, single direction, or verb noun
' parse the command then use verb to identify appropriate action to take
commandWords = Split(command," ")
select case ubound(commandwords)
case 0
' 'verb' command
select case ucase(commandWords(0))
case "N","S","E","W","NORTH","SOUTH","EAST","WEST"
if tryMoving(commandWords(0)) then displayRoom
case "INVENTORY"
if trymoving(commandwords(0)) then inventory
case "PICKUPBLADE", "TAKEBLADE"
if trymoving(commandwords(0)) then pickup_blade
end select
case 1
' 'verb noun' commands
select case ucase(commandWords(0))
case "GO","MOVE"
if trymoving(commandwords(1)) then displayRoom
end select
end select
end while
End Sub
sub displayRoom()
console.title=room(location)
console.out.writeline(desc(location))
if objLocation(0) = location Then
Console.WriteLine("You can see a blade")
Console.WriteLine("You can pickup this item.")
end if
end sub
sub pickup_blade()
if objLocation(0) = location Then
Console.WriteLine("You have picked up the blade.")
objLocation(0) = 0
end if
end sub
sub inventory()
Console.WriteLine("------------------------------------------------------")
Console.WriteLine("----------------------Inventory-----------------------")
Console.WriteLine("------------------------------------------------------")
if objLocation(0) = 0 Then
Console.WriteLine("> Blade")
elseif objLocation(1) = 0 Then
Console.WriteLine("> Gloves")
else
Console.WriteLine("Inventory is empty.")
end if
end sub
당신은'case 3'과'case case ucase (commandWords (0))'를 선택하여 "INVENTORY"와 일치하는 것을 찾았습니다. 따라서 입력 명령에 ** 3 개의 공백 **이 있어야합니다. "INVENTORY what what the bleep"과 같이 간단하게 "INVENTORY"로 작업 할 것으로 예상 할 때입니다. –
@Idle_Mind 이제 'INVENTORY'및 'PICKUPBLADE'명령이 0 인 경우 코드가 변경되었지만 여전히 서브 루틴이 호출되지 않고 있습니까? 변경 내용을 보여주는 스 니펫을 업데이트했습니다. –
'재생'이 맞습니까? – itsLex