Jump to content

Recommended Posts

ok I am working on a mod with chat gpt4 as an experiment and need someone with some knowledge on the matter.

 

specifically I am building a mod that will regenerate the volcano biome, I want to know if someone can provide feedback that i can feed to chat gpt to help steer it in the correct direction. here is the code block

this code is meant to add a command into the game that will regenerate the volcano biome in shipwrecked, Can someone help me figure out what i need to to say to this language model to steer it in the right direction.

 

The last error i got from this code was 'c_regenvolcano() isnt a defined variable. to be clear this is just the modmain.lua file. the modinfo.lua file is working properly

-- Define function to regenerate volcano
local function RegenVolcano()
    local world = TheWorld
    local map = TheWorld.Map
    local ocean_spawner = TheWorld.components.ocean_spawner

    -- Create a coroutine
    local co = coroutine.create(function()
        -- Disable world generation saving to prevent save file corruption
        if TheNet:IsDedicated() then
            TheNet:Announce("Disabling world saving for regeneration process.")
            world.ismastersim:SetPersistentString("world", "false")
        end

        -- Yield the coroutine for 2 seconds
        coroutine.yield(2)

        -- Regenerate volcano biome
        for _, node in ipairs(map:GetNodesWithTag("volcano")) do
            map:ResetTileAtPoint(node.x, 0, node.y)
        end
        for _, node in ipairs(map:GetNodesWithTag("volcanoonwater")) do
            map:ResetTileAtPoint(node.x, 0, node.y)
        end

        -- Yield the coroutine for 3 seconds
        coroutine.yield(3)

        -- Respawn ocean resources
        ocean_spawner:RegenerateResources()

        -- Yield the coroutine for 3 seconds
        coroutine.yield(3)

        -- Enable world generation saving
        if TheNet:IsDedicated() then
            world.ismastersim:SetPersistentString("world", "true")
            TheNet:Announce("World saving enabled. Regeneration complete.")
        else
            TheNet:Announce("Regeneration complete.")
        end
    end)

    -- Start the coroutine with a task that resumes it every frame
    TheWorld:DoPeriodicTask(0, function() 
        local status, delay = coroutine.resume(co) -- Resume the coroutine and get its status and delay
        if not status then -- If the coroutine has an error, print it
            print(coroutine.status(co))
            print(delay)
        elseif delay then -- If the coroutine has a delay, pause the task until the delay is over
            TheWorld:PushEvent("pauseperiodictask", {taskid = co})
            TheWorld:DoTaskInTime(delay, function() 
                TheWorld:PushEvent("resumeperiodictask", {taskid = co})
            end)
        elseif coroutine.status(co) == "dead" then -- If the coroutine is done, cancel the task
            TheWorld:PushEvent("cancelperiodictask", {taskid = co})
        end
    end)
end

-- Add the console command
_G.c_regenvolcano = RegenVolcano

 

the language model has been going in circles about the way to declare the variable in the file and everytime it gives me an edit if it doesnt straight up crash then the console gives me the error variable not defined

This task is too complicated for gpt model. Either break it down or just try another task, to delete the volcano save. If you don't know how correct the code is, gpt neither.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...