ArcEmu: Teleporter Lua Script Debug - ArcEmu

Jump to content

Toggle shoutbox Lastest Announcements

dfighter  : (07 December 2014 - 12:06 PM) Arcemu is in hibernation mode, please read http://arcemu.org/fo...showtopic=26903
dfighter  : (01 January 2013 - 05:56 PM) Arcemu wishes you all a happy new year!
Hasbro  : (12 September 2012 - 10:01 AM) Please excuse our outage from the web! Our web host had a major malfunction!
dfighter  : (01 September 2012 - 04:05 PM) Since the spam bots just don't want to stop, I've enabled admin verification when registering.
dfighter  : (23 January 2012 - 09:56 PM) Please note that from now on you will need to confirm your email on the wiki in order to edit it!
Hasbro  : (31 December 2011 - 12:50 PM) Happy New Years all!
Navid  : (26 December 2011 - 04:09 AM) Merry Christmas !!!!!! Happy holidays all :)
WAmadeus  : (24 December 2011 - 03:54 PM) Merry Christmas to all!
dfighter  : (24 December 2011 - 11:05 AM) The Arcemu team wishes y'all a Merry Christmukkah!
Hasbro  : (05 October 2011 - 12:53 PM) Looking for web designers for upcoming web related project. If you're interested in designing user interfaces contact me
dfighter  : (02 September 2011 - 03:47 PM) So who here wants vehicles in Arcemu? :P http://arcemu.org/fo...showtopic=25440
Hasbro  : (14 August 2011 - 03:25 PM) Join us on irc, grab an irc client and connect to irc.freenode.net join channel #arcemu /server irc.freenode.net:6667 /join #arcemu
jackpoz  : (03 August 2011 - 05:33 AM) to all Lua Engine (old one) users: please check http://arcemu.org/fo...showtopic=25274
Hasbro  : (20 May 2011 - 05:27 PM) Looking for people experienced with CMake configuration and setup! Contact me asap
Hasbro  : (15 May 2011 - 05:03 PM) ArcEmu is recruiting C++ programmers, contact Hasbro if interested.
paroxysm  : (03 May 2011 - 06:26 PM) Updated luabridge gossip example to describe the whole gossip creation process rather than just how to create menu. Gossip tutorial
paroxysm  : (23 April 2011 - 11:35 AM) Lua writers can refer to the Luabridge Tutorials section in the Wiki to learn how to write gossip code correctly.
Hasbro  : (20 April 2011 - 05:22 PM) Thank you for your continuous contribution of bug reports, we are working on them.
Hasbro  : (17 April 2011 - 03:20 AM) Please consider donating to support our bills. Donations can be sent using PayPal to donations@arcemu.org - Thank you for your support.
paroxysm  : (10 April 2011 - 12:43 AM) Refer to the Luabridge Tutorials section in the Wiki to learn the new syntax of luabridge.
Resize Shouts Area

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Teleporter Lua Script Debug what am i doing here...?

#1 User is offline   iEzri 

  • < Ace of spades >
  • Group: Contributor
  • Posts: 1,692
  • Joined: 22-December 08
  • Gender:Female
  • Interests:I'm likely to cause mischief
  • Server OS:Linux

Posted 03 January 2011 - 02:48 PM

ok my fellow oily humanoids...

I lost my brain somehow... maybe i even ate it, but since it is gone right now i wrote this lua script for someone in german forums and i am not even sure if this is correct.

Can some mighty lua pro codah check this out and tell me if this is even correct?

It's just i don't know those fancy functions anymore and im too rusty to download all svn compile it, set everything up again just to test this... :blink:

so oh please, whats wrong with this?

local Item_ID = 1000001

function onSubmenu(Unit, event, Player, id, intid, code, pMisc)
        if(intid == 10) then
                Player:Teleport(554, 253.164993, 52.331608, 0.236356) -- something something dark side
                Player:GossipComplete(Player)
        elseif(intid == 20) then
                Player:Teleport(554, 268.101990, 52.331760, 25.670067) -- something something dark side
                Player:GossipComplete(Player)
        end
end

function onUse(pItem, event, player)
        pItem:GossipCreateMenu(50, Player, 0)
        pItem:GossipMenuAddItem(4, "1st location", 10, 0)
        pItem:GossipMenuAddItem(4, "2nd location", 20, 0)       
        pItem:GossipSendMenu(Player)
end

RegisterItemGossipEvent(Item_ID, 1, "onUse")
RegisterItemGossipEvent(Item_ID, 2, "onSubmenu")


thankuuu :(
Posted Image I do not join. I lead.
0

#2 User is offline   Marforius 

  • Permanantly on leave
  • PipPipPipPip
  • Group: Members
  • Posts: 597
  • Joined: 07-August 08
  • IRC:Marforius
  • Gender:Male
  • Location:Rome
  • Interests:ArcEmulatorius
  • Server OS:Linux

Posted 03 January 2011 - 04:55 PM

View PostiEzri, on 03 January 2011 - 02:48 PM, said:

 
 function onusepipe()
  onUse();
 end
 
 function onSubmenu()
  onSubmenu();
 end
 
 local function onUse(pItem, event, player)
 		pItem:GossipCreateMenu(50, Player, 0);
 		pItem:GossipMenuAddItem(4, "1st location", 10, 0);
 		pItem:GossipMenuAddItem(4, "2nd location", 20, 0);
 		pItem:GossipSendMenu(Player);
 end
 
 local function onSubmenu(Unit, event, Player, id, intid, code, pMisc)
 	if(intid == 10) then
     			Player:Teleport(554, 253.164993, 52.331608, 0.236356); -- something something dark side
     			Player:GossipComplete(Player);
 	if(intid == 20) then
     			Player:Teleport(554, 268.101990, 52.331760, 25.670067); -- something something dark side
     			Player:GossipComplete(Player);
 		end
 end
 
 RegisterItemGossipEvent(1000001, 1, "onUsepipe")
 RegisterItemGossipEvent(1000001, 2, "onSubmenupipe")




Im not entirely sure, this might work. I haven't fiddled with server scripting since... july?

1. onSubmenu was declared after declaration of onUse
2. Intid(s) do not need elseif they are not in an if nor for loop just an integer based variable
3. This script is not "up to standards" :P


This is... but yet again this probably wont work, I haven't investigated how local functions are called, and a teleporter script is hardly going to notice the performance gains by being to standard.

function onusepipe()
 onUse();
end

function onSubmenupipe()
 onSubmenu();
end

local function onUse(pItem, event, player)
        pItem:GossipCreateMenu(50, Player, 0);
        pItem:GossipMenuAddItem(4, "1st location", 10, 0);
        pItem:GossipMenuAddItem(4, "2nd location", 20, 0);
        pItem:GossipSendMenu(Player);
end

local function onSubmenu(Unit, event, Player, id, intid, code, pMisc)
	if(intid == 10) then
                Player:Teleport(554, 253.164993, 52.331608, 0.236356); -- something something dark side
                Player:GossipComplete(Player);
	if(intid == 20) then
                Player:Teleport(554, 268.101990, 52.331760, 25.670067); -- something something dark side
                Player:GossipComplete(Player);
        end
end

RegisterItemGossipEvent(1000001, 1, "onUsepipe")
 RegisterItemGossipEvent(1000001, 2, "onSubmenupipe")

This post has been edited by Marforius: 03 January 2011 - 05:04 PM

0

#3 User is offline   iEzri 

  • < Ace of spades >
  • Group: Contributor
  • Posts: 1,692
  • Joined: 22-December 08
  • Gender:Female
  • Interests:I'm likely to cause mischief
  • Server OS:Linux

Posted 03 January 2011 - 06:14 PM

View PostMarforius, on 03 January 2011 - 04:55 PM, said:

This is... but yet again this probably wont work, I haven't investigated how local functions are called, and a teleporter script is hardly going to notice the performance gains by being to standard.



ok i just noticed some typos that could break it. But uh, this confuses me. What would those pipes be for? I thought pipes were for smoking funny stuff?

function onUsepipe()
 onUse();
end

function onSubmenupipe()
 onSubmenu();
end

local function onUse(pItem, event, Player)
        pItem:GossipCreateMenu(50, Player, 0);
        pItem:GossipMenuAddItem(4, "1st location", 10, 0);
        pItem:GossipMenuAddItem(4, "2nd location", 20, 0);
        pItem:GossipSendMenu(Player);
end

local function onSubmenu(Unit, event, Player, id, intid, code, pMisc)
        if(intid == 10) then
                Player:Teleport(554, 253.164993, 52.331608, 0.236356); -- something something dark side
                Player:GossipComplete(Player);
        if(intid == 20) then
                Player:Teleport(554, 268.101990, 52.331760, 25.670067); -- something something dark side
                Player:GossipComplete(Player);
        end
end

RegisterItemGossipEvent(1000001, 1, "onUsepipe")
RegisterItemGossipEvent(1000001, 2, "onSubmenupipe")

Posted Image I do not join. I lead.
0

#4 User is offline   Marforius 

  • Permanantly on leave
  • PipPipPipPip
  • Group: Members
  • Posts: 597
  • Joined: 07-August 08
  • IRC:Marforius
  • Gender:Male
  • Location:Rome
  • Interests:ArcEmulatorius
  • Server OS:Linux

Posted 09 January 2011 - 12:59 AM

pipes are for calling local functions, which tl;dr isnt really doing anything as the pipes are still globals - which is why I have been meaning to look up a better way of implementing local functions in menu scripts...

so calling derp from anywhere or registering it makes it a local function, but it still has the static "global" hashtable lookuptime in Lua, so its not really doing anything for this script.


like so:

function derp()
 herp();
end

local function herp()
 print("lol Lua");
end





A possibility is doing


local function registerme()
 RegisterItemGossipEvent(1, 1, "OnUse")
end

local OnUse(pPlayer, event)
 pPlayer:Eject();
end

registerme();

-- but I need to fiddle with my Lua logic more before making a fool of myself in Lua :3


This post has been edited by Marforius: 09 January 2011 - 01:02 AM

0

#5 User is offline   paroxysm 

  • Chatty Cathy
  • Group: Retired
  • Posts: 320
  • Joined: 25-June 08
  • Gender:Male
  • Server OS:Windows

Posted 09 January 2011 - 01:59 AM

Last time I checked, those global RegisterxxxEvent can take a direct function rather than a string literal of the function name. Just pass in the local function directly.
0

#6 User is offline   Shrexx 

  • Member
  • Pip
  • Group: Members
  • Posts: 37
  • Joined: 29-March 10
  • Gender:Male

Posted 23 February 2011 - 02:07 PM

I'm not sure about the Pipe part.


But I think between line 19 and 20 is a "end" missing :P


Don't hurt me if i'm wrong :lol: I'M currently realy tired^^


-Shrexx

EDIT: Ohhh 1 month old thread :/ Sorry :lol:


EDIT2: Old or not, I was bored, so I fixed it.

I'm not sure about that it will work, I don't tested it ingame cuz im too lazy to create an item :D. But now there are no more errors in the world.exe.

function pipe_onUse(pItem, event, Player)
        pItem:GossipCreateMenu(50, Player, 0)
        pItem:GossipMenuAddItem(4, "1st location", 10, 0)
        pItem:GossipMenuAddItem(4, "2nd location", 20, 0)
        pItem:GossipSendMenu(Player)
end

function pipe_onSubmenu(Unit, event, Player, id, intid, code, pMisc)
        if(intid == 10) then
                Player:Teleport(554, 253.164993, 52.331608, 0.236356) -- something something dark side
                Player:GossipComplete(Player)
	end
        if(intid == 20) then
                Player:Teleport(554, 268.101990, 52.331760, 25.670067) -- something something dark side
                Player:GossipComplete(Player)
        end
end

RegisterItemGossipEvent(1000001, 1, "pipe_onUse")
RegisterItemGossipEvent(1000001, 2, "pipe_onSubmenu")


And it is new for me that Lua scripts needs ";" after each function or whatever its called in english :/ .
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users