I need a script that after having pressed X hidden pressure plate an item, a scroll, must be put into a pit (with a teleporter that bring the object on a pressure plate on the same level) that check if the scroll is right. If none the wrong item/scroll will be spawned in the inventory with a hudPrint that says something.
PS: there must be a control on the scroll item, it must be in the hand of one of the party member while the party walks on the hidden_pressure_plate. If not, there will be a reset function with a hudPrint as a hint.
SCRIPT HELP - Pressure plate + pit + scroll check
SCRIPT HELP - Pressure plate + pit + scroll check
If we do not end the war, the war will end us.
-
Lollgramoth
- Posts: 35
- Joined: Fri Jun 15, 2012 7:31 am
- Location: Germany
Re: SCRIPT HELP - Pressure plate + pit + scroll check
I don't think I understand what you need.
You want the Player to run over x hidden Pressureplates.
After doing so Spawn a Scroll, somewhere in this or an other level(?)
And after that, I got puzzeled myself.
To spawn the scroll after all the hidden Pressureplates add a counter("myCounter") and increment the counter everytime one goes over any of the specified pressureplates. Add a connector to the counter which points on a script_entities function "myPuzzle()"
in the script_entity add:
... "myScroll" is a placeholder for the name of the Item you want to add. Also the level, x, y and facing need to be modified by your needs. You can find the correct name of your scroll in ether your custom definition in items.lua or in the assets packs items.lua which contains all standard assets and you can download it here
Can you please be more explicit in what you want after what? I don't know if it's just me, but just to not give you hints you don't need.
You want the Player to run over x hidden Pressureplates.
After doing so Spawn a Scroll, somewhere in this or an other level(?)
And after that, I got puzzeled myself.
To spawn the scroll after all the hidden Pressureplates add a counter("myCounter") and increment the counter everytime one goes over any of the specified pressureplates. Add a connector to the counter which points on a script_entities function "myPuzzle()"
in the script_entity add:
Code: Select all
function myPuzzle()
if(myCounter == 10) then
-- this is how spawn is described: spawn(object, level, x, y, facing, [id])
spawn("myScroll", 1, 20,22, 3,"PuzzleScroll_1")
end
endCan you please be more explicit in what you want after what? I don't know if it's just me, but just to not give you hints you don't need.
Re: SCRIPT HELP - Pressure plate + pit + scroll check
The player must have a scroll, the party got it on alcove just before the puzzle.Lollgramoth wrote:I don't think I understand what you need.
You want the Player to run over x hidden Pressureplates.
After doing so Spawn a Scroll, somewhere in this or an other level(?)
And after that, I got puzzeled myself.
To spawn the scroll after all the hidden Pressureplates add a counter("myCounter") and increment the counter everytime one goes over any of the specified pressureplates. Add a connector to the counter which points on a script_entities function "myPuzzle()"
in the script_entity add:... "myScroll" is a placeholder for the name of the Item you want to add. Also the level, x, y and facing need to be modified by your needs. You can find the correct name of your scroll in ether your custom definition in items.lua or in the assets packs items.lua which contains all standard assets and you can download it hereCode: Select all
function myPuzzle() if(myCounter == 10) then -- this is how spawn is described: spawn(object, level, x, y, facing, [id]) spawn("myScroll", 1, 20,22, 3,"PuzzleScroll_1") end end
Can you please be more explicit in what you want after what? I don't know if it's just me, but just to not give you hints you don't need.
Then the party must have that scroll equiped in one hand of one champion and press X hidden_pressure_plate, then must throw that scroll in a pit (with teleport on a pressure plate not reachable on the same level) that open a secret door. If the scroll is not right, it will re-spawn the same item/scroll in the inventory.
If we do not end the war, the war will end us.
-
Lollgramoth
- Posts: 35
- Joined: Fri Jun 15, 2012 7:31 am
- Location: Germany
Re: SCRIPT HELP - Pressure plate + pit + scroll check
Ah! I guess you make two custom scroll for your party. One right and one wrong. You can check for their name. So one logic will be checking for the Item to be in the right place while the Party walks over the Pressureplates. Counting the pressureplates can be done by a counter or in lua script. In my example it will be done in lua Script.Daght wrote: The player must have a scroll, the party got it on alcove just before the puzzle.
Then the party must have that scroll equiped in one hand of one champion and press X hidden_pressure_plate, then must throw that scroll in a pit (with teleport on a pressure plate not reachable on the same level) that open a secret door. If the scroll is not right, it will re-spawn the same item/scroll in the inventory.
Now for the code:
SpoilerShow
Code: Select all
-- our counter
counter = 0
hpp1 = false
hpp2 = false
hpp3 = false
-- increase the counter by 1
function increaseCounter()
if (isInventoryItemInHand("arrow")) then
counter = counter + 1
end
hudPrint("You pressed" .. counter .. "hidden pressureplates.")
end
function isInventoryItemInHand(item)
for i=1,4 do
if(party:getChampion(i):getEnabled()) then
local champ = party:getChampion(i)
if(champ:getItem(7)) then
if(champ:getItem(7).name == item) then
return true
end
end
if(champ:getItem(8)) then
if(champ:getItem(8).name == item) then
return true
end
end
end
end
return false
end-
Lollgramoth
- Posts: 35
- Joined: Fri Jun 15, 2012 7:31 am
- Location: Germany
Re: SCRIPT HELP - Pressure plate + pit + scroll check
Ok, your problem is a little bit more complex as first thought. But at least i found a nice way to get the Job with the counting of pressureplates and learned a little bit more by the process.
You need pressure_plates_hidden which are not only once activated.
If you throw the scroll down you can find out, if all needed hidden pressureplates were triggered in the pressedHpp table. I think tables are an essential part of lua, so you might wanna look it up.
If you have no expierience at all with programming, read this first before you read about tables in lua.
Here is the code:
And now add the Connectors to the Lua script_entity with the code. They need to point to the function increaseCounter(the dropdown menu).
Lay down an arrow somewhere so you can pick it up and put it in a hand. Since i don't have your scroll Items, I used an arrow to point out how it works
You might wanna change the name of the item to the name of your scroll item(not the uiname but the name)
If you now walk over the plates a text will come up in your hud which tells you something like "You pressed pressure_plate_hidden_1. Tablesize: 1"
That is the half way of the job. But I am out of time for today. Work, work, work. Have fun. Maybe others can help you with the last part. I hope that is what you needed, and have fun.
You need pressure_plates_hidden which are not only once activated.
If you throw the scroll down you can find out, if all needed hidden pressureplates were triggered in the pressedHpp table. I think tables are an essential part of lua, so you might wanna look it up.
If you have no expierience at all with programming, read this first before you read about tables in lua.
Here is the code:
SpoilerShow
Code: Select all
-- our table to be used as a counter
pressedHpp = {}
-- inserts the triggering objects ID to the(initial empty) table pressedHpp
-- you can use this table as a counter. To get the number use the following
-- command: # pressedHpp (i.e. like in the end of this function in the debug info hudPrint)
-- you can also get all entities by ID were involved to increase the counter; look up "findEntry(id)"
function increaseCounter(sender)
local newEntry = false
-- if one of the champions has <item.name> in one of his hands
if (isInventoryItemInHand("arrow")) then
-- if never used then add first entry
if(pressedHpp[1] == nil) then
newEntry = true
end
-- look in the pressed Hpp table to see if the <object.id> already exists
for i = 1 , # pressedHpp do
if(pressedHpp) then
if(pressedHpp[i] == sender.id) then
-- sender.id already exists/has been triggered
newEntry = false
break
else
-- sender id is not pressedHpp at i
newEntry = true
end
else
-- debug message, there is no pressedHpp table _before_ this function known,
-- if there is _any_ in the code.
hudPrint("Variable pressedHpp doesn't exist, my friend :(")
end
end
if(newEntry) then
-- table.insert(table,position,value)
-- it does not overwrite any entry. It pushes the existing entry up one number(old:1 -> new:2)
table.insert(pressedHpp,1,sender.id)
end
end
-- debug info, what table fired the event, how many entries are in pressedHpp
-- by the way you wanna look up tables, all other variabletypes are fairly easy to use
-- table is the only one, not so easy but it will get soon essential.
hudPrint("You pressed " .. sender.id ..". Tablesize:".. # pressedHpp)
end
-- this function returns true if item was found in one of the parties champions hands, false if not.
function isInventoryItemInHand(item)
-- look up every one of the 4 possible champions in the party
for i=1,4 do
if(party:getChampion(i):getEnabled()) then
local champ = party:getChampion(i)
-- returns true if searched item is in left hand
if(champ:getItem(7)) then
if(champ:getItem(7).name == item) then
return true
end
end
-- returns true if searched item is in right hand
if(champ:getItem(8)) then
if(champ:getItem(8).name == item) then
return true
end
end
end
end
-- not found item return false
return false
endLay down an arrow somewhere so you can pick it up and put it in a hand. Since i don't have your scroll Items, I used an arrow to point out how it works
You might wanna change the name of the item to the name of your scroll item(not the uiname but the name)
If you now walk over the plates a text will come up in your hud which tells you something like "You pressed pressure_plate_hidden_1. Tablesize: 1"
That is the half way of the job. But I am out of time for today. Work, work, work. Have fun. Maybe others can help you with the last part. I hope that is what you needed, and have fun.
Re: SCRIPT HELP - Pressure plate + pit + scroll check
I got this code for now:
This is linked to a counter that open a pit. How can I implement the control over a torch that must be holded in one hand of the party for every pressureXX and, if not equiped, a hudPrint will show some hint about that?
Then i got this code:
And i need to respawn a wrong item. So if you use a scroll_fireburst it will disappear and respawn onto the ground.
Code: Select all
function pressure74()
if firecounter:getValue() == 8 then
firecounter:decrement()
hudPrint("right")
else
resetPlates()
end
end
function pressure75()
if firecounter:getValue() == 7 then
firecounter:decrement()
else
resetPlates()
end
end
function pressure76()
if firecounter:getValue() == 6 then
firecounter:decrement()
else
resetPlates()
end
end
function pressure77()
if firecounter:getValue() == 5 then
firecounter:decrement()
else
resetPlates()
end
end
function pressure78()
if firecounter:getValue() == 4 then
firecounter:decrement()
else
resetPlates()
end
end
function pressure79()
if firecounter:getValue() == 3 then
firecounter:decrement()
else
resetPlates()
end
end
function pressure80()
if firecounter:getValue() == 2 then
firecounter:decrement()
else
resetPlates()
end
end
function pressure81()
if firecounter:getValue() == 1 then
firecounter:decrement()
else
resetPlates()
end
end
function resetPlates()
firecounter:reset()
endThen i got this code:
Code: Select all
function p1()
for i in entitiesAt(5, 26, 17) do
if i.name == "scroll_fireball" then
door1:open()
end
end
end
If we do not end the war, the war will end us.
-
Lollgramoth
- Posts: 35
- Joined: Fri Jun 15, 2012 7:31 am
- Location: Germany
Re: SCRIPT HELP - Pressure plate + pit + scroll check
Use the code I posted and link the pressureplates to the function descripted. That solves all the counting completly and it also asks if the right item(in my example an arrow) is in a hand. Try it out in a new Lua entity_script. There are a lot of comments in the code to point out what does what. I hope that was a help.