Page 1 of 1

lua question

Posted: Wed Feb 21, 2018 4:25 pm
by Ememjr
so i have modified the SummonItem lusa function so that it accepts another parameter
so teh forth parmameter would be a string and can only be "bank" or it will be ignored

my modification is below

Code: Select all

int EQ2Emu_lua_SummonItem(lua_State* state){
	if(!lua_interface)
		return 0;
	Spawn* spawn = lua_interface->GetSpawn(state);
	int32 item_id = lua_interface->GetInt32Value(state, 2);
	bool send_messages = (lua_interface->GetInt8Value(state, 3) == 1);
	if (spawn && spawn->IsPlayer()){
		Client* client = spawn->GetZone()->GetClientBySpawn(spawn);
		if (client && item_id > 0){
			if (lua_interface->GetStringValue(state, 4) == "bank")
				lua_interface->SetBooleanValue(state, client->AddItemToBank(item_id, 1));
			else
				lua_interface->SetBooleanValue(state, client->AddItem(item_id, 1));
			if (send_messages) {
				Item* item = master_item_list.GetItem(item_id);
				if (item) {
					client->Message(CHANNEL_COLOR_YELLOW, "You receive \\aITEM %u 0:%s\\/a.", item->details.item_id, item->name.c_str());
					string popup_text = "You receive " + item->name;
					client->SendPopupMessage(10, popup_text.c_str(), "ui_harvested_normal", 3, 0xFF, 0xFF, 0xFF);
				}
			}
			return 1;
		}
	}
	lua_interface->SetBooleanValue(state, false);
	return 1;
}
i do not think i did the compare of the state 4 correctly to see if it == "bank"

Code: Select all

if (lua_interface->GetStringValue(state, 4) == "bank")
				lua_interface->SetBooleanValue(state, client->AddItemToBank(item_id, 1));
			else
				lua_interface->SetBooleanValue(state, client->AddItem(item_id, 1));
fwi i also created new functions in server for AddItemToBank(item_id, 1) so i know this works correctly
what would be the correct if statement for that

Re: lua question

Posted: Wed Feb 21, 2018 4:33 pm
by Ememjr
think i may have the answer,

i just hate to have someone code for me but i like suggestions so here is my attempt

Code: Select all

string location = lua_interface->GetStringValue(state, 4);
	if (spawn && spawn->IsPlayer()){
		Client* client = spawn->GetZone()->GetClientBySpawn(spawn);
		if (client && item_id > 0){
			if (strncasecmp(location.c_str(), "bank", 4) == 0)

Re: lua question

Posted: Wed Feb 21, 2018 4:39 pm
by Ememjr
And it works, my new pair of shoes in the bank

but i need to know what quest step type i can use to aquire the item from the banks

i tried this
AddQuestStepObtainItem(Quest, 3, "I need to pick up my boots from the bank.", 1,100, "I need to visit the bank in the village to pick up my boots.", 497, 708)
but if i drag them to my inventory i dont get an update
boots.PNG

Re: lua question

Posted: Wed Feb 21, 2018 4:58 pm
by Jabantiz
If it can only be one value then I would make it an int8 instead of a string so it would essentially be a true of false parameter to send the item to the bank.

As for obtain item, items in your bank are already in your possession so moving them from the bank to inventory doesn't trigger the obtain step, you will probably need to make an entirely new function to listen for movement between the bank and inventory.

Re: lua question

Posted: Wed Feb 21, 2018 5:09 pm
by Ememjr
Jabantiz wrote: Wed Feb 21, 2018 4:58 pm If it can only be one value then I would make it an int8 instead of a string so it would essentially be a true of false parameter to send the item to the bank.

As for obtain item, items in your bank are already in your possession so moving them from the bank to inventory doesn't trigger the obtain step, you will probably need to make an entirely new function to listen for movement between the bank and inventory.
kinda figure so, LIve has several variations

ie some will/will not update if its something you have in bank
some will/will not update if it traded (usuall a crafting componet you have to create yourself)
some cannot be purchased from broker
some cannot be traded


now to find those listeners
i am guessing a newlua function (add quest step obtain item from bank
then only listen for that movement if thats the type of quest step

Re: lua question

Posted: Wed Feb 21, 2018 7:10 pm
by Jabantiz
Ememjr wrote: Wed Feb 21, 2018 5:09 pm now to find those listeners
i am guessing a newlua function (add quest step obtain item from bank
then only listen for that movement if thats the type of quest step
Sorry I can't be much help here as I have never added or even worked with adding new types of quest steps. I believe the newest one to be added was harvest item so that might give you some clues on how to set it all up.

Re: lua question

Posted: Fri Feb 23, 2018 4:56 pm
by Ememjr
i have decided to abandon the idea of having the quest step see you move the item out of the bank
and have instead just update the quest when the bank is opened