unixdude007
New Member
- Joined
- Dec 3, 2015
- Messages
- 5
Hi Guys,
I'm trying to create an NPC based on the Crazy Merchant example someone did a while back which sold speeders but this time to sell buffs.
I'm a bit stuck on how to get him/her to buff the actual player. The convo is in place the menu items are there but when you click on the option to obtain a buff I am egtting the following error :
[Console] ERROR - Error running function getNextConversationScreen ...cripts/screenplays/tasks/naboo/merch_crazy_larry.lua:73: attempt to call global 'enhanceCharacter' (a nil value)
I am pretty sure it's because I have no idea on what to do with enhanceCharater the code is basically essentially the same as the crazy merch one with a few extras, any help would be appreciated:
I'm trying to create an NPC based on the Crazy Merchant example someone did a while back which sold speeders but this time to sell buffs.
I'm a bit stuck on how to get him/her to buff the actual player. The convo is in place the menu items are there but when you click on the option to obtain a buff I am egtting the following error :
[Console] ERROR - Error running function getNextConversationScreen ...cripts/screenplays/tasks/naboo/merch_crazy_larry.lua:73: attempt to call global 'enhanceCharacter' (a nil value)
I am pretty sure it's because I have no idea on what to do with enhanceCharater the code is basically essentially the same as the crazy merch one with a few extras, any help would be appreciated:
Code:
CrazyLarry = ScreenPlay:new {
numberOfActs = 1,
questString = "crazy_larry_task",
states = {},
}
registerScreenPlay("CrazyLarry", true)
function CrazyLarry:start()
-- Spawn our character into the world, setting pLarry a pointer variable we can use to check or change his state.
local pLarry = spawnMobile("naboo", "merch_crazy_larry", 1, -4881, 6.0, 4150, 35, 0 )
end
crazylarry_convo_handler = Object:new {
tstring = "myconversation"
}
function crazylarry_convo_handler:getNextConversationScreen(conversationTemplate, conversingPlayer, selectedOption)
-- Assign the player to variable creature for use inside this function.
local creature = LuaCreatureObject(conversingPlayer)
-- Get the last conversation to determine whetehr or not we're on the first screen
local convosession = creature:getConversationSession()
lastConversation = nil
local conversation = LuaConversationTemplate(conversationTemplate)
local nextConversationScreen
-- If there is a conversation open, do stuff with it
if ( conversation ~= nil ) then
-- check to see if we have a next screen
if ( convosession ~= nil ) then
local session = LuaConversationSession(convosession)
if ( session ~= nil ) then
lastConversationScreen = session:getLastConversationScreen()
end
end
-- Last conversation was nil, so get the first screen
if ( lastConversationScreen == nil ) then
nextConversationScreen = conversation:getInitialScreen()
else
-- Start playing the rest of the conversation based on user input
local luaLastConversationScreen = LuaConversationScreen(lastConversationScreen)
-- Set variable to track what option the player picked and get the option picked
local optionLink = luaLastConversationScreen:getOptionLink(selectedOption)
nextConversationScreen = conversation:getScreen(optionLink)
-- Get some information about the player.
local credits = creature:getCashCredits()
local pInventory = creature:getSlottedObject("inventory")
local inventory = LuaSceneObject(pInventory)
-- Take action when the player makes a purchase.
if (SceneObject(pInventory):isContainerFullRecursive() == true) then
nextConversationScreen = conversation:getScreen("insufficient_space")
creature:sendSystemMessage("You do not have enough inventory space")
elseif (optionLink == "speederbike" and credits < 10000) then
-- Bail if the player doesn't have enough cash on hand.
-- Plays a chat box message from the NPC as well as a system message.
nextConversationScreen = conversation:getScreen("insufficient_funds")
creature:sendSystemMessage("You have insufficient funds")
elseif (optionLink == "speederbike" and credits >= 10000) then
-- Take 10,000 credits from the player's cash on hand and give player a speederbike.
creature:subtractCashCredits(10000)
local pItem = giveItem(pInventory, "object/tangible/deed/vehicle_deed/speederbike_deed.iff", -1)
elseif (optionLink == "buffcharacter" and credits < 10000) then
nextConversationScreen = conversation:getScreen("insufficient_funds")
creature:sendSystemMessage("You have insufficient funds")
elseif (optionLink == "buffcharacter" and credits >= 10000) then
-- Take 10,000 credits from the player's cash on hand and give player a buff.
creature:subtractCashCredits(10000)
enhanceCharacter(creature)
end
end
end
-- end of the conversation logic.
return nextConversationScreen
end
function crazylarry_convo_handler:runScreenHandlers(conversationTemplate, conversingPlayer, conversingNPC, selectedOption, conversationScreen)
-- Plays the screens of the conversation.
return conversationScreen
end