Menu
Coddy logo textTech
flag Ar iconالعربيةdown icon

حالة اللاعب

جزء من قسم Logic & Flow في رحلة Lua على Coddy — الدرس 26 من 54.

challenge icon

التحدي

سهل

بناءً على الغرف المتصلة التي أنشأتها، قم بإنشاء جدول player لتتبع موقع اللاعب الحالي في عالم اللعبة.

لقد تم تزويدك بمتغيرات startingRoom و gardenRoom من التحدي السابق.

أنشئ جدولاً يسمى player بمفتاح واحد:

  • currentRoom: قم بتعيين هذا ليشير إلى startingRoom

اطبع اسم الغرفة الحالية للاعب، ثم اطبع وصف الغرفة الحالية للاعب في أسطر منفصلة.

تنسيق المخرجات المتوقع:

Ancient Library
You find yourself in a dusty library filled with ancient books and scrolls.

جرّب بنفسك

-- Create the starting room
local startingRoom = {
    name = "Ancient Library",
    description = "A dusty library filled with ancient tomes and scrolls.",
    exits = {}
}

-- Create the garden room
local gardenRoom = {
    name = "Secret Garden",
    description = "A hidden garden with overgrown plants and a small fountain.",
    exits = {}
}

-- Link the rooms together
startingRoom.exits["east"] = gardenRoom
gardenRoom.exits["west"] = startingRoom

-- Print the required output
print(startingRoom.name)
print(startingRoom.exits["east"].name)
print(startingRoom.exits["east"].exits["west"].name)

جميع دروس Logic & Flow