Jump to content

Hae

Member
  • Posts

    3
  • Joined

  • Last visited

Hae's Achievements

  1. Hae

    Creating a random number

    ZombRand(1, 100) This generates a random number 1 to 100 In case anybody needs this info in the future
  2. Hi! I am trying to change this mod. The mod teleports the player to a tile in the world. I would like to find a random tile in one area. This is to prevent campers or to build a structure to box the player inside the fixed tile. Something like: math.randomseed(os.time()) -- seed the random number generator with the current time random_number1 = math.random(12712, 12788) random_number2 = math.random(1434, 1372) X = random_number1 Y = random_number2 ISInventoryMenuElements = ISInventoryMenuElements or {}; function ISInventoryMenuElements.ContextTeleporter() local self = ISMenuElement.new(); self.invMenu = ISContextManager.getInstance().getInventoryMenu(); function self.init() end function self.createMenu( _item ) if _item:getFullType() == "Base.BusTicket" then local teleMenu = self.invMenu.context:addOption( "Travel", self.invMenu, nil ); local telePoints = SSDart.Transporter.GetAvailablePoints(); local submenu = self.invMenu.context:getNew( self.invMenu.context ); self.invMenu.context:addSubMenu( teleMenu, submenu ); print("======================> Processing '" .. #telePoints .. "' traveling points" ); for _, pointName in ipairs(telePoints) do submenu:addOption( "Travel to '" .. pointName .."'", self.invMenu, self.TeleportTo, pointName ); end if SSDart.Transporter.CanReturn() then submenu:addOption( "Return", self.invMenu, self.Return ); end end end function self.TeleportTo( items, player, pointName ) SSDart.Transporter.MoveTo( items, player ); end function self.Return( player ) SSDart.Transporter.Return( player ); end function self.openMovableCursor( _p, _item ) local tpx = 12697; local tpy = 2347; local tpz = 0; local player = _p.player; player:setX(tpx); player:setY(tpy); player:setZ(tpz); player:setLx(player:getX()); player:setLy(player:getY()); player:setLz(player:getZ()); end return self; end SSDart = SSDart or {}; local function transporterInit() local transporter = { _regPoints = {}, _returnPoint = {} } function transporter.AddPoint( id, x, y, z ) if not id then error("There was no ID given", 2 ); end if type(id) ~= "string" then error("The given ID is not a string", 2 ); end transporter._regPoints[ id ] = { X = x, Y = y, Z = z or 0 } end function transporter.MoveTo( player, id ) print("=======================> Moving player '" .. tostring(player) .. "' to point '" .. id .. "'"); player = player.player; print("=======================> Moving player '" .. tostring(player) .. "' to point '" .. id .. "'"); local lastPos = { X = player:getX(), Y = player:getY(), Z = player:getZ() } local newPoint = transporter.GetPoint( id ); player:setX( newPoint.X ); player:setY( newPoint.Y ); player:setZ( newPoint.Z ); player:setLx( newPoint.X ); player:setLy( newPoint.Y ); player:setLz( newPoint.Z ); transporter._returnPoint.Last = lastPos; end function transporter.GetAvailablePoints() local points = {}; for pointName, _ in pairs(transporter._regPoints) do table.insert(points, pointName); end return points; end function transporter.GetPoint( id ) for pointName, point in pairs(transporter._regPoints) do if pointName == id then return point; end end error("There is no point with ID of '" .. id .. "'", 2 ); end function transporter.CanReturn() if not transporter._returnPoint.Last then return false; else return true; end end function transporter.Return( player ) player = player.player; local returnPoint = transporter._returnPoint.Last; player:setX( returnPoint.X ); player:setY( returnPoint.Y ); player:setZ( returnPoint.Z ); player:setLx( returnPoint.X ); player:setLy( returnPoint.Y ); player:setLz( returnPoint.Z ); transporter._returnPoint.Last = nil; end return { AddPoint = transporter.AddPoint, MoveTo = transporter.MoveTo, GetAvailablePoints = transporter.GetAvailablePoints, CanReturn = transporter.CanReturn, Return = transporter.Return } end SSDart.Transporter = transporterInit(); SSDart.Transporter.AddPoint( "Louisville", 12697, 2347 ); SSDart.Transporter.AddPoint( "Rosewood", 8093, 11658 ); SSDart.Transporter.AddPoint( "WestPoint", 11927, 6886 ); SSDart.Transporter.AddPoint( "Muldraugh", 10604, 9934 ); SSDart.Transporter.AddPoint( "Riverside", 6538, 5309 ); SSDart.Transporter.AddPoint( "MarchRidge", 10009, 12706 ); SSDart.Transporter.AddPoint( "Raven Creek", 4018, 11245 ); SSDart.Transporter.AddPoint( "Ashenwood", 11459, 11230 ); BT.Transporter.AddPoint( "Grapeseed", 7312, 11192 ); BT.Transporter.AddPoint( "Blackwood", 8095, 10735 ); BT.Transporter.AddPoint( "Ekron", 7272, 8540 ); BT.Transporter.AddPoint( "Chestown", 4546, 6792 );
  3. Hi! Can you help me with the code to change the Displayname of an item from the sand box? --WITH SANDBOX OPTIONS require('NPCs/MainCreationMethods'); local NAME1; local function setLocalSandboxVars() NAME1 = SandboxVars.PerpetualItems.Name1; if NAME1 == nil then NAME1 = "Epic Hatchet"; end end local function initItemNamePerpetual() setLocalSandboxVars(); end local item1 = getItemDisplayName(BCGTools.KukriMachete); item1:setItemDisplayName(BCGTools.KukriMachete); Events.OnGameStart.Add(initItemNamePerpetual);
×
×
  • Create New...